-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
base: 2.4
Are you sure you want to change the base?
Conversation
…ough the call stack to avoid guessing it from the file extension.
No longer guess the fileType from the file extension.
There was a problem hiding this 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?
Co-authored-by: Antoine Colombier <7086688+acolombier@users.noreply.github.com>
src/test/soundproxy_test.cpp
Outdated
@@ -1086,3 +1087,14 @@ TEST_F(SoundSourceProxyTest, freeModeGarbage) { | |||
break; | |||
} | |||
} | |||
|
|||
TEST_F(SoundSourceProxyTest, taglibStringToEnumFileType) { | |||
for (const auto& fileType : SoundSourceProxy::getSupportedFileTypes()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clazy here
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") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QStringLiteral, otherwise implicitly converts
// This table is aligned with detectByExtension() in fileref.cpp | ||
constexpr std::array lookupTable = { | ||
TypePair{"mp3"_L1, FileType::MPEG}, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
// 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}, |
taglib::FileType fileType) | ||
const QString& fileType) | ||
: m_fileName(fileName), | ||
m_fileType(fileType) { | ||
m_fileType(taglib::stringToEnumFileType(fileType)) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
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