Skip to content

Commit

Permalink
[Taglib] Use non-deprecated constructors for MPEG::File/FLAC::File
Browse files Browse the repository at this point in the history
The old constructor taking the FrameFactory as second, non-optional
parameter has been deprecated, and replaced with a constructor taking
the default'ed FrameFactory as an optional 4th parameter (the 3rd
parameter, Properties::ReadStyle, is also defaulted).

Unfortunately, older versions require a FrameFactory for the `FileStream`
constructor overload.
  • Loading branch information
StefanBruens committed Aug 5, 2024
1 parent ba053bc commit 5264254
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/extractors/taglibextractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,11 @@ void TagLibExtractor::extract(ExtractionResult* result)
};

if (mimeType == QLatin1String("audio/mpeg")) {
#if TAGLIB_MAJOR_VERSION >= 2
TagLib::MPEG::File file(&stream, true);
#else
TagLib::MPEG::File file(&stream, TagLib::ID3v2::FrameFactory::instance(), true);
#endif
if (file.isValid()) {
extractAudioProperties(&file, result);
readGenericProperties(file.properties(), result);
Expand Down Expand Up @@ -634,7 +638,11 @@ void TagLibExtractor::extract(ExtractionResult* result)
result->addImageData(extractMp4Cover(file.tag(), imageTypes));
}
} else if (mimeType == QLatin1String("audio/flac")) {
#if TAGLIB_MAJOR_VERSION >= 2
TagLib::FLAC::File file(&stream, true);
#else
TagLib::FLAC::File file(&stream, TagLib::ID3v2::FrameFactory::instance(), true);
#endif
if (file.isValid()) {
extractAudioProperties(&file, result);
readGenericProperties(file.properties(), result);
Expand Down
8 changes: 8 additions & 0 deletions src/writers/taglibwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,11 @@ void TagLibWriter::write(const WriteData& data)
}

if (mimeType == QLatin1String("audio/mpeg")) {
#if TAGLIB_MAJOR_VERSION >= 2
TagLib::MPEG::File file(&stream, false);
#else
TagLib::MPEG::File file(&stream, TagLib::ID3v2::FrameFactory::instance(), false);
#endif
if (file.isValid()) {
auto savedProperties = file.properties();
writeGenericProperties(savedProperties, properties);
Expand Down Expand Up @@ -609,7 +613,11 @@ void TagLibWriter::write(const WriteData& data)
file.save();
}
} else if (mimeType == QLatin1String("audio/flac")) {
#if TAGLIB_MAJOR_VERSION >= 2
TagLib::FLAC::File file(&stream, false);
#else
TagLib::FLAC::File file(&stream, TagLib::ID3v2::FrameFactory::instance(), false);
#endif
if (file.isValid()) {
auto savedProperties = file.properties();
writeGenericProperties(savedProperties, properties);
Expand Down

0 comments on commit 5264254

Please sign in to comment.