Use ID3v2::FrameFactory also for AIFF

This commit is contained in:
Urs Fleisch 2023-11-18 14:22:19 +01:00
parent b7dc1ab8ac
commit b993e70cf4
2 changed files with 27 additions and 7 deletions

View File

@ -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> properties;
std::unique_ptr<ID3v2::Tag> 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<FilePrivate>())
d(std::make_unique<FilePrivate>(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<FilePrivate>())
d(std::make_unique<FilePrivate>(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<ID3v2::Tag>(this, chunkOffset(i));
d->tag = std::make_unique<ID3v2::Tag>(this, chunkOffset(i),
d->ID3v2FrameFactory);
d->hasID3v2 = true;
}
else {

View File

@ -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.