1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-25 15:53:52 +02:00

Bugs 188 and 225

Refer to bugzilla for discussion, but, to summarize, this removes any writing of ID3V1 tags.  ID3V1 tags will still be imported, but they will be written as ID3V2 tags.
This commit is contained in:
lllucius
2011-03-01 07:06:58 +00:00
parent 031a9e0af3
commit 60af76d2b3
6 changed files with 37 additions and 102 deletions

View File

@@ -187,7 +187,7 @@ private:
int AddTags(AudacityProject *project, char **buffer, bool *endOfFile, Tags *tags);
#ifdef USE_LIBID3TAG
void AddFrame(struct id3_tag *tp, bool v2, const wxString & n, const wxString & v, const char *name);
void AddFrame(struct id3_tag *tp, const wxString & n, const wxString & v, const char *name);
#endif
};
@@ -344,8 +344,6 @@ int ExportMP2::AddTags(AudacityProject *project, char **buffer, bool *endOfFile,
#ifdef USE_LIBID3TAG
struct id3_tag *tp = id3_tag_new();
bool v2 = tags->GetID3V2();
wxString n, v;
for (bool cont = tags->GetFirst(n, v); cont; cont = tags->GetNext(n, v)) {
const char *name = "TXXX";
@@ -362,14 +360,11 @@ int ExportMP2::AddTags(AudacityProject *project, char **buffer, bool *endOfFile,
else if (n.CmpNoCase(TAG_YEAR) == 0) {
// LLL: Some apps do not like the newer frame ID (ID3_FRAME_YEAR),
// so we add old one as well.
AddFrame(tp, v2, n, v, "TYER");
AddFrame(tp, n, v, "TYER");
name = ID3_FRAME_YEAR;
}
else if (n.CmpNoCase(TAG_GENRE) == 0) {
name = ID3_FRAME_GENRE;
if (!v2) {
v.Printf(wxT("%d"), tags->GetGenre(v));
}
}
else if (n.CmpNoCase(TAG_COMMENTS) == 0) {
name = ID3_FRAME_COMMENT;
@@ -378,25 +373,19 @@ int ExportMP2::AddTags(AudacityProject *project, char **buffer, bool *endOfFile,
name = ID3_FRAME_TRACK;
}
AddFrame(tp, v2, n, v, name);
AddFrame(tp, n, v, name);
}
if (v2) {
tp->options &= (~ID3_TAG_OPTION_COMPRESSION); // No compression
tp->options &= (~ID3_TAG_OPTION_COMPRESSION); // No compression
// If this version of libid3tag supports it, use v2.3 ID3
// tags instead of the newer, but less well supported, v2.4
// that libid3tag uses by default.
#ifdef ID3_TAG_HAS_TAG_OPTION_ID3V2_3
tp->options |= ID3_TAG_OPTION_ID3V2_3;
#endif
// If this version of libid3tag supports it, use v2.3 ID3
// tags instead of the newer, but less well supported, v2.4
// that libid3tag uses by default.
#ifdef ID3_TAG_HAS_TAG_OPTION_ID3V2_3
tp->options |= ID3_TAG_OPTION_ID3V2_3;
#endif
*endOfFile = false;
}
else {
tp->options |= ID3_TAG_OPTION_ID3V1;
*endOfFile = true;
}
*endOfFile = false;
id3_length_t len;
@@ -413,17 +402,15 @@ int ExportMP2::AddTags(AudacityProject *project, char **buffer, bool *endOfFile,
}
#ifdef USE_LIBID3TAG
void ExportMP2::AddFrame(struct id3_tag *tp, bool v2, const wxString & n, const wxString & v, const char *name)
void ExportMP2::AddFrame(struct id3_tag *tp, const wxString & n, const wxString & v, const char *name)
{
struct id3_frame *frame = id3_frame_new(name);
if (v2) {
if (!n.IsAscii() || !v.IsAscii()) {
id3_field_settextencoding(id3_frame_field(frame, 0), ID3_FIELD_TEXTENCODING_UTF_16);
}
else {
id3_field_settextencoding(id3_frame_field(frame, 0), ID3_FIELD_TEXTENCODING_ISO_8859_1);
}
if (!n.IsAscii() || !v.IsAscii()) {
id3_field_settextencoding(id3_frame_field(frame, 0), ID3_FIELD_TEXTENCODING_UTF_16);
}
else {
id3_field_settextencoding(id3_frame_field(frame, 0), ID3_FIELD_TEXTENCODING_ISO_8859_1);
}
id3_ucs4_t *ucs4 =

View File

@@ -1486,7 +1486,7 @@ private:
int AskResample(int bitrate, int rate, int lowrate, int highrate);
int AddTags(AudacityProject *project, char **buffer, bool *endOfFile, Tags *tags);
#ifdef USE_LIBID3TAG
void AddFrame(struct id3_tag *tp, bool v2, const wxString & n, const wxString & v, const char *name);
void AddFrame(struct id3_tag *tp, const wxString & n, const wxString & v, const char *name);
#endif
};
@@ -1848,8 +1848,6 @@ int ExportMP3::AddTags(AudacityProject *project, char **buffer, bool *endOfFile,
#ifdef USE_LIBID3TAG
struct id3_tag *tp = id3_tag_new();
bool v2 = tags->GetID3V2();
wxString n, v;
for (bool cont = tags->GetFirst(n, v); cont; cont = tags->GetNext(n, v)) {
const char *name = "TXXX";
@@ -1866,14 +1864,11 @@ int ExportMP3::AddTags(AudacityProject *project, char **buffer, bool *endOfFile,
else if (n.CmpNoCase(TAG_YEAR) == 0) {
// LLL: Some apps do not like the newer frame ID (ID3_FRAME_YEAR),
// so we add old one as well.
AddFrame(tp, v2, n, v, "TYER");
AddFrame(tp, n, v, "TYER");
name = ID3_FRAME_YEAR;
}
else if (n.CmpNoCase(TAG_GENRE) == 0) {
name = ID3_FRAME_GENRE;
if (!v2) {
v.Printf(wxT("%d"), tags->GetGenre(v));
}
}
else if (n.CmpNoCase(TAG_COMMENTS) == 0) {
name = ID3_FRAME_COMMENT;
@@ -1882,25 +1877,19 @@ int ExportMP3::AddTags(AudacityProject *project, char **buffer, bool *endOfFile,
name = ID3_FRAME_TRACK;
}
AddFrame(tp, v2, n, v, name);
AddFrame(tp, n, v, name);
}
if (v2) {
tp->options &= (~ID3_TAG_OPTION_COMPRESSION); // No compression
tp->options &= (~ID3_TAG_OPTION_COMPRESSION); // No compression
// If this version of libid3tag supports it, use v2.3 ID3
// tags instead of the newer, but less well supported, v2.4
// that libid3tag uses by default.
#ifdef ID3_TAG_HAS_TAG_OPTION_ID3V2_3
tp->options |= ID3_TAG_OPTION_ID3V2_3;
#endif
// If this version of libid3tag supports it, use v2.3 ID3
// tags instead of the newer, but less well supported, v2.4
// that libid3tag uses by default.
#ifdef ID3_TAG_HAS_TAG_OPTION_ID3V2_3
tp->options |= ID3_TAG_OPTION_ID3V2_3;
#endif
*endOfFile = false;
}
else {
tp->options |= ID3_TAG_OPTION_ID3V1;
*endOfFile = true;
}
*endOfFile = false;
id3_length_t len;
@@ -1917,17 +1906,15 @@ int ExportMP3::AddTags(AudacityProject *project, char **buffer, bool *endOfFile,
}
#ifdef USE_LIBID3TAG
void ExportMP3::AddFrame(struct id3_tag *tp, bool v2, const wxString & n, const wxString & v, const char *name)
void ExportMP3::AddFrame(struct id3_tag *tp, const wxString & n, const wxString & v, const char *name)
{
struct id3_frame *frame = id3_frame_new(name);
if (v2) {
if (!n.IsAscii() || !v.IsAscii()) {
id3_field_settextencoding(id3_frame_field(frame, 0), ID3_FIELD_TEXTENCODING_UTF_16);
}
else {
id3_field_settextencoding(id3_frame_field(frame, 0), ID3_FIELD_TEXTENCODING_ISO_8859_1);
}
if (!n.IsAscii() || !v.IsAscii()) {
id3_field_settextencoding(id3_frame_field(frame, 0), ID3_FIELD_TEXTENCODING_UTF_16);
}
else {
id3_field_settextencoding(id3_frame_field(frame, 0), ID3_FIELD_TEXTENCODING_ISO_8859_1);
}
id3_ucs4_t *ucs4 =