Skip to content

Commit

Permalink
Create comment tag as both COMMENT and DESCRIPTION, and warn for file…
Browse files Browse the repository at this point in the history
… error in metadata read and multiple tag values.

I can find no authoritative source that says whether comment tags from m4a files should be saved in flac files as COMMENT or
DESCRIPTION tags.  Max does it as DESCRIPTION, but mp3tag looks like it expects COMMENT.  Other references I found
vary too.  So save a comment as both, until I find a more correct answer.  Also fixed a potential crash in the event taglib couldn't
turn a fileref into a file object when reading metadata in the alac to flac conversion, and warned in the event there are more than
one tag values for a particular tag key.  We only convert the first one.  Multiple values would sometimes be legal, but we don't
expect them.  Put in the warning so I could hear if that becomes an issue.
  • Loading branch information
tattwamasi committed May 14, 2015
1 parent 425d8ed commit d8f1412
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions TeslaTunes/flac_utils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,16 @@ auto FlacMetadataFromMP4fileURL(const NSURL *mp4, std::vector<FLAC__StreamMetada
if (!vorb) {
return metadata.size();
}
if (!f.file()) {
NSLog(@"Couldn't read extended tags from \"%s\".", mp4.fileSystemRepresentation);
}
auto props = f.file()->properties();
//NSLog(@"Properties in Apple Lossless file %s", mp4.fileSystemRepresentation);
for (auto p : props) {
//NSLog(@"Property: \"%s\" (%u) => \"%s\"", p.first.toCString(true), p.second.size(), p.second.toString().toCString(true) );
if (p.second.size() != 1) {
NSLog(@"warning: expected one, but found %u values for tag \"%s\".", p.second.size(), p.first.toCString(true));
}
if (p.first == "TRACKNUMBER") {
// taglib seems to format the property as t/n where t is the current track number and n is the number of tracks.
// if this is the form, then split it up and set both TRACKNUMBER and TRACKTOTAL. If we can't scan it in the
Expand All @@ -140,8 +146,11 @@ auto FlacMetadataFromMP4fileURL(const NSURL *mp4, std::vector<FLAC__StreamMetada
} else {
addVorbisCommentIfExists(vorb, p.first, p.second.front() );
}
} else if (p.first == "COMMENT") {
addVorbisCommentIfExists(vorb, "DESCRIPTION", p.second.front());
addVorbisCommentIfExists(vorb, p.first, p.second.front() );
} else {
addVorbisCommentIfExists(vorb, p.first, p.second.front());
addVorbisCommentIfExists(vorb, p.first, p.second.front() );
}
}
#if 0
Expand All @@ -150,11 +159,7 @@ auto FlacMetadataFromMP4fileURL(const NSURL *mp4, std::vector<FLAC__StreamMetada
NSLog(@"Unsupported data item: \"%s\"", s.toCString(true));
}
#endif
// Comment
if (t->comment() != TagLib::String::null) {
NSLog(@"********** ALAC file had a comment, %s", t->comment().toCString(true));
}
addVorbisCommentIfExists(vorb, "DESCRIPTION", t->comment());

// done with Vorbis tag
metadata.push_back(vorb);
return metadata.size();
Expand Down

0 comments on commit d8f1412

Please sign in to comment.