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