annotate src/tta/libtta.c @ 2298:cfe45e6861f7

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