mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-03 07:33:49 +01:00
Bug 2217 - Metadata: When exporting to FLAC the "Comment" field is ignored and not exported with the audio file
I don't know how I lost the original changes, but here they are again.
This commit is contained in:
@@ -461,15 +461,25 @@ bool ExportFLAC::GetMetadata(AudacityProject *project, const Tags *tags)
|
||||
n = wxT("DATE");
|
||||
}
|
||||
else if (n == TAG_COMMENTS) {
|
||||
// N.B. There seems to be COMMENT and DESCRIPTION in use.
|
||||
// Some apps like Foobar use COMMENT and some like Windows use DESCRIPTION,
|
||||
// so add both to try and make everyone happy.
|
||||
n = wxT("COMMENT");
|
||||
FLAC::Metadata::VorbisComment::Entry entry(n.mb_str(wxConvUTF8),
|
||||
v.mb_str(wxConvUTF8));
|
||||
if (! ::FLAC__metadata_object_vorbiscomment_append_comment(mMetadata.get(),
|
||||
entry.get_entry(),
|
||||
true) ) {
|
||||
return false;
|
||||
}
|
||||
n = wxT("DESCRIPTION");
|
||||
}
|
||||
FLAC::Metadata::VorbisComment::Entry entry(n.mb_str(wxConvUTF8),
|
||||
v.mb_str(wxConvUTF8));
|
||||
if (! ::FLAC__metadata_object_vorbiscomment_append_comment(mMetadata.get(),
|
||||
entry.get_entry(),
|
||||
true) )
|
||||
true) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -440,20 +440,39 @@ ProgressResult FLACImportFileHandle::Import(WaveTrackFactory *trackFactory,
|
||||
if (!mChannels.empty())
|
||||
outTracks.push_back(std::move(mChannels));
|
||||
|
||||
wxString comment;
|
||||
wxString description;
|
||||
|
||||
tags->Clear();
|
||||
size_t cnt = mFile->mComments.size();
|
||||
for (size_t c = 0; c < cnt; c++) {
|
||||
wxString name = mFile->mComments[c].BeforeFirst(wxT('='));
|
||||
wxString value = mFile->mComments[c].AfterFirst(wxT('='));
|
||||
if (name.Upper() == wxT("DATE") && !tags->HasTag(TAG_YEAR)) {
|
||||
wxString upper = name.Upper();
|
||||
if (upper == wxT("DATE") && !tags->HasTag(TAG_YEAR)) {
|
||||
long val;
|
||||
if (value.length() == 4 && value.ToLong(&val)) {
|
||||
name = TAG_YEAR;
|
||||
}
|
||||
}
|
||||
else if (upper == wxT("COMMENT") || upper == wxT("COMMENTS")) {
|
||||
comment = value;
|
||||
continue;
|
||||
}
|
||||
else if (upper == wxT("DESCRIPTION")) {
|
||||
description = value;
|
||||
continue;
|
||||
}
|
||||
tags->SetTag(name, value);
|
||||
}
|
||||
|
||||
if (comment.empty()) {
|
||||
comment = description;
|
||||
}
|
||||
if (!comment.empty()) {
|
||||
tags->SetTag(TAG_COMMENTS, comment);
|
||||
}
|
||||
|
||||
return mUpdateResult;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user