-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(taglib): read cover art from dsf, wavpak, fix wma test #4296
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
Conversation
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.
Summary of Changes
Hello @kgarner7, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request addresses a bug where cover art embedded in DSF/DSD audio files was not being recognized by the taglib
wrapper. It introduces specific logic to correctly identify and extract cover art from these files, ensuring that applications utilizing this wrapper can now display embedded artwork for DSF content, resolving the issue described in #4278.
Highlights
- Bug Fix: DSF Cover Art Detection: I've added specific handling within the
has_cover
function intaglib_wrapper.cpp
to correctly identify embedded cover art in DSF/DSD audio files. This is achieved by checking for the presence of the "APIC" frame within the ID3 tag structure of DSF files.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request adds support for detecting cover art in DSF files. A null pointer dereference issue was identified and a suggestion to add a null check has been provided.
adapters/taglib/taglib_wrapper.cpp
Outdated
const auto& frameListMap = dsffile->tag()->frameListMap(); | ||
hasCover = !frameListMap["APIC"].isEmpty(); |
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.
The dsffile->tag()
method can return a nullptr
if the file does not contain any tags. Dereferencing a null pointer by calling ->frameListMap()
will lead to a crash. Add a null check before accessing the tag's methods.
const auto& frameListMap = dsffile->tag()->frameListMap(); | |
hasCover = !frameListMap["APIC"].isEmpty(); | |
const auto* tag = dsffile->tag(); | |
hasCover = tag && !tag->frameListMap()["APIC"].isEmpty(); |
/gemini review |
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.
Code Review
This pull request adds support for detecting cover art in DSF and WavPack files, and improves tag handling for WMA files by supporting multi-value tags. The changes include updates to the C++ wrapper to implement the new logic, and corresponding updates to Go tests to verify the new functionality. The implementation looks correct, but I have a couple of suggestions to improve the C++ code quality by using const_cast
instead of C-style casts for better type safety and maintainability.
adapters/taglib/taglib_wrapper.cpp
Outdated
@@ -174,7 +174,14 @@ int taglib_read(const FILENAME_CHAR_T *filename, unsigned long id) { | |||
const TagLib::ASF::Tag *asfTags{asfFile->tag()}; | |||
const auto itemListMap = asfTags->attributeListMap(); | |||
for (const auto item : itemListMap) { | |||
tags.insert(item.first, item.second.front().toString()); | |||
char *key = (char *)item.first.toCString(true); |
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.
Using a C-style cast (char *)
to remove the const
qualifier is discouraged in C++. It's better to use const_cast
which is type-safe and clearly expresses the intent of casting away const-ness. This also makes the code easier to maintain and search for potentially dangerous casts.
char *key = (char *)item.first.toCString(true); | |
char *key = const_cast<char *>(item.first.toCString(true)); |
adapters/taglib/taglib_wrapper.cpp
Outdated
for (auto j = item.second.begin(); | ||
j != item.second.end(); ++j) { | ||
|
||
char *val = (char *) j->toString().toCString(true); |
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.
Description
DSF/DSD (or, at least Picard) appears to store cover art in APIC field (ID3). Extract this in taglib for
has_cover
Also make reading from wma a bit safer, fix the tests, and read from WavPack (APE tags only, not ID3v1).
Related Issues
Fixes #4278
Type of Change
Checklist
Please review and check all that apply:
How to Test
I could not for the life of me figure out how to trim a DSF file to 1 second. So, to test:
navidrome inspect $file
shows"hasCoverArt": true,
Agents
set to an empty string, shows the embedded cover art for the album and songFor the other formats, just
make test PKG=./adapters/taglib
Screenshots / Demos (if applicable)
Inspect output:
inspect_output.json
Embedding a completely unrelated screenshot into the album:

Additional Notes