Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reading metadata for some file extensions #13218

Open
wants to merge 6 commits into
base: 2.4
Choose a base branch
from

Conversation

daschuer
Copy link
Member

@daschuer daschuer commented May 6, 2024

This replaces all file type guessing code form the file extension, by using the normalized file type stored in the Track object.
This makes sure all parts are using the same file type, even if the extension is wrong.

This fixes #13205

…ough the call stack to avoid guessing it from the file extension.
Copy link
Contributor

@acolombier acolombier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be worth adding one or few test case to ensure the behaviour and prevent potential regression?

src/track/taglib/trackmetadata_file.cpp Outdated Show resolved Hide resolved
Co-authored-by: Antoine Colombier <7086688+acolombier@users.noreply.github.com>
@@ -1086,3 +1087,14 @@ TEST_F(SoundSourceProxyTest, freeModeGarbage) {
break;
}
}

TEST_F(SoundSourceProxyTest, taglibStringToEnumFileType) {
for (const auto& fileType : SoundSourceProxy::getSupportedFileTypes()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clazy here

@daschuer
Copy link
Member Author

All green now.

@@ -82,7 +83,7 @@ double SeratoTags::guessTimingOffsetMillis(
// PR for more detailed information:
// https://github.com/mixxxdj/mixxx/pull/2119
double timingOffset = 0;
if (taglib::getFileTypeFromFileName(filePath) == taglib::FileType::MP3) {
if (fileType == "mp3") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QStringLiteral, otherwise implicitly converts

Comment on lines +66 to +68
// This table is aligned with detectByExtension() in fileref.cpp
constexpr std::array lookupTable = {
TypePair{"mp3"_L1, FileType::MPEG},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one day we should think about introducing a "minimal perfect hash function"-based approach for LUTs like these.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll also need to make it static, otherwise the compiler is more likely to choose to create it at runtime.

Suggested change
// This table is aligned with detectByExtension() in fileref.cpp
constexpr std::array lookupTable = {
TypePair{"mp3"_L1, FileType::MPEG},
// This table is aligned with detectByExtension() in fileref.cpp
constexpr static std::array lookupTable = {
TypePair{"mp3"_L1, FileType::MPEG},

Comment on lines -17 to +14
taglib::FileType fileType)
const QString& fileType)
: m_fileName(fileName),
m_fileType(fileType) {
m_fileType(taglib::stringToEnumFileType(fileType)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats the advantage of taking a string here instead of shifting the conversion duty to the caller? This smells stringly-typed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi, two of the other three comments were redundant if this would avoid strings better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants