From a77abedf631834f3476f7c2d9cd958c4a6b55e3e Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Fri, 12 Jun 2015 17:41:01 +0900 Subject: [PATCH] Remove some more data members not needed to carry. --- taglib/flac/flacfile.cpp | 40 +++++++++++++++++++--------------------- taglib/flac/flacfile.h | 5 ++--- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/taglib/flac/flacfile.cpp b/taglib/flac/flacfile.cpp index 090c6164..e1db4bc2 100644 --- a/taglib/flac/flacfile.cpp +++ b/taglib/flac/flacfile.cpp @@ -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 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; } diff --git a/taglib/flac/flacfile.h b/taglib/flac/flacfile.h index 3dce89cb..367a5bf2 100644 --- a/taglib/flac/flacfile.h +++ b/taglib/flac/flacfile.h @@ -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; -- 2.40.0