]> granicus.if.org Git - taglib/commitdiff
Remove some more data members not needed to carry.
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Fri, 12 Jun 2015 08:41:01 +0000 (17:41 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Fri, 31 Jul 2015 15:49:22 +0000 (00:49 +0900)
taglib/flac/flacfile.cpp
taglib/flac/flacfile.h

index 090c6164f8ba46a6428bff0ddcc306b9dc133ee2..e1db4bc24f27e1df3afcd9b5e95c5d22768ac817 100644 (file)
@@ -60,7 +60,6 @@ public:
     properties(0),
     flacStart(0),
     streamStart(0),
-    streamLength(0),
     scanned(false),
     hasXiphComment(false),
     hasID3v2(false),
@@ -86,13 +85,11 @@ public:
   TagUnion tag;
 
   Properties *properties;
-  ByteVector streamInfoData;
   ByteVector xiphCommentData;
   List<MetadataBlock *> blocks;
 
   long flacStart;
   long streamStart;
-  long streamLength;
   bool scanned;
 
   bool hasXiphComment;
@@ -176,7 +173,6 @@ FLAC::Properties *FLAC::File::audioProperties() const
   return d->properties;
 }
 
-
 bool FLAC::File::save()
 {
   if(readOnly()) {
@@ -294,7 +290,6 @@ void FLAC::File::setID3v2FrameFactory(const ID3v2::FrameFactory *factory)
   d->ID3v2FrameFactory = factory;
 }
 
-
 ////////////////////////////////////////////////////////////////////////////////
 // private members
 ////////////////////////////////////////////////////////////////////////////////
@@ -334,27 +329,35 @@ void FLAC::File::read(bool readProperties, Properties::ReadStyle propertiesStyle
     return;
 
   if(d->hasXiphComment)
-    d->tag.set(FlacXiphIndex, new Ogg::XiphComment(xiphCommentData()));
+    d->tag.set(FlacXiphIndex, new Ogg::XiphComment(d->xiphCommentData));
   else
     d->tag.set(FlacXiphIndex, new Ogg::XiphComment);
 
-  if(readProperties)
-    d->properties = new Properties(streamInfoData(), streamLength(), propertiesStyle);
-}
+  if(readProperties) {
 
-ByteVector FLAC::File::streamInfoData()
-{
-  return isValid() ? d->streamInfoData : ByteVector();
+    // First block should be the stream_info metadata
+
+    const ByteVector infoData = d->blocks.front()->render();
+
+    long streamLength;
+
+    if(d->hasID3v1)
+      streamLength = d->ID3v1Location - d->streamStart;
+    else
+      streamLength = File::length() - d->streamStart;
+
+    d->properties = new Properties(infoData, streamLength, propertiesStyle);
+  }
 }
 
-ByteVector FLAC::File::xiphCommentData() const
+ByteVector FLAC::File::streamInfoData()
 {
-  return (isValid() && d->hasXiphComment) ? d->xiphCommentData : ByteVector();
+  return ByteVector();
 }
 
 long FLAC::File::streamLength()
 {
-  return d->streamLength;
+  return 0;
 }
 
 void FLAC::File::scan()
@@ -409,8 +412,7 @@ void FLAC::File::scan()
     return;
   }
 
-  d->streamInfoData = readBlock(length);
-  d->blocks.append(new UnknownMetadataBlock(blockType, d->streamInfoData));
+  d->blocks.append(new UnknownMetadataBlock(blockType, readBlock(length)));
   nextBlockOffset += length + 4;
 
   // Search through the remaining metadata
@@ -480,10 +482,6 @@ void FLAC::File::scan()
   // End of metadata, now comes the datastream
 
   d->streamStart = nextBlockOffset;
-  d->streamLength = File::length() - d->streamStart;
-
-  if(d->hasID3v1)
-    d->streamLength -= 128;
 
   d->scanned = true;
 }
index 3dce89cbc2bc2b1d1dca3de37d4069c696e1f0b4..367a5bf2d974ed0f38b5e16e1bc83be90439057b 100644 (file)
@@ -229,7 +229,7 @@ namespace TagLib {
        * Returns the block of data used by FLAC::Properties for parsing the
        * stream properties.
        *
-       * \deprecated This method will not be public in a future release.
+       * \deprecated Always returns an empty vector.
        */
       ByteVector streamInfoData(); // BIC: remove
 
@@ -237,7 +237,7 @@ namespace TagLib {
        * Returns the length of the audio-stream, used by FLAC::Properties for
        * calculating the bitrate.
        *
-       * \deprecated This method will not be public in a future release.
+       * \deprecated Always returns zero.
        */
       long streamLength();  // BIC: remove
 
@@ -294,7 +294,6 @@ namespace TagLib {
       void scan();
       long findID3v2();
       long findID3v1();
-      ByteVector xiphCommentData() const;
 
       class FilePrivate;
       FilePrivate *d;