Mercurial > audlegacy-plugins
annotate src/tta/libtta.c @ 1653:c98e16576bfb
fixed TrueAudio plugin
author | mf0102 <0102@gmx.at> |
---|---|
date | Fri, 07 Sep 2007 14:32:49 +0200 |
parents | 3f4a74858aa0 |
children | aee4ebea943a 62e89e392227 |
rev | line source |
---|---|
290 | 1 /* |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
2 * libtta.c |
290 | 3 * |
4 * Description: TTA input plug-in for Audacious | |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
5 * Developed by: Alexander Djourik <ald@true-audio.com> |
290 | 6 * Audacious port: Yoshiki Yazawa <yaz@cc.rim.or.jp> |
7 * | |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
8 * Copyright (c) 2007 Alexander Djourik. All rights reserved. |
290 | 9 * |
10 */ | |
11 | |
12 /* | |
13 * This library is free software; you can redistribute it and/or | |
14 * modify it under the terms of the GNU Lesser General Public | |
15 * License as published by the Free Software Foundation; either | |
16 * version 2.1 of the License, or (at your option) any later version. | |
17 * | |
18 * This library is distributed in the hope that it will be useful, | |
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
21 * Lesser General Public License for more details. | |
22 * | |
23 * You should have received a copy of the GNU Lesser General Public | |
24 * License along with this library; if not, write to the Free Software | |
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
26 * | |
27 * Please see the file COPYING in this directory for full copyright | |
28 * information. | |
29 */ | |
528 | 30 |
31 #ifdef HAVE_CONFIG_H | |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
32 #include "config.h" |
528 | 33 #endif |
34 | |
290 | 35 #include <stdio.h> |
36 #include <stdlib.h> | |
37 #include <string.h> | |
38 #include <time.h> | |
39 #include <sys/types.h> | |
40 #include <sys/stat.h> | |
41 #include <glib.h> | |
42 #include <string.h> | |
43 | |
44 #include <audacious/util.h> | |
45 #include <audacious/plugin.h> | |
1440
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
46 #include <audacious/main.h> |
290 | 47 #include <audacious/vfs.h> |
520
8f1785471613
[svn] - add missing inclusion of audacious/strings.h where necessary
giacomo
parents:
443
diff
changeset
|
48 #include <audacious/output.h> |
8f1785471613
[svn] - add missing inclusion of audacious/strings.h where necessary
giacomo
parents:
443
diff
changeset
|
49 #include <audacious/strings.h> |
527
d124034ebea3
[svn] - glib/gi18n.h -> audacious/i18n.h for automatic dgettext support
nenolod
parents:
520
diff
changeset
|
50 #include <audacious/i18n.h> |
290 | 51 |
661 | 52 #include <audacious/id3tag.h> |
290 | 53 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
54 #define PLUGIN_VERSION "1.4" |
290 | 55 #define PROJECT_URL "<http://www.true-audio.com>" |
56 | |
57 #include "ttalib.h" | |
58 | |
59 #define OUTPUT_ERROR (MEMORY_ERROR+1) | |
60 #define MAX_BSIZE (MAX_BPS>>3) | |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
61 #define BYTES(x) ((x) * sizeof(id3_ucs4_t)) |
290 | 62 |
63 static void init (); | |
64 static void cleanup (); | |
65 static int is_our_file (char *filename); | |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
528
diff
changeset
|
66 static void play_file (InputPlayback *playback); |
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
528
diff
changeset
|
67 static void tta_pause (InputPlayback *playback, short paused); |
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
528
diff
changeset
|
68 static void stop (InputPlayback *playback); |
1366
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
69 static void mseek (InputPlayback *playback, gulong millisec); |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
70 static void seek (InputPlayback *playback, int sec); |
290 | 71 static void get_song_info (char *filename, char **title, int *length); |
72 static void file_info (char *filename); | |
73 static void about (); | |
1440
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
74 static Tuple *get_song_tuple(char *filename); |
1507
3f4a74858aa0
- make use of tuple_formatter_make_title_string().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1473
diff
changeset
|
75 //static gchar *extname(const char *filename); |
851 | 76 |
1366
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
77 static GThread *decode_thread = NULL; |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
78 static char sample_buffer[PCM_BUFFER_LENGTH * MAX_BSIZE * MAX_NCH]; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
79 static tta_info info; // currently playing file info |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
80 static int seek_position = -1; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
81 static int read_samples = -1; |
290 | 82 |
372
a157306caf03
[svn] - finalize the plugin-side of the extension-assist ABI
nenolod
parents:
368
diff
changeset
|
83 gchar *tta_fmts[] = { "tta", NULL }; |
a157306caf03
[svn] - finalize the plugin-side of the extension-assist ABI
nenolod
parents:
368
diff
changeset
|
84 |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
85 InputPlugin tta_ip = |
290 | 86 { |
1653 | 87 .description = "True Audio Plugin", |
88 .init = init, | |
89 .about = about, | |
90 .is_our_file = is_our_file, | |
91 .play_file = play_file, | |
92 .stop = stop, | |
93 .pause = tta_pause, | |
94 .seek = seek, | |
95 .cleanup = cleanup, | |
96 .get_song_info = get_song_info, | |
97 .file_info_box = file_info, | |
98 .get_song_tuple = get_song_tuple, | |
99 .vfs_extensions = tta_fmts, | |
100 .mseek = mseek, | |
290 | 101 }; |
102 | |
1087 | 103 InputPlugin *tta_iplist[] = { &tta_ip, NULL }; |
104 | |
1395
761e17b23e0c
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
1366
diff
changeset
|
105 DECLARE_PLUGIN(tta, NULL, NULL, tta_iplist, NULL, NULL, NULL, NULL, NULL); |
290 | 106 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
107 size_t |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
108 file_size (char *filename) |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
109 { |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
110 VFSFile *f; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
111 size_t size = -1; |
290 | 112 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
113 if ((f = vfs_fopen (filename, "r"))) |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
114 { |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
115 vfs_fseek (f, 0, SEEK_END); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
116 size = vfs_ftell (f); |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
117 vfs_fclose (f); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
118 } |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
119 return size; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
120 } |
851 | 121 |
290 | 122 static void |
123 tta_error (int error) | |
124 { | |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
125 char *message; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
126 static GtkWidget *errorbox; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
127 if (errorbox != NULL) return; |
290 | 128 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
129 switch (error) |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
130 { |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
131 case OPEN_ERROR: |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
132 message = _("Can't open file\n"); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
133 break; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
134 case FORMAT_ERROR: |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
135 message = _("Not supported file format\n"); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
136 break; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
137 case FILE_ERROR: |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
138 message = _("File is corrupted\n"); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
139 break; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
140 case READ_ERROR: |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
141 message = _("Can't read from file\n"); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
142 break; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
143 case MEMORY_ERROR: |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
144 message = _("Insufficient memory available\n"); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
145 break; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
146 case OUTPUT_ERROR: |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
147 message = _("Output plugin error\n"); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
148 break; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
149 default: |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
150 message = _("Unknown error\n"); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
151 break; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
152 } |
290 | 153 |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
154 xmms_show_message (_("TTA Decoder Error"), message, |
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
155 _("Ok"), FALSE, NULL, NULL); |
290 | 156 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
157 gtk_signal_connect(GTK_OBJECT(errorbox), "destroy", |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
158 G_CALLBACK(gtk_widget_destroyed), &errorbox); |
290 | 159 } |
160 | |
161 static gchar * | |
1440
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
162 get_song_title(Tuple *tuple) |
290 | 163 { |
1507
3f4a74858aa0
- make use of tuple_formatter_make_title_string().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1473
diff
changeset
|
164 return tuple_formatter_make_title_string(tuple, get_gentitle_format()); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
165 } |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
166 |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
167 static void |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
168 get_song_info (char *filename, char **title, int *length) |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
169 { |
1440
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
170 Tuple *tuple; |
290 | 171 |
1165 | 172 *length = -1; |
173 *title = NULL; | |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
174 |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
175 if ((tuple = get_song_tuple(filename)) != NULL) { |
1440
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
176 *length = tuple_get_int(tuple, "length"); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
177 *title = get_song_title(tuple); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
178 } |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
179 |
1465
db616ccdd40c
use tuple_free(x) in place of mowgli_object_unref(x)
Giacomo Lozito <james@develia.org>
parents:
1447
diff
changeset
|
180 tuple_free(tuple); |
290 | 181 } |
182 | |
183 static void * | |
1366
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
184 play_loop (InputPlayback *playback) |
290 | 185 { |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
186 int bufsize = PCM_BUFFER_LENGTH * info.BSIZE * info.NCH; |
290 | 187 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
188 //////////////////////////////////////// |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
189 // decode PCM_BUFFER_LENGTH samples |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
190 // into the current PCM buffer position |
290 | 191 |
1366
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
192 while (playback->playing) |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
193 { |
1190
ed2d7787779e
more warning elimination.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1166
diff
changeset
|
194 while ((read_samples = get_samples ((unsigned char *)sample_buffer)) > 0) |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
195 { |
851 | 196 |
1366
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
197 while ((playback->output->buffer_free () < bufsize) |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
198 && seek_position == -1) |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
199 { |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
200 if (!playback->playing) |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
201 goto DONE; |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
202 xmms_usleep (10000); |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
203 } |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
204 if (seek_position == -1) |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
205 { |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
206 produce_audio(playback->output->written_time(), |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
207 ((info.BPS == 8) ? FMT_U8 : FMT_S16_LE), |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
208 info.NCH, |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
209 read_samples * info.NCH * info.BSIZE, |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
210 sample_buffer, |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
211 &playback->playing); |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
212 } |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
213 else |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
214 { |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
215 set_position (seek_position); |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
216 playback->output->flush (seek_position * SEEK_STEP); |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
217 seek_position = -1; |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
218 } |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
219 if(!playback->playing) |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
220 goto DONE; |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
221 } |
851 | 222 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
223 playback->output->buffer_free (); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
224 playback->output->buffer_free (); |
1270
d73eed18f3f4
make tta decode easy to be interrupted.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1237
diff
changeset
|
225 while (playback->output->buffer_playing()) { |
d73eed18f3f4
make tta decode easy to be interrupted.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1237
diff
changeset
|
226 xmms_usleep(10000); |
1366
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
227 if(!playback->playing) |
1270
d73eed18f3f4
make tta decode easy to be interrupted.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1237
diff
changeset
|
228 goto DONE; |
d73eed18f3f4
make tta decode easy to be interrupted.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1237
diff
changeset
|
229 } |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
230 } |
290 | 231 |
851 | 232 DONE: |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
233 //////////////////////// |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
234 // destroy memory pools |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
235 player_stop (); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
236 |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
237 /////////////////////////////// |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
238 // close currently playing file |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
239 close_tta_file (&info); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
240 |
1366
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
241 return NULL; |
290 | 242 } |
243 | |
244 static void | |
245 init () | |
246 { | |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
247 memset (&info, 0, sizeof (tta_info)); |
290 | 248 } |
249 | |
250 static void | |
251 cleanup () | |
252 { | |
253 } | |
254 | |
255 static void | |
256 about () | |
257 { | |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
258 static GtkWidget *aboutbox; |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
259 gchar *about_text; |
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
260 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
261 if (aboutbox != NULL) return; |
290 | 262 |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
263 about_text = g_strjoin("", _("TTA input plugin "), PLUGIN_VERSION, |
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
264 _(" for BMP\n" |
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
265 "Copyright (c) 2004 True Audio Software\n"), PROJECT_URL, NULL); |
290 | 266 |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
267 aboutbox = xmms_show_message(_("About True Audio Plugin"), |
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
268 about_text, |
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
269 _("Ok"), FALSE, NULL, NULL); |
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
270 |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1321
diff
changeset
|
271 gtk_signal_connect(GTK_OBJECT(aboutbox), "destroy", |
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1321
diff
changeset
|
272 G_CALLBACK(gtk_widget_destroyed), &aboutbox); |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
273 g_free(about_text); |
290 | 274 } |
275 | |
276 static GtkWidget *window = NULL; | |
277 static GtkWidget *filename_entry, *title_entry, | |
278 *artist_entry, *album_entry, | |
279 *year_entry, *tracknum_entry, | |
280 *comment_entry, *genre_entry, | |
281 *info_frame; | |
282 | |
283 static void | |
284 file_info (char *filename) | |
285 { | |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
286 tta_info ttainfo; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
287 char *title; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
288 gchar *utf_filename = NULL; |
1296
2a6865d42dc4
more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1270
diff
changeset
|
289 gchar *realfn = NULL; |
290 | 290 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
291 if (!window) { |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
292 GtkWidget *vbox, *hbox, *left_vbox, *table; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
293 GtkWidget *label, *filename_hbox, *button_ok; |
290 | 294 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
295 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
296 gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
297 gtk_signal_connect(GTK_OBJECT(window), "destroy", |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
298 G_CALLBACK(gtk_widget_destroyed), &window); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
299 gtk_container_set_border_width(GTK_CONTAINER(window), 10); |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
300 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
301 vbox = gtk_vbox_new(FALSE, 10); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
302 gtk_container_add(GTK_CONTAINER(window), vbox); |
290 | 303 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
304 filename_hbox = gtk_hbox_new(FALSE, 5); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
305 gtk_box_pack_start(GTK_BOX(vbox), filename_hbox, FALSE, TRUE, 0); |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
306 label = gtk_label_new(_("Filename:")); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
307 gtk_box_pack_start(GTK_BOX(filename_hbox), label, FALSE, TRUE, 0); |
290 | 308 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
309 filename_entry = gtk_entry_new_with_max_length(1024); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
310 gtk_editable_set_editable(GTK_EDITABLE(filename_entry), FALSE); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
311 gtk_box_pack_start(GTK_BOX(filename_hbox), filename_entry, TRUE, TRUE, 0); |
290 | 312 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
313 hbox = gtk_hbox_new(FALSE, 10); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
314 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
315 left_vbox = gtk_vbox_new(FALSE, 10); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
316 gtk_box_pack_start(GTK_BOX(hbox), left_vbox, FALSE, FALSE, 0); |
290 | 317 |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
318 info_frame = gtk_frame_new(_("ID3 Tag:")); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
319 gtk_box_pack_start(GTK_BOX(left_vbox), info_frame, FALSE, FALSE, 0); |
290 | 320 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
321 table = gtk_table_new(5, 5, FALSE); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
322 gtk_container_set_border_width(GTK_CONTAINER(table), 5); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
323 gtk_container_add(GTK_CONTAINER(info_frame), table); |
290 | 324 |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
325 label = gtk_label_new(_("Title:")); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
326 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
327 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 5, 5); |
290 | 328 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
329 title_entry = gtk_entry_new_with_max_length(1024); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
330 gtk_editable_set_editable(GTK_EDITABLE(title_entry), FALSE); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
331 gtk_table_attach(GTK_TABLE(table), title_entry, 1, 4, 0, 1, |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
332 GTK_FILL | GTK_EXPAND | GTK_SHRINK, |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
333 GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); |
290 | 334 |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
335 label = gtk_label_new(_("Artist:")); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
336 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
337 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
338 GTK_FILL, GTK_FILL, 5, 5); |
290 | 339 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
340 artist_entry = gtk_entry_new_with_max_length(1024); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
341 gtk_editable_set_editable(GTK_EDITABLE(artist_entry), FALSE); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
342 gtk_table_attach(GTK_TABLE(table), artist_entry, 1, 4, 1, 2, |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
343 GTK_FILL | GTK_EXPAND | GTK_SHRINK, |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
344 GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); |
290 | 345 |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
346 label = gtk_label_new(_("Album:")); |
290 | 347 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
348 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, | |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
349 GTK_FILL, GTK_FILL, 5, 5); |
290 | 350 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
351 album_entry = gtk_entry_new_with_max_length(1024); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
352 gtk_editable_set_editable(GTK_EDITABLE(album_entry), FALSE); |
290 | 353 gtk_table_attach(GTK_TABLE(table), album_entry, 1, 4, 2, 3, |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
354 GTK_FILL | GTK_EXPAND | GTK_SHRINK, |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
355 GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); |
290 | 356 |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
357 label = gtk_label_new(_("Comment:")); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
358 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
359 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
360 GTK_FILL, GTK_FILL, 5, 5); |
290 | 361 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
362 comment_entry = gtk_entry_new_with_max_length(1024); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
363 gtk_editable_set_editable(GTK_EDITABLE(comment_entry), FALSE); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
364 gtk_table_attach(GTK_TABLE(table), comment_entry, 1, 4, 3, 4, |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
365 GTK_FILL | GTK_EXPAND | GTK_SHRINK, |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
366 GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); |
290 | 367 |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
368 label = gtk_label_new(_("Year:")); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
369 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
370 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5, |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
371 GTK_FILL, GTK_FILL, 5, 5); |
290 | 372 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
373 year_entry = gtk_entry_new_with_max_length(4); |
290 | 374 gtk_editable_set_editable(GTK_EDITABLE(year_entry), FALSE); |
375 gtk_widget_set_usize(year_entry, 40, -1); | |
376 gtk_table_attach(GTK_TABLE(table), year_entry, 1, 2, 4, 5, | |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
377 GTK_FILL | GTK_EXPAND | GTK_SHRINK, |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
378 GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); |
290 | 379 |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
380 label = gtk_label_new(_("Track number:")); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
381 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
382 gtk_table_attach(GTK_TABLE(table), label, 2, 3, 4, 5, |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
383 GTK_FILL, GTK_FILL, 5, 5); |
290 | 384 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
385 tracknum_entry = gtk_entry_new_with_max_length(3); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
386 gtk_editable_set_editable(GTK_EDITABLE(tracknum_entry), FALSE); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
387 gtk_widget_set_usize(tracknum_entry, 40, -1); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
388 gtk_table_attach(GTK_TABLE(table), tracknum_entry, 3, 4, 4, 5, |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
389 GTK_FILL | GTK_EXPAND | GTK_SHRINK, |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
390 GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); |
290 | 391 |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
392 label = gtk_label_new(_("Genre:")); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
393 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
394 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 5, 6, |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
395 GTK_FILL, GTK_FILL, 5, 5); |
290 | 396 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
397 genre_entry = gtk_entry_new_with_max_length(1024); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
398 gtk_editable_set_editable(GTK_EDITABLE(genre_entry), FALSE); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
399 gtk_widget_set_usize(genre_entry, 40, -1); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
400 gtk_table_attach(GTK_TABLE(table), genre_entry, 1, 4, 5, 6, |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
401 GTK_FILL | GTK_EXPAND | GTK_SHRINK, |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
402 GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); |
290 | 403 |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
404 button_ok = gtk_button_new_with_label(_("Ok")); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
405 gtk_signal_connect_object(GTK_OBJECT(button_ok), "clicked", |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
406 G_CALLBACK(gtk_widget_destroy), G_OBJECT(window)); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
407 GTK_WIDGET_SET_FLAGS(button_ok, GTK_CAN_DEFAULT); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
408 gtk_box_pack_start(GTK_BOX(vbox), button_ok, TRUE, TRUE, 0); |
290 | 409 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
410 gtk_widget_show_all (window); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
411 } |
1296
2a6865d42dc4
more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1270
diff
changeset
|
412 realfn = g_filename_from_uri(filename, NULL, NULL); |
2a6865d42dc4
more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1270
diff
changeset
|
413 utf_filename = str_to_utf8(realfn ? realfn : filename); |
2a6865d42dc4
more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1270
diff
changeset
|
414 g_free(realfn); realfn = NULL; |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
415 title = g_strdup_printf(_("File Info - %s"), g_basename(utf_filename)); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
416 gtk_window_set_title(GTK_WINDOW(window), title); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
417 g_free(title); |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
418 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
419 gtk_entry_set_text(GTK_ENTRY(filename_entry), utf_filename); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
420 gtk_editable_set_position(GTK_EDITABLE(filename_entry), -1); |
290 | 421 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
422 title = g_strdup(g_basename(utf_filename)); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
423 gtk_entry_set_text(GTK_ENTRY(title_entry), title); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
424 |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
425 g_free(title); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
426 g_free(utf_filename); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
427 |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
428 if (open_tta_file (filename, &ttainfo, 0) >= 0) |
290 | 429 { |
1190
ed2d7787779e
more warning elimination.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1166
diff
changeset
|
430 gtk_entry_set_text(GTK_ENTRY(title_entry), (gchar *)ttainfo.ID3.title); |
ed2d7787779e
more warning elimination.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1166
diff
changeset
|
431 gtk_entry_set_text(GTK_ENTRY(artist_entry), (gchar *)ttainfo.ID3.artist); |
ed2d7787779e
more warning elimination.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1166
diff
changeset
|
432 gtk_entry_set_text(GTK_ENTRY(album_entry), (gchar *)ttainfo.ID3.album); |
ed2d7787779e
more warning elimination.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1166
diff
changeset
|
433 gtk_entry_set_text(GTK_ENTRY(year_entry), (gchar *)ttainfo.ID3.year); |
ed2d7787779e
more warning elimination.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1166
diff
changeset
|
434 gtk_entry_set_text(GTK_ENTRY(tracknum_entry), (gchar *)ttainfo.ID3.track); |
ed2d7787779e
more warning elimination.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1166
diff
changeset
|
435 gtk_entry_set_text(GTK_ENTRY(comment_entry), (gchar *)ttainfo.ID3.comment); |
ed2d7787779e
more warning elimination.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1166
diff
changeset
|
436 gtk_entry_set_text(GTK_ENTRY(genre_entry), (gchar *)ttainfo.ID3.genre); |
290 | 437 } |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
438 close_tta_file (&ttainfo); |
290 | 439 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
440 gtk_widget_set_sensitive(info_frame, TRUE); |
290 | 441 } |
442 | |
443 static int | |
444 is_our_file (char *filename) | |
445 { | |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
446 gchar *ext = strrchr(filename, '.'); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
447 |
1152
949457464b28
[svn] - fix for crash when file extension is not available.
yaz
parents:
1087
diff
changeset
|
448 if (ext && !strncasecmp(ext, ".tta", 4)) |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
449 return TRUE; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
450 |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
451 return FALSE; |
290 | 452 } |
453 | |
454 static void | |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
528
diff
changeset
|
455 play_file (InputPlayback *playback) |
290 | 456 { |
1237
0d5b0f861bf0
- quick fix for link breakage to libaudid3tag.so when --prefix is specified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1190
diff
changeset
|
457 gchar *filename = playback->filename; |
1296
2a6865d42dc4
more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1270
diff
changeset
|
458 char *title = NULL; |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
459 int datasize, origsize, bitrate; |
1440
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
460 Tuple *tuple = NULL; |
290 | 461 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
462 //////////////////////////////////////// |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
463 // open TTA file |
1237
0d5b0f861bf0
- quick fix for link breakage to libaudid3tag.so when --prefix is specified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1190
diff
changeset
|
464 if (open_tta_file (filename, &info, 0) > 0) |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
465 { |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
466 tta_error (info.STATE); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
467 close_tta_file (&info); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
468 return; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
469 } |
290 | 470 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
471 //////////////////////////////////////// |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
472 // initialize TTA player |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
473 if (player_init (&info) < 0) |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
474 { |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
475 tta_error (info.STATE); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
476 close_tta_file (&info); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
477 return; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
478 } |
290 | 479 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
480 if (playback->output->open_audio ((info.BPS == 8) ? FMT_U8 : FMT_S16_LE, |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
481 info.SAMPLERATE, info.NCH) == 0) |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
482 { |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
483 tta_error (OUTPUT_ERROR); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
484 close_tta_file (&info); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
485 return; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
486 } |
290 | 487 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
488 tuple = get_song_tuple(filename); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
489 title = get_song_title(tuple); |
1465
db616ccdd40c
use tuple_free(x) in place of mowgli_object_unref(x)
Giacomo Lozito <james@develia.org>
parents:
1447
diff
changeset
|
490 tuple_free(tuple); |
290 | 491 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
492 datasize = file_size(filename) - info.DATAPOS; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
493 origsize = info.DATALENGTH * info.BSIZE * info.NCH; |
290 | 494 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
495 bitrate = (int) ((float) datasize / origsize * |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
496 (info.SAMPLERATE * info.NCH * info.BPS)); |
290 | 497 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
498 tta_ip.set_info (title, 1000 * info.LENGTH, bitrate, info.SAMPLERATE, info.NCH); |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
499 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
500 if (title) |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
501 g_free (title); |
290 | 502 |
1165 | 503 playback->playing = 1; |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
504 seek_position = -1; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
505 read_samples = -1; |
290 | 506 |
1366
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
507 decode_thread = g_thread_self(); |
1447
195b5657303e
updated input plugins to use set_pb_ready to signal to the core that they're ready for playback
Giacomo Lozito <james@develia.org>
parents:
1440
diff
changeset
|
508 playback->set_pb_ready(playback); |
1366
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
509 play_loop(playback); |
290 | 510 } |
511 | |
512 static void | |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
528
diff
changeset
|
513 tta_pause (InputPlayback *playback, short paused) |
290 | 514 { |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
515 playback->output->pause (paused); |
290 | 516 } |
851 | 517 |
290 | 518 static void |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
528
diff
changeset
|
519 stop (InputPlayback *playback) |
290 | 520 { |
1366
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
521 if (playback->playing) |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
522 { |
1165 | 523 playback->playing = 0; |
1366
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
524 g_thread_join(decode_thread); |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
525 decode_thread = NULL; |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
526 playback->output->close_audio (); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
527 close_tta_file (&info); |
1366
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
528 read_samples = -1; |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
529 } |
290 | 530 } |
531 | |
532 static void | |
1366
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
533 mseek (InputPlayback *data, gulong millisec) |
290 | 534 { |
1366
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
535 if (data->playing) |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
536 { |
1366
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
537 seek_position = (int)(millisec / SEEK_STEP); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
538 |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
539 while (seek_position != -1) |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
540 xmms_usleep (10000); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
541 } |
290 | 542 } |
543 | |
1366
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
544 static void |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
545 seek (InputPlayback *data, int sec) |
290 | 546 { |
1366
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
547 gulong millisec = 1000 * sec; |
4c43c38bd033
- adapt tta for new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1325
diff
changeset
|
548 mseek(data, millisec); |
290 | 549 } |
550 | |
1440
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
551 static Tuple * |
290 | 552 get_song_tuple(char *filename) |
553 { | |
1440
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
554 Tuple *tuple = NULL; |
290 | 555 tta_info *ttainfo; |
556 VFSFile *file; | |
557 | |
558 ttainfo = g_malloc0(sizeof(tta_info)); | |
559 | |
560 if((file = vfs_fopen(filename, "rb")) != NULL) { | |
561 if(open_tta_file(filename, ttainfo, 0) >= 0) { | |
1440
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
562 tuple = tuple_new_from_filename(filename); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
563 |
1440
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
564 tuple_associate_string(tuple, "codec", "True Audio (TTA)"); |
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
565 tuple_associate_string(tuple, "quality", "lossless"); |
290 | 566 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
567 if (ttainfo->ID3.id3has) { |
1440
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
568 if (ttainfo->ID3.artist) |
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
569 tuple_associate_string(tuple, "artist", (gchar *) ttainfo->ID3.artist); |
1166 | 570 |
1440
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
571 if (ttainfo->ID3.album) |
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
572 tuple_associate_string(tuple, "album", (gchar *) ttainfo->ID3.album); |
1166 | 573 |
1440
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
574 if (ttainfo->ID3.title) |
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
575 tuple_associate_string(tuple, "title", (gchar *) ttainfo->ID3.title); |
1166 | 576 |
1440
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
577 if (ttainfo->ID3.year) |
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
578 tuple_associate_int(tuple, "year", atoi((char *)ttainfo->ID3.year)); |
1166 | 579 |
1440
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
580 if(ttainfo->ID3.track) |
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
581 tuple_associate_int(tuple, "track-number", atoi((char *)ttainfo->ID3.track)); |
1166 | 582 |
1440
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
583 if(ttainfo->ID3.genre) |
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
584 tuple_associate_string(tuple, "genre", (gchar *) ttainfo->ID3.genre); |
1166 | 585 |
1440
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
586 if(ttainfo->ID3.comment) |
90af998f55fa
tta: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
587 tuple_associate_string(tuple, "comment", (gchar *) ttainfo->ID3.comment); |
290 | 588 } |
589 close_tta_file (ttainfo); | |
590 } | |
591 vfs_fclose(file); | |
592 } | |
593 return tuple; | |
594 } | |
595 | |
1507
3f4a74858aa0
- make use of tuple_formatter_make_title_string().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1473
diff
changeset
|
596 #if 0 |
290 | 597 static gchar * |
598 extname(const char *filename) | |
599 { | |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
600 gchar *ext = strrchr(filename, '.'); |
290 | 601 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
602 if (ext != NULL) |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
603 ++ext; |
290 | 604 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
605 return ext; |
290 | 606 } |
1507
3f4a74858aa0
- make use of tuple_formatter_make_title_string().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1473
diff
changeset
|
607 #endif |
290 | 608 |
609 /* return length in letters */ | |
610 size_t tta_ucs4len(id3_ucs4_t *ucs) | |
611 { | |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
612 id3_ucs4_t *ptr = ucs; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
613 size_t len = 0; |
290 | 614 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
615 while(*ptr++ != 0) |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
616 len++; |
290 | 617 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
618 return len; |
290 | 619 } |
620 | |
621 /* duplicate id3_ucs4_t string. new string will be terminated with 0. */ | |
622 id3_ucs4_t *tta_ucs4dup(id3_ucs4_t *org) | |
623 { | |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
624 id3_ucs4_t *new = NULL; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
625 size_t len = tta_ucs4len(org); |
290 | 626 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
627 new = g_malloc0((len + 1) * sizeof(id3_ucs4_t)); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
628 memcpy(new, org, len * sizeof(id3_ucs4_t)); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
629 *(new + len) = 0; //terminate |
290 | 630 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
631 return new; |
290 | 632 } |
633 | |
634 id3_ucs4_t *tta_parse_genre(const id3_ucs4_t *string) | |
635 { | |
636 id3_ucs4_t *ret = NULL; | |
637 id3_ucs4_t *tmp = NULL; | |
638 id3_ucs4_t *genre = NULL; | |
639 id3_ucs4_t *ptr, *end, *tail, *tp; | |
640 size_t ret_len = 0; //num of ucs4 char! | |
641 size_t tmp_len = 0; | |
642 gboolean is_num = TRUE; | |
643 | |
644 tail = (id3_ucs4_t *)string + tta_ucs4len((id3_ucs4_t *)string); | |
645 | |
646 ret = g_malloc0(1024); | |
647 | |
648 for(ptr = (id3_ucs4_t *)string; *ptr != 0 && ptr <= tail; ptr++) { | |
649 if(*ptr == '(') { | |
650 if(*(++ptr) == '(') { // escaped text like: ((something) | |
651 for(end = ptr; *end != ')' && *end != 0;) { // copy "(something)" | |
652 end++; | |
653 } | |
654 end++; //include trailing ')' | |
655 memcpy(ret, ptr, BYTES(end - ptr)); | |
656 ret_len += (end - ptr); | |
657 *(ret + ret_len) = 0; //terminate | |
658 ptr = end + 1; | |
659 } | |
660 else { | |
661 // reference to an id3v1 genre code | |
662 for(end = ptr; *end != ')' && *end != 0;) { | |
663 end++; | |
664 } | |
665 | |
666 tmp = g_malloc0(BYTES(end - ptr + 1)); | |
667 memcpy(tmp, ptr, BYTES(end - ptr)); | |
668 *(tmp + (end - ptr)) = 0; //terminate | |
669 ptr += end - ptr; | |
670 | |
671 genre = (id3_ucs4_t *)id3_genre_name((const id3_ucs4_t *)tmp); | |
672 | |
673 g_free(tmp); | |
674 tmp = NULL; | |
675 | |
676 tmp_len = tta_ucs4len(genre); | |
677 | |
678 memcpy(ret + BYTES(ret_len), genre, BYTES(tmp_len)); | |
679 | |
680 ret_len += tmp_len; | |
681 *(ret + ret_len) = 0; //terminate | |
682 } | |
683 } | |
684 else { | |
685 for(end = ptr; *end != '(' && *end != 0; ) { | |
686 end++; | |
687 } | |
688 // scan string to determine whether a genre code number or not | |
689 tp = ptr; | |
690 is_num = TRUE; | |
691 while(tp < end) { | |
692 if(*tp < '0' || *tp > '9') { // anything else than number appears. | |
693 is_num = FALSE; | |
694 break; | |
695 } | |
696 tp++; | |
697 } | |
698 if(is_num) { | |
699 #ifdef DEBUG | |
700 printf("is_num!\n"); | |
701 #endif | |
702 tmp = g_malloc0(BYTES(end - ptr + 1)); | |
703 memcpy(tmp, ptr, BYTES(end - ptr)); | |
704 *(tmp + (end - ptr)) = 0; //terminate | |
705 ptr += end - ptr; | |
706 | |
707 genre = (id3_ucs4_t *)id3_genre_name((const id3_ucs4_t *)tmp); | |
708 #ifdef DEBUG | |
709 printf("genre length = %d\n", tta_ucs4len(genre)); | |
710 #endif | |
711 g_free(tmp); | |
712 tmp = NULL; | |
713 | |
714 tmp_len = tta_ucs4len(genre); | |
715 | |
716 memcpy(ret + BYTES(ret_len), genre, BYTES(tmp_len)); | |
717 | |
718 ret_len += tmp_len; | |
719 *(ret + ret_len) = 0; //terminate | |
720 } | |
721 else { // plain text | |
722 #ifdef DEBUG | |
723 printf("plain!\n"); | |
724 printf("ret_len = %d\n", ret_len); | |
725 #endif | |
726 memcpy(ret + BYTES(ret_len), ptr, BYTES(end - ptr)); | |
727 ret_len = ret_len + (end - ptr); | |
728 *(ret + ret_len) = 0; //terminate | |
729 ptr += (end - ptr); | |
730 } | |
731 } | |
732 } | |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
733 |
290 | 734 return ret; |
735 } | |
736 | |
737 gchar *tta_input_id3_get_string(struct id3_tag * tag, char *frame_name) | |
738 { | |
739 gchar *rtn; | |
740 gchar *rtn2; | |
741 const id3_ucs4_t *string_const; | |
742 id3_ucs4_t *string; | |
743 id3_ucs4_t *ucsptr; | |
744 struct id3_frame *frame; | |
745 union id3_field *field; | |
746 gboolean flagutf = FALSE; | |
747 | |
748 frame = id3_tag_findframe(tag, frame_name, 0); | |
749 if (!frame) | |
750 return NULL; | |
751 | |
1190
ed2d7787779e
more warning elimination.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1166
diff
changeset
|
752 if (!strcmp(frame_name, ID3_FRAME_COMMENT)) |
290 | 753 field = id3_frame_field(frame, 3); |
754 else | |
755 field = id3_frame_field(frame, 1); | |
756 | |
757 if (!field) | |
758 return NULL; | |
759 | |
1190
ed2d7787779e
more warning elimination.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1166
diff
changeset
|
760 if (!strcmp(frame_name, ID3_FRAME_COMMENT)) |
290 | 761 string_const = id3_field_getfullstring(field); |
762 else | |
763 string_const = id3_field_getstrings(field, 0); | |
764 | |
765 if (!string_const) | |
766 return NULL; | |
767 | |
768 string = tta_ucs4dup((id3_ucs4_t *)string_const); | |
769 | |
1190
ed2d7787779e
more warning elimination.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1166
diff
changeset
|
770 if (!strcmp(frame_name, ID3_FRAME_GENRE)) { |
290 | 771 id3_ucs4_t *string2 = NULL; |
772 string2 = tta_parse_genre(string); | |
773 g_free((void *)string); | |
774 string = string2; | |
775 } | |
776 | |
777 ucsptr = (id3_ucs4_t *)string; | |
778 while (*ucsptr) { | |
779 if (*ucsptr > 0x000000ffL) { | |
780 flagutf = TRUE; | |
781 break; | |
782 } | |
783 ucsptr++; | |
784 } | |
785 | |
786 if (flagutf) { | |
787 #ifdef DEBUG | |
788 g_message("aud-tta: flagutf!\n"); | |
789 #endif | |
1190
ed2d7787779e
more warning elimination.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1166
diff
changeset
|
790 rtn = (gchar *)id3_ucs4_utf8duplicate(string); |
290 | 791 } |
792 else { | |
1190
ed2d7787779e
more warning elimination.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1166
diff
changeset
|
793 rtn = (gchar *)id3_ucs4_latin1duplicate(string); |
290 | 794 rtn2 = str_to_utf8(rtn); |
795 free(rtn); | |
796 rtn = rtn2; | |
797 } | |
798 g_free(string); | |
799 string = NULL; | |
800 #ifdef DEBUG | |
801 g_print("string = %s\n", rtn); | |
1321
f0b81aeed25f
Thank you for your help, Giacomo. ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1296
diff
changeset
|
802 #endif |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
803 |
290 | 804 return rtn; |
805 } | |
806 | |
807 int get_id3_tags (const char *filename, tta_info *ttainfo) { | |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
808 int id3v2_size = 0; |
290 | 809 gchar *str = NULL; |
1296
2a6865d42dc4
more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1270
diff
changeset
|
810 gchar *realfn = NULL; |
290 | 811 |
812 struct id3_file *id3file = NULL; | |
813 struct id3_tag *tag = NULL; | |
814 | |
1296
2a6865d42dc4
more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1270
diff
changeset
|
815 realfn = g_filename_from_uri(filename, NULL, NULL); |
2a6865d42dc4
more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1270
diff
changeset
|
816 id3file = id3_file_open (realfn ? realfn : filename, ID3_FILE_MODE_READONLY); |
2a6865d42dc4
more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1270
diff
changeset
|
817 g_free(realfn); realfn = NULL; |
290 | 818 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
819 if (id3file) { |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
820 tag = id3_file_tag (id3file); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
821 |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
822 if (tag) { |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
823 ttainfo->ID3.id3has = 1; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
824 id3v2_size = tag->paddedsize; |
290 | 825 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
826 str = tta_input_id3_get_string (tag, ID3_FRAME_ARTIST); |
1190
ed2d7787779e
more warning elimination.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1166
diff
changeset
|
827 if(str) strncpy((char *)ttainfo->ID3.artist, str, MAX_LINE); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
828 free(str); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
829 str = NULL; |
290 | 830 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
831 str = tta_input_id3_get_string (tag, ID3_FRAME_ALBUM); |
1190
ed2d7787779e
more warning elimination.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1166
diff
changeset
|
832 if(str) strncpy((char *)ttainfo->ID3.album, str, MAX_LINE); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
833 free(str); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
834 str = NULL; |
290 | 835 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
836 str = tta_input_id3_get_string (tag, ID3_FRAME_TITLE); |
1190
ed2d7787779e
more warning elimination.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1166
diff
changeset
|
837 if(str) strncpy((char *)ttainfo->ID3.title, str, MAX_LINE); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
838 free(str); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
839 str = NULL; |
290 | 840 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
841 str = tta_input_id3_get_string (tag, ID3_FRAME_YEAR); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
842 if(!str) str = tta_input_id3_get_string (tag, "TYER"); |
1190
ed2d7787779e
more warning elimination.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1166
diff
changeset
|
843 if(str) strncpy((char *)ttainfo->ID3.year, str, MAX_YEAR); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
844 free(str); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
845 str = NULL; |
290 | 846 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
847 str = tta_input_id3_get_string (tag, ID3_FRAME_TRACK); |
1190
ed2d7787779e
more warning elimination.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1166
diff
changeset
|
848 if(str) strncpy((char *)ttainfo->ID3.track, str, MAX_TRACK); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
849 free(str); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
850 str = NULL; |
290 | 851 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
852 str = tta_input_id3_get_string (tag, ID3_FRAME_GENRE); |
1190
ed2d7787779e
more warning elimination.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1166
diff
changeset
|
853 if(str) strncpy((char *)ttainfo->ID3.genre, str, MAX_GENRE); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
854 free(str); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
855 str = NULL; |
290 | 856 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
857 str = tta_input_id3_get_string (tag, ID3_FRAME_COMMENT); |
1190
ed2d7787779e
more warning elimination.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1166
diff
changeset
|
858 if(str) strncpy((char *)ttainfo->ID3.comment, str, MAX_LINE); |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
859 free(str); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
860 str = NULL; |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
861 } |
290 | 862 |
1012
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
863 id3_file_close(id3file); |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
864 } |
d0d99b22e393
[svn] import major update by Aleksander Djuric (the original author).
yaz
parents:
912
diff
changeset
|
865 |
290 | 866 return id3v2_size; // not used |
867 } |