From b993e70cf4264b31a9b5f571040017fe824de96d Mon Sep 17 00:00:00 2001 From: Urs Fleisch Date: Sat, 18 Nov 2023 14:22:19 +0100 Subject: [PATCH] Use ID3v2::FrameFactory also for AIFF --- taglib/riff/aiff/aifffile.cpp | 22 +++++++++++++++++----- taglib/riff/aiff/aifffile.h | 12 ++++++++++-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/taglib/riff/aiff/aifffile.cpp b/taglib/riff/aiff/aifffile.cpp index 3c4edc00..f31efd59 100644 --- a/taglib/riff/aiff/aifffile.cpp +++ b/taglib/riff/aiff/aifffile.cpp @@ -34,6 +34,15 @@ using namespace TagLib; class RIFF::AIFF::File::FilePrivate { public: + FilePrivate(ID3v2::FrameFactory *frameFactory) + : ID3v2FrameFactory(frameFactory ? frameFactory + : ID3v2::FrameFactory::instance()) + { + } + + ~FilePrivate() = default; + + const ID3v2::FrameFactory *ID3v2FrameFactory; std::unique_ptr properties; std::unique_ptr tag; @@ -56,17 +65,19 @@ bool RIFF::AIFF::File::isSupported(IOStream *stream) // public members //////////////////////////////////////////////////////////////////////////////// -RIFF::AIFF::File::File(FileName file, bool readProperties, Properties::ReadStyle) : +RIFF::AIFF::File::File(FileName file, bool readProperties, Properties::ReadStyle, + ID3v2::FrameFactory *frameFactory) : RIFF::File(file, BigEndian), - d(std::make_unique()) + d(std::make_unique(frameFactory)) { if(isOpen()) read(readProperties); } -RIFF::AIFF::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : +RIFF::AIFF::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle, + ID3v2::FrameFactory *frameFactory) : RIFF::File(stream, BigEndian), - d(std::make_unique()) + d(std::make_unique(frameFactory)) { if(isOpen()) read(readProperties); @@ -145,7 +156,8 @@ void RIFF::AIFF::File::read(bool readProperties) const ByteVector name = chunkName(i); if(name == "ID3 " || name == "id3 ") { if(!d->tag) { - d->tag = std::make_unique(this, chunkOffset(i)); + d->tag = std::make_unique(this, chunkOffset(i), + d->ID3v2FrameFactory); d->hasID3v2 = true; } else { diff --git a/taglib/riff/aiff/aifffile.h b/taglib/riff/aiff/aifffile.h index 1f6cded4..a9288708 100644 --- a/taglib/riff/aiff/aifffile.h +++ b/taglib/riff/aiff/aifffile.h @@ -62,9 +62,13 @@ namespace TagLib { * file's audio properties will also be read. * * \note In the current implementation, \a propertiesStyle is ignored. + * + * If this file contains an ID3v2 tag, the frames will be created using + * \a frameFactory (default if null). */ File(FileName file, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + Properties::ReadStyle propertiesStyle = Properties::Average, + ID3v2::FrameFactory *frameFactory = nullptr); /*! * Constructs an AIFF file from \a stream. If \a readProperties is true the @@ -74,9 +78,13 @@ namespace TagLib { * responsible for deleting it after the File object. * * \note In the current implementation, \a propertiesStyle is ignored. + * + * If this file contains an ID3v2 tag, the frames will be created using + * \a frameFactory (default if null). */ File(IOStream *stream, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + Properties::ReadStyle propertiesStyle = Properties::Average, + ID3v2::FrameFactory *frameFactory = nullptr); /*! * Destroys this instance of the File.