From ceb989f170657cbf54c8270d9992b3be36db61f0 Mon Sep 17 00:00:00 2001
From: Scott Wheeler <wheeler@kde.org>
Date: Tue, 4 May 2004 01:47:01 +0000
Subject: [PATCH] Don't append a framing bit when writing Xiph comments to FLAC
 files since this renders them unplayable with some players.  Thanks to Jason
 Lee for tracking this down!

CCMAIL:75880-done@bugs.kde.org


git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@308437 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
---
 flac/flacfile.cpp   |  2 +-
 ogg/xiphcomment.cpp | 10 ++++++++--
 ogg/xiphcomment.h   | 11 ++++++++++-
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/flac/flacfile.cpp b/flac/flacfile.cpp
index 50fa324b..b8315ee4 100644
--- a/flac/flacfile.cpp
+++ b/flac/flacfile.cpp
@@ -132,7 +132,7 @@ void FLAC::File::save()
       Tag::duplicate(d->tag, d->comment, true);
   }
 
-  d->xiphCommentData = d->comment->render();
+  d->xiphCommentData = d->comment->render(false);
 
   ByteVector v = ByteVector::fromUInt(d->xiphCommentData.size());
 
diff --git a/ogg/xiphcomment.cpp b/ogg/xiphcomment.cpp
index 2e781bcb..62c45ec4 100644
--- a/ogg/xiphcomment.cpp
+++ b/ogg/xiphcomment.cpp
@@ -197,6 +197,11 @@ void Ogg::XiphComment::removeField(const String &key, const String &value)
 }
 
 ByteVector Ogg::XiphComment::render() const
+{
+  return render(true);
+}
+
+ByteVector Ogg::XiphComment::render(bool addFramingBit) const
 {
   ByteVector data;
 
@@ -238,8 +243,9 @@ ByteVector Ogg::XiphComment::render() const
   }
 
   // Append the "framing bit".
-
-  data.append(char(1));
+ 
+  if(addFramingBit)
+    data.append(char(1));
 
   return data;
 }
diff --git a/ogg/xiphcomment.h b/ogg/xiphcomment.h
index 6e899fa1..dbcde9d5 100644
--- a/ogg/xiphcomment.h
+++ b/ogg/xiphcomment.h
@@ -159,7 +159,16 @@ namespace TagLib {
       /*!
        * Renders the comment to a ByteVector suitable for inserting into a file.
        */
-      ByteVector render() const;
+      ByteVector render() const; // BIC: remove and merge with below
+
+      /*!
+       * Renders the comment to a ByteVector suitable for inserting into a file.
+       *
+       * If \a addFramingBit is true the standard Vorbis comment framing bit will
+       * be appended.  However some formats (notably FLAC) do not work with this
+       * in place.
+       */
+      ByteVector render(bool addFramingBit) const;
 
     protected:
       /*!