annotate src/tta/libtta.c @ 1237:0d5b0f861bf0

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