annotate src/madplug/tuple.c @ 3161:6dd886b5c72b

revive stdio plugin for now. gio cannot write id3 tags.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Mon, 13 Jul 2009 23:53:41 +0900
parents 3134a0987162
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
1 /*
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
2 * mad plugin for audacious
2201
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
3 * Copyright (C) 2005-2007 William Pitcock, Yoshiki Yazawa, Eugene Zagidullin
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
4 *
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
5 * Portions derived from xmms-mad:
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
6 * Copyright (C) 2001-2002 Sam Clegg - See COPYING
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
7 *
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
10 * the Free Software Foundation; under version 2 of the License.
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
11 *
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
15 * GNU General Public License for more details.
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
16 *
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
2835
f1b6f1b2cdb3 fixed FSF address
Andrew O. Shadoura <bugzilla@tut.by>
parents: 2576
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
20 */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
21
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
22 #include "config.h"
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
23
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
24 #include "plugin.h"
2202
f76e846d53d9 updating TLEN frame returned
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2201
diff changeset
25 #include "tuple.h"
f76e846d53d9 updating TLEN frame returned
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2201
diff changeset
26 #include "input.h"
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
27
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
28 #include <math.h>
2201
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
29 #include <string.h>
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
30
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
31 #include <glib.h>
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
32 #include <glib/gprintf.h>
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
33
2971
3134a0987162 - changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2835
diff changeset
34 #include <audlegacy/plugin.h>
3134a0987162 - changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2835
diff changeset
35 #include <audlegacy/id3tag.h>
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
36
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
37 #include <langinfo.h>
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
38
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
39 static void
2201
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
40 update_id3_frame(struct id3_tag *tag, const char *frame_name, const char *data, int sjis)
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
41 {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
42 int res;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
43 struct id3_frame *frame;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
44 union id3_field *field;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
45 id3_ucs4_t *ucs4;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
46
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
47 if (data == NULL)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
48 return;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
49
2203
13b8ab116b69 removed debugging stuff. some notes added
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2202
diff changeset
50 /* printf ("updating id3: %s: %s\n", frame_name, data);
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
51
2203
13b8ab116b69 removed debugging stuff. some notes added
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2202
diff changeset
52
13b8ab116b69 removed debugging stuff. some notes added
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2202
diff changeset
53 An empty string removes the frame altogether.
13b8ab116b69 removed debugging stuff. some notes added
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2202
diff changeset
54 */
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
55 if (strlen(data) == 0) {
629
ee59ad236eb6 [svn] - revise save tag callback
yaz
parents: 613
diff changeset
56 while ((frame = id3_tag_findframe(tag, frame_name, 0))) {
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2203
diff changeset
57 AUDDBG("madplug: detachframe\n");
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
58 id3_tag_detachframe(tag, frame);
629
ee59ad236eb6 [svn] - revise save tag callback
yaz
parents: 613
diff changeset
59 }
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
60 return;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
61 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
62
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
63 frame = id3_tag_findframe(tag, frame_name, 0);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
64 if (!frame) {
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2203
diff changeset
65 AUDDBG("frame_new\n");
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
66 frame = id3_frame_new(frame_name);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
67 id3_tag_attachframe(tag, frame);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
68 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
69
2203
13b8ab116b69 removed debugging stuff. some notes added
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2202
diff changeset
70 /* setup ucs4 string */
2201
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
71 if(sjis) {
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
72 ucs4 = id3_latin1_ucs4duplicate((id3_latin1_t *) data);
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
73 }
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
74 else {
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
75 ucs4 = id3_utf8_ucs4duplicate((id3_utf8_t *) data);
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
76 }
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
77
2203
13b8ab116b69 removed debugging stuff. some notes added
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2202
diff changeset
78 /* set encoding */
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
79 field = id3_frame_field(frame, 0);
2201
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
80 id3_field_settextencoding(field, sjis ? ID3_FIELD_TEXTENCODING_ISO_8859_1 :
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
81 ID3_FIELD_TEXTENCODING_UTF_8);
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1264
diff changeset
82
2203
13b8ab116b69 removed debugging stuff. some notes added
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2202
diff changeset
83 /* setup genre code */
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
84 if (!strcmp(frame_name, ID3_FRAME_GENRE)) {
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
85 char *tmp;
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
86 int index = id3_genre_number(ucs4);
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
87 g_free(ucs4);
730
74a46ac77c97 [svn] - now fileinfo dialog shows "Unknown" instead of "Blues" if genre name isn't specified.
yaz
parents: 645
diff changeset
88
2203
13b8ab116b69 removed debugging stuff. some notes added
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2202
diff changeset
89 if(index == -1) { /* unknown genre. remove TCON frame. */
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2203
diff changeset
90 AUDDBG("madplug: remove genre frame\n");
730
74a46ac77c97 [svn] - now fileinfo dialog shows "Unknown" instead of "Blues" if genre name isn't specified.
yaz
parents: 645
diff changeset
91 id3_tag_detachframe(tag, frame);
74a46ac77c97 [svn] - now fileinfo dialog shows "Unknown" instead of "Blues" if genre name isn't specified.
yaz
parents: 645
diff changeset
92 }
2203
13b8ab116b69 removed debugging stuff. some notes added
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2202
diff changeset
93 else { /* meaningful genre */
730
74a46ac77c97 [svn] - now fileinfo dialog shows "Unknown" instead of "Blues" if genre name isn't specified.
yaz
parents: 645
diff changeset
94 tmp = g_strdup_printf("%d", index);
74a46ac77c97 [svn] - now fileinfo dialog shows "Unknown" instead of "Blues" if genre name isn't specified.
yaz
parents: 645
diff changeset
95 ucs4 = id3_latin1_ucs4duplicate((unsigned char *) tmp);
74a46ac77c97 [svn] - now fileinfo dialog shows "Unknown" instead of "Blues" if genre name isn't specified.
yaz
parents: 645
diff changeset
96 }
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1264
diff changeset
97
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
98 }
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
99
2203
13b8ab116b69 removed debugging stuff. some notes added
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2202
diff changeset
100 /* write string */
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
101 if (!strcmp(frame_name, ID3_FRAME_COMMENT)) {
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
102 field = id3_frame_field(frame, 3);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
103 field->type = ID3_FIELD_TYPE_STRINGFULL;
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
104 res = id3_field_setfullstring(field, ucs4);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
105 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
106 else {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
107 field = id3_frame_field(frame, 1);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
108 field->type = ID3_FIELD_TYPE_STRINGLIST;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
109 res = id3_field_setstrings(field, 1, &ucs4);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
110 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
111
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
112 if (res != 0)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
113 g_print("error setting id3 field: %s\n", frame_name);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
114 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
115
2201
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
116 static void
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
117 update_id3_frame_from_tuple(struct id3_tag *id3tag, const char *field, Tuple *tuple, int fieldn, int sjis)
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
118 {
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
119 int val;
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
120 char *text, *text2;
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
121 const char *encoding = sjis ? "SJIS" : "UTF-8";
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
122
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
123 if(aud_tuple_get_value_type(tuple, fieldn, NULL) == TUPLE_INT) {
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
124 val = aud_tuple_get_int(tuple, fieldn, NULL);
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
125 if(val > 0) {
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
126 text2 = g_strdup_printf("%d", val);
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2203
diff changeset
127 AUDDBG("madplug: updating field:\"%s\"=\"%s\", enc %s\n", field, text2, encoding);
2201
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
128 update_id3_frame(id3tag, field, text2, 0);
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
129 g_free(text2);
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
130 } else {
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
131 update_id3_frame(id3tag, field, "", 0); /* will be detached */
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
132 }
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
133
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
134 } else if(aud_tuple_get_value_type(tuple, fieldn, NULL) == TUPLE_STRING) {
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
135 text = (char*)aud_tuple_get_string(tuple, fieldn, NULL);
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
136 text2 = g_convert(text, strlen(text), encoding, "UTF-8", NULL, NULL, NULL);
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2203
diff changeset
137 AUDDBG("madplug: updating field:\"%s\"=\"%s\", enc %s\n", field, text2, encoding);
2201
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
138 update_id3_frame(id3tag, field, text2, sjis);
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
139 g_free(text2);
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
140 }
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
141 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
142
2201
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
143 gboolean
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
144 audmad_update_song_tuple(Tuple *tuple, VFSFile *fd)
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
145 {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
146 struct id3_file *id3file;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
147 struct id3_tag *id3tag;
2202
f76e846d53d9 updating TLEN frame returned
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2201
diff changeset
148 gchar *text;
f76e846d53d9 updating TLEN frame returned
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2201
diff changeset
149 struct mad_info_t songinfo;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
150
2201
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
151 if ((id3file = id3_file_vfsopen(fd, ID3_FILE_MODE_READWRITE)) == NULL) return FALSE;
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
152
629
ee59ad236eb6 [svn] - revise save tag callback
yaz
parents: 613
diff changeset
153 id3tag = id3_file_tag(id3file);
ee59ad236eb6 [svn] - revise save tag callback
yaz
parents: 613
diff changeset
154 if (!id3tag) {
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2203
diff changeset
155 AUDDBG("no id3tag\n. append new tag.\n");
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
156 id3tag = id3_tag_new();
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
157 id3_tag_clearframes(id3tag);
629
ee59ad236eb6 [svn] - revise save tag callback
yaz
parents: 613
diff changeset
158 id3tag->options |= ID3_TAG_OPTION_APPENDEDTAG | ID3_TAG_OPTION_ID3V1;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
159 }
629
ee59ad236eb6 [svn] - revise save tag callback
yaz
parents: 613
diff changeset
160
2201
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
161 id3_tag_options(id3tag, ID3_TAG_OPTION_ID3V1, ~0); /* enables id3v1. TODO: make id3v1 optional */
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
162
2341
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
163 update_id3_frame_from_tuple(id3tag, ID3_FRAME_TITLE, tuple, FIELD_TITLE, audmad_config->sjis);
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
164 update_id3_frame_from_tuple(id3tag, ID3_FRAME_ARTIST, tuple, FIELD_ARTIST, audmad_config->sjis);
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
165 update_id3_frame_from_tuple(id3tag, ID3_FRAME_ALBUM, tuple, FIELD_ALBUM, audmad_config->sjis);
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
166 update_id3_frame_from_tuple(id3tag, ID3_FRAME_YEAR, tuple, FIELD_YEAR, audmad_config->sjis);
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
167 update_id3_frame_from_tuple(id3tag, ID3_FRAME_COMMENT, tuple, FIELD_COMMENT, audmad_config->sjis);
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
168 update_id3_frame_from_tuple(id3tag, ID3_FRAME_TRACK, tuple, FIELD_TRACK_NUMBER, audmad_config->sjis);
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
169 update_id3_frame_from_tuple(id3tag, ID3_FRAME_GENRE, tuple, FIELD_GENRE, audmad_config->sjis);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
170
2202
f76e846d53d9 updating TLEN frame returned
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2201
diff changeset
171 if(!id3_tag_findframe(id3tag, "TLEN", 0) && input_init(&songinfo, fd->uri, fd) && !songinfo.remote) {
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2203
diff changeset
172 AUDDBG("update TLEN frame\n");
2202
f76e846d53d9 updating TLEN frame returned
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2201
diff changeset
173 songinfo.fileinfo_request = FALSE; /* we don't need to read tuple again */
f76e846d53d9 updating TLEN frame returned
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2201
diff changeset
174 input_get_info(&songinfo, FALSE);
f76e846d53d9 updating TLEN frame returned
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2201
diff changeset
175 text = g_strdup_printf("%ld", mad_timer_count(songinfo.duration, MAD_UNITS_MILLISECONDS));
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2203
diff changeset
176 AUDDBG("TLEN: \"%s\"\n", text);
2202
f76e846d53d9 updating TLEN frame returned
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2201
diff changeset
177 update_id3_frame(id3tag, "TLEN", text, 0);
f76e846d53d9 updating TLEN frame returned
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2201
diff changeset
178 g_free(text);
f76e846d53d9 updating TLEN frame returned
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2201
diff changeset
179 input_term(&songinfo);
f76e846d53d9 updating TLEN frame returned
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2201
diff changeset
180 }
f76e846d53d9 updating TLEN frame returned
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2201
diff changeset
181
2201
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
182 if (id3_file_update(id3file) != 0) return FALSE;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
183
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
184 id3_file_close(id3file);
2201
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
185 return TRUE;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
186 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
187