Mercurial > audlegacy-plugins
annotate src/aac/src/libmp4.c @ 595:99e8b9881cb9 trunk
[svn] - Uncommented some (obviously unneeded?) stuff -> fixed crash
author | mf0102 |
---|---|
date | Thu, 01 Feb 2007 11:12:38 -0800 |
parents | 5e2b137a24fe |
children | 9e4145566248 |
rev | line source |
---|---|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1 #include <glib.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
2 #include <gtk/gtk.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
3 #include <string.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
4 #include <stdlib.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
5 #include "faad.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
6 #include "mp4ff.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
7 #include "tagging.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
8 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
9 #include <audacious/plugin.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
10 #include <audacious/output.h> |
4
0ad4849f6219
[svn] - the first pass missed some libaudacious references, this fixes them
nenolod
parents:
0
diff
changeset
|
11 #include <audacious/util.h> |
0ad4849f6219
[svn] - the first pass missed some libaudacious references, this fixes them
nenolod
parents:
0
diff
changeset
|
12 #include <audacious/titlestring.h> |
0ad4849f6219
[svn] - the first pass missed some libaudacious references, this fixes them
nenolod
parents:
0
diff
changeset
|
13 #include <audacious/vfs.h> |
527
d124034ebea3
[svn] - glib/gi18n.h -> audacious/i18n.h for automatic dgettext support
nenolod
parents:
393
diff
changeset
|
14 #include <audacious/i18n.h> |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
15 |
583 | 16 #define MP4_VERSION VERSION |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
17 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
18 /* |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
19 * BUFFER_SIZE is the highest amount of memory that can be pulled. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
20 * We use this for sanity checks, among other things, as mp4ff needs |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
21 * a labotomy sometimes. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
22 */ |
583 | 23 #define BUFFER_SIZE FAAD_MIN_STREAMSIZE*64 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
24 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
25 /* |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
26 * AAC_MAGIC is the pattern that marks the beginning of an MP4 container. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
27 */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
28 #define AAC_MAGIC (unsigned char [4]) { 0xFF, 0xF9, 0x5C, 0x80 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
29 |
583 | 30 static void mp4_init(void); |
31 static void mp4_about(void); | |
32 static int mp4_is_our_file(char *); | |
33 static void mp4_play(InputPlayback *); | |
34 static void mp4_stop(InputPlayback *); | |
35 static void mp4_pause(InputPlayback *, short); | |
36 static void mp4_seek(InputPlayback *, int); | |
37 static int mp4_get_time(InputPlayback *); | |
38 static void mp4_cleanup(void); | |
39 static void mp4_get_song_title_len(char *filename, char **, int *); | |
40 static TitleInput* mp4_get_song_tuple(char *); | |
41 static int mp4_is_our_fd(char *, VFSFile *); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
42 |
374 | 43 gchar *mp4_fmts[] = { "m4a", "mp4", "aac", NULL }; |
44 | |
583 | 45 static void * mp4_decode(void *); |
46 static gchar * mp4_get_song_title(char *filename); | |
47 static void audmp4_file_info_box(gchar *); | |
48 gboolean buffer_playing; | |
49 | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
50 InputPlugin mp4_ip = |
583 | 51 { |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
52 NULL, // handle |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
53 NULL, // filename |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
54 "MP4 Audio Plugin", |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
55 mp4_init, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
56 mp4_about, |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
57 NULL, // configuration |
583 | 58 mp4_is_our_file, |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
59 NULL, //scandir |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
60 mp4_play, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
61 mp4_stop, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
62 mp4_pause, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
63 mp4_seek, |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
64 NULL, // set equalizer |
583 | 65 mp4_get_time, |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
66 NULL, // get volume |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
67 NULL, |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
68 mp4_cleanup, |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
69 NULL, // obsolete |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
70 NULL, // send visualisation data |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
71 NULL, // set player window info |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
72 NULL, // set song title text |
583 | 73 mp4_get_song_title_len, // get song title text |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
74 NULL, // info box |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
75 NULL, // to output plugin |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
76 mp4_get_song_tuple, |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
77 NULL, |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
78 NULL, |
583 | 79 mp4_is_our_fd, |
374 | 80 mp4_fmts, |
583 | 81 }; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
82 |
583 | 83 typedef struct _mp4cfg |
84 { | |
85 #define FILE_UNKNOWN 0 | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
86 #define FILE_MP4 1 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
87 #define FILE_AAC 2 |
583 | 88 gshort file_type; |
89 } Mp4Config; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
90 |
583 | 91 static Mp4Config mp4cfg; |
92 static GThread *decodeThread; | |
93 GStaticMutex mutex = G_STATIC_MUTEX_INIT; | |
94 static int seekPosition = -1; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
95 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
96 void getMP4info(char*); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
97 int getAACTrack(mp4ff_t *); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
98 |
583 | 99 static guint32 mp4_read_callback(void *data, void *buffer, guint32 len) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
100 { |
583 | 101 if (data == NULL || buffer == NULL) |
102 return -1; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
103 |
583 | 104 return vfs_fread(buffer, 1, len, (VFSFile *) data); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
105 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
106 |
583 | 107 static guint32 mp4_seek_callback(void *data, guint64 pos) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
108 { |
583 | 109 if (data == NULL) |
110 return -1; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
111 |
583 | 112 return vfs_fseek((VFSFile *) data, pos, SEEK_SET); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
113 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
114 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
115 static gchar * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
116 extname(const char *filename) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
117 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
118 gchar *ext = strrchr(filename, '.'); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
119 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
120 if (ext != NULL) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
121 ++ext; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
122 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
123 return ext; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
124 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
125 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
126 InputPlugin *get_iplugin_info(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
127 { |
583 | 128 return(&mp4_ip); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
129 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
130 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
131 static void mp4_init(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
132 { |
583 | 133 mp4cfg.file_type = FILE_UNKNOWN; |
134 seekPosition = -1; | |
135 return; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
136 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
137 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
138 static void mp4_play(InputPlayback *playback) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
139 { |
583 | 140 buffer_playing = TRUE; |
141 decodeThread = g_thread_create((GThreadFunc)mp4_decode, playback, TRUE, NULL); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
142 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
143 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
144 static void mp4_stop(InputPlayback *playback) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
145 { |
583 | 146 if (buffer_playing) |
147 { | |
148 buffer_playing = FALSE; | |
149 g_thread_join(decodeThread); | |
150 playback->output->close_audio(); | |
151 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
152 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
153 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
154 static int mp4_is_our_file(char *filename) |
262
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
155 { |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
156 VFSFile *file; |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
157 gchar* extension; |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
158 gchar magic[8]; |
393 | 159 |
160 memset(magic, '\0', 8); | |
161 | |
262
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
162 extension = strrchr(filename, '.'); |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
163 if ((file = vfs_fopen(filename, "rb"))) { |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
164 vfs_fread(magic, 1, 8, file); |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
165 if (!memcmp(magic, AAC_MAGIC, 4)) { |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
166 vfs_fclose(file); |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
167 return 1; |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
168 } |
583 | 169 if (!memcmp(magic, "ID3", 3)) { // ID3 tag bolted to the front, obfuscated magic bytes |
262
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
170 vfs_fclose(file); |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
171 if (extension &&( |
583 | 172 !strcasecmp(extension, ".mp4") || // official extension |
173 !strcasecmp(extension, ".m4a") || // Apple mp4 extension | |
174 !strcasecmp(extension, ".aac") // old MPEG2/4-AAC extension | |
175 )) | |
176 return 1; | |
177 else | |
178 return 0; | |
262
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
179 } |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
180 if (!memcmp(&magic[4], "ftyp", 4)) { |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
181 vfs_fclose(file); |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
182 return 1; |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
183 } |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
184 vfs_fclose(file); |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
185 } |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
186 return 0; |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
187 } |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
188 |
583 | 189 static int mp4_is_our_fd(char *filename, VFSFile* file) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
190 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
191 gchar* extension; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
192 gchar magic[8]; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
193 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
194 extension = strrchr(filename, '.'); |
255 | 195 vfs_fread(magic, 1, 8, file); |
196 if (!memcmp(magic, AAC_MAGIC, 4)) | |
197 return 1; | |
198 if (!memcmp(&magic[4], "ftyp", 4)) | |
199 return 1; | |
583 | 200 if (!memcmp(magic, "ID3", 3)) { // ID3 tag bolted to the front, obfuscated magic bytes |
255 | 201 if (extension &&( |
583 | 202 !strcasecmp(extension, ".mp4") || // official extension |
203 !strcasecmp(extension, ".m4a") || // Apple mp4 extension | |
204 !strcasecmp(extension, ".aac") // old MPEG2/4-AAC extension | |
255 | 205 )) |
206 return 1; | |
207 else | |
208 return 0; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
209 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
210 return 0; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
211 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
212 |
583 | 213 static void mp4_about(void) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
214 { |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
215 static GtkWidget *aboutbox = NULL; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
216 aboutbox = xmms_show_message("About MP4 AAC player plugin", |
583 | 217 "Using libfaad2-" FAAD2_VERSION " for decoding.\n" |
218 "Copyright (c) 2005-2006 Audacious team", | |
219 "Ok", FALSE, NULL, NULL); | |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
220 g_signal_connect(G_OBJECT(aboutbox), "destroy", |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
221 G_CALLBACK(gtk_widget_destroyed), |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
222 &aboutbox); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
223 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
224 |
583 | 225 static void mp4_pause(InputPlayback *playback, short flag) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
226 { |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
227 playback->output->pause(flag); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
228 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
229 |
583 | 230 static void mp4_seek(InputPlayback *data, int time) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
231 { |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
232 seekPosition = time; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
233 while(buffer_playing && seekPosition != -1) |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
234 xmms_usleep(10000); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
235 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
236 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
237 static int mp4_get_time(InputPlayback *playback) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
238 { |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
239 if(!buffer_playing) |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
240 return (-1); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
241 else |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
242 return (playback->output->output_time()); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
243 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
244 |
583 | 245 static void mp4_cleanup(void) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
246 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
247 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
248 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
249 static TitleInput *mp4_get_song_tuple(char *fn) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
250 { |
583 | 251 mp4ff_callback_t *mp4cb = g_malloc0(sizeof(mp4ff_callback_t)); |
252 VFSFile *mp4fh; | |
253 mp4ff_t *mp4file; | |
254 TitleInput *input = NULL; | |
255 gchar *filename = g_strdup(fn); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
256 |
583 | 257 mp4fh = vfs_fopen(filename, "rb"); |
258 mp4cb->read = mp4_read_callback; | |
259 mp4cb->seek = mp4_seek_callback; | |
260 mp4cb->user_data = mp4fh; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
261 |
583 | 262 if (!(mp4file = mp4ff_open_read(mp4cb))) { |
263 g_free(mp4cb); | |
264 vfs_fclose(mp4fh); | |
265 } else { | |
266 gint mp4track= getAACTrack(mp4file); | |
267 gint numSamples = mp4ff_num_samples(mp4file, mp4track); | |
268 guint framesize = 1024; | |
269 gulong samplerate; | |
270 guchar channels; | |
271 gint msDuration; | |
272 mp4AudioSpecificConfig mp4ASC; | |
273 gchar *tmpval; | |
274 guchar *buffer = NULL; | |
275 guint bufferSize = 0; | |
276 faacDecHandle decoder; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
277 |
583 | 278 if (mp4track == -1) |
279 return NULL; | |
280 | |
281 decoder = faacDecOpen(); | |
282 mp4ff_get_decoder_config(mp4file, mp4track, &buffer, &bufferSize); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
283 |
583 | 284 if ( !buffer ) { |
285 faacDecClose(decoder); | |
286 return FALSE; | |
287 } | |
288 if ( faacDecInit2(decoder, buffer, bufferSize, | |
289 &samplerate, &channels) < 0 ) { | |
290 faacDecClose(decoder); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
291 |
583 | 292 return FALSE; |
293 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
294 |
583 | 295 /* Add some hacks for SBR profile */ |
296 if (AudioSpecificConfig(buffer, bufferSize, &mp4ASC) >= 0) { | |
297 if (mp4ASC.frameLengthFlag == 1) framesize = 960; | |
298 if (mp4ASC.sbr_present_flag == 1) framesize *= 2; | |
299 } | |
300 | |
301 g_free(buffer); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
302 |
583 | 303 faacDecClose(decoder); |
304 | |
305 msDuration = ((float)numSamples * (float)(framesize - 1.0)/(float)samplerate) * 1000; | |
306 | |
307 input = bmp_title_input_new(); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
308 |
583 | 309 mp4ff_meta_get_title(mp4file, &input->track_name); |
310 mp4ff_meta_get_album(mp4file, &input->album_name); | |
311 mp4ff_meta_get_artist(mp4file, &input->performer); | |
312 mp4ff_meta_get_date(mp4file, &tmpval); | |
313 mp4ff_meta_get_genre(mp4file, &input->genre); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
314 |
583 | 315 if (tmpval) |
316 { | |
317 input->year = atoi(tmpval); | |
318 free(tmpval); | |
319 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
320 |
583 | 321 input->file_name = g_path_get_basename(filename); |
322 input->file_path = g_path_get_dirname(filename); | |
323 input->file_ext = extname(filename); | |
324 input->length = msDuration; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
325 |
583 | 326 free (mp4cb); |
327 vfs_fclose(mp4fh); | |
328 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
329 |
583 | 330 return input; |
331 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
332 |
583 | 333 static void mp4_get_song_title_len(char *filename, char **title, int *len) |
334 { | |
335 (*title) = mp4_get_song_title(filename); | |
336 (*len) = -1; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
337 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
338 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
339 static gchar *mp4_get_song_title(char *filename) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
340 { |
583 | 341 mp4ff_callback_t *mp4cb = g_malloc0(sizeof(mp4ff_callback_t)); |
342 VFSFile *mp4fh; | |
343 mp4ff_t *mp4file; | |
344 gchar *title = NULL; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
345 |
583 | 346 mp4fh = vfs_fopen(filename, "rb"); |
347 mp4cb->read = mp4_read_callback; | |
348 mp4cb->seek = mp4_seek_callback; | |
349 mp4cb->user_data = mp4fh; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
350 |
583 | 351 if (!(mp4file = mp4ff_open_read(mp4cb))) { |
352 g_free(mp4cb); | |
353 vfs_fclose(mp4fh); | |
354 } else { | |
355 TitleInput *input; | |
356 gchar *tmpval; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
357 |
583 | 358 input = bmp_title_input_new(); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
359 |
583 | 360 mp4ff_meta_get_title(mp4file, &input->track_name); |
361 mp4ff_meta_get_album(mp4file, &input->album_name); | |
362 mp4ff_meta_get_artist(mp4file, &input->performer); | |
363 mp4ff_meta_get_date(mp4file, &tmpval); | |
364 mp4ff_meta_get_genre(mp4file, &input->genre); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
365 |
583 | 366 if (tmpval) |
367 { | |
368 input->year = atoi(tmpval); | |
369 free(tmpval); | |
370 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
371 |
583 | 372 input->file_name = g_path_get_basename(filename); |
373 input->file_path = g_path_get_dirname(filename); | |
374 input->file_ext = extname(filename); | |
375 | |
376 title = xmms_get_titlestring(xmms_get_gentitle_format(), input); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
377 |
583 | 378 free (input->track_name); |
379 free (input->album_name); | |
380 free (input->performer); | |
381 free (input->genre); | |
382 free (input->file_name); | |
383 free (input->file_path); | |
384 free (input); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
385 |
583 | 386 free (mp4cb); |
387 vfs_fclose(mp4fh); | |
388 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
389 |
583 | 390 if (!title) |
391 { | |
392 title = g_path_get_basename(filename); | |
393 if (extname(title)) | |
394 *(extname(title) - 1) = '\0'; | |
395 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
396 |
583 | 397 return title; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
398 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
399 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
400 static int my_decode_mp4( InputPlayback *playback, char *filename, mp4ff_t *mp4file ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
401 { |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
402 // We are reading an MP4 file |
583 | 403 gint mp4track= getAACTrack(mp4file); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
404 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
405 if (mp4track < 0) |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
406 { |
583 | 407 g_print("Unsupported Audio track type\n"); |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
408 return TRUE; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
409 } |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
410 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
411 faacDecHandle decoder; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
412 mp4AudioSpecificConfig mp4ASC; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
413 guchar *buffer = NULL; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
414 guint bufferSize = 0; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
415 gulong samplerate; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
416 guchar channels; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
417 gulong msDuration; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
418 gulong numSamples; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
419 gulong sampleID = 1; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
420 guint framesize = 1024; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
421 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
422 gchar *xmmstitle = NULL; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
423 xmmstitle = mp4_get_song_title(filename); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
424 if(xmmstitle == NULL) |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
425 xmmstitle = g_strdup(filename); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
426 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
427 decoder = faacDecOpen(); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
428 mp4ff_get_decoder_config(mp4file, mp4track, &buffer, &bufferSize); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
429 if ( !buffer ) { |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
430 faacDecClose(decoder); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
431 return FALSE; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
432 } |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
433 if ( faacDecInit2(decoder, buffer, bufferSize, |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
434 &samplerate, &channels) < 0 ) { |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
435 faacDecClose(decoder); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
436 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
437 return FALSE; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
438 } |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
439 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
440 /* Add some hacks for SBR profile */ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
441 if (AudioSpecificConfig(buffer, bufferSize, &mp4ASC) >= 0) { |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
442 if (mp4ASC.frameLengthFlag == 1) framesize = 960; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
443 if (mp4ASC.sbr_present_flag == 1) framesize *= 2; |
583 | 444 } |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
445 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
446 g_free(buffer); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
447 if( !channels ) { |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
448 faacDecClose(decoder); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
449 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
450 return FALSE; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
451 } |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
452 numSamples = mp4ff_num_samples(mp4file, mp4track); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
453 msDuration = ((float)numSamples * (float)(framesize - 1.0)/(float)samplerate) * 1000; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
454 playback->output->open_audio(FMT_S16_NE, samplerate, channels); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
455 playback->output->flush(0); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
456 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
457 mp4_ip.set_info(xmmstitle, msDuration, |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
458 mp4ff_get_avg_bitrate( mp4file, mp4track ), |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
459 samplerate,channels); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
460 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
461 while ( buffer_playing ) { |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
462 void* sampleBuffer; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
463 faacDecFrameInfo frameInfo; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
464 gint rc; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
465 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
466 /* Seek if seek position has changed */ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
467 if ( seekPosition!=-1 ) { |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
468 sampleID = (float)seekPosition*(float)samplerate/(float)(framesize - 1.0); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
469 playback->output->flush(seekPosition*1000); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
470 seekPosition = -1; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
471 } |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
472 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
473 /* Otherwise continue playing */ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
474 buffer=NULL; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
475 bufferSize=0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
476 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
477 /* If we've run to the end of the file, we're done. */ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
478 if(sampleID >= numSamples){ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
479 /* Finish playing before we close the |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
480 output. */ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
481 while ( playback->output->buffer_playing() ) { |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
482 xmms_usleep(10000); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
483 } |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
484 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
485 playback->output->flush(seekPosition*1000); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
486 playback->output->close_audio(); |
583 | 487 faacDecClose(decoder); |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
488 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
489 g_static_mutex_lock(&mutex); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
490 buffer_playing = FALSE; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
491 g_static_mutex_unlock(&mutex); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
492 g_thread_exit(NULL); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
493 |
583 | 494 return FALSE; |
495 } | |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
496 rc= mp4ff_read_sample(mp4file, mp4track, |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
497 sampleID++, &buffer, &bufferSize); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
498 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
499 /*g_print(":: %d/%d\n", sampleID-1, numSamples);*/ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
500 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
501 /* If we can't read the file, we're done. */ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
502 if((rc == 0) || (buffer== NULL) || (bufferSize == 0) || (bufferSize > BUFFER_SIZE)){ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
503 g_print("MP4: read error\n"); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
504 sampleBuffer = NULL; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
505 sampleID=0; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
506 playback->output->buffer_free(); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
507 playback->output->close_audio(); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
508 |
583 | 509 faacDecClose(decoder); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
510 |
583 | 511 return FALSE; |
512 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
513 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
514 /* g_print(" :: %d/%d\n", bufferSize, BUFFER_SIZE); */ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
515 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
516 sampleBuffer= faacDecDecode(decoder, |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
517 &frameInfo, |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
518 buffer, |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
519 bufferSize); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
520 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
521 /* If there was an error decoding, we're done. */ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
522 if(frameInfo.error > 0){ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
523 g_print("MP4: %s\n", |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
524 faacDecGetErrorMessage(frameInfo.error)); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
525 playback->output->close_audio(); |
583 | 526 faacDecClose(decoder); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
527 |
583 | 528 return FALSE; |
529 } | |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
530 if(buffer){ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
531 g_free(buffer); |
583 | 532 buffer=NULL; |
533 bufferSize=0; | |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
534 } |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
535 if (buffer_playing == FALSE) |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
536 { |
583 | 537 playback->output->close_audio(); |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
538 return FALSE; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
539 } |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
540 produce_audio(playback->output->written_time(), |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
541 FMT_S16_NE, |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
542 channels, |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
543 frameInfo.samples<<1, |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
544 sampleBuffer, &buffer_playing); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
545 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
546 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
547 playback->output->close_audio(); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
548 faacDecClose(decoder); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
549 |
583 | 550 return TRUE; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
551 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
552 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
553 static void my_decode_aac( InputPlayback *playback, char *filename ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
554 { |
583 | 555 // WE ARE READING AN AAC FILE |
556 VFSFile *file = NULL; | |
557 faacDecHandle decoder = 0; | |
558 guchar *buffer = 0; | |
559 gulong bufferconsumed = 0; | |
560 gulong samplerate = 0; | |
561 guchar channels; | |
562 gulong buffervalid = 0; | |
563 TitleInput* input; | |
564 gchar *temp = g_strdup(filename); | |
565 gchar *ext = strrchr(temp, '.'); | |
566 gchar *xmmstitle = NULL; | |
567 faacDecConfigurationPtr config; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
568 |
583 | 569 if((file = vfs_fopen(filename, "rb")) == 0){ |
570 g_print("AAC: can't find file %s\n", filename); | |
571 buffer_playing = FALSE; | |
572 g_static_mutex_unlock(&mutex); | |
573 g_thread_exit(NULL); | |
574 } | |
575 if((decoder = faacDecOpen()) == NULL){ | |
576 g_print("AAC: Open Decoder Error\n"); | |
577 vfs_fclose(file); | |
578 buffer_playing = FALSE; | |
579 g_static_mutex_unlock(&mutex); | |
580 g_thread_exit(NULL); | |
581 } | |
582 config = faacDecGetCurrentConfiguration(decoder); | |
583 config->useOldADTSFormat = 0; | |
584 faacDecSetConfiguration(decoder, config); | |
585 if((buffer = g_malloc(BUFFER_SIZE)) == NULL){ | |
586 g_print("AAC: error g_malloc\n"); | |
587 vfs_fclose(file); | |
588 buffer_playing = FALSE; | |
589 faacDecClose(decoder); | |
590 g_static_mutex_unlock(&mutex); | |
591 g_thread_exit(NULL); | |
592 } | |
593 if((buffervalid = vfs_fread(buffer, 1, BUFFER_SIZE, file))==0){ | |
594 g_print("AAC: Error reading file\n"); | |
595 g_free(buffer); | |
596 vfs_fclose(file); | |
597 buffer_playing = FALSE; | |
598 faacDecClose(decoder); | |
599 g_static_mutex_unlock(&mutex); | |
600 g_thread_exit(NULL); | |
601 } | |
602 XMMS_NEW_TITLEINPUT(input); | |
603 input->file_name = (char*)g_basename(temp); | |
604 input->file_ext = ext ? ext+1 : NULL; | |
605 input->file_path = temp; | |
606 if(!strncmp((char*)buffer, "ID3", 3)){ | |
607 gint size = 0; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
608 |
583 | 609 vfs_fseek(file, 0, SEEK_SET); |
610 size = (buffer[6]<<21) | (buffer[7]<<14) | (buffer[8]<<7) | buffer[9]; | |
611 size+=10; | |
612 vfs_fread(buffer, 1, size, file); | |
613 buffervalid = vfs_fread(buffer, 1, BUFFER_SIZE, file); | |
614 } | |
615 xmmstitle = xmms_get_titlestring(xmms_get_gentitle_format(), input); | |
616 if(xmmstitle == NULL) | |
617 xmmstitle = g_strdup(input->file_name); | |
618 if(temp) g_free(temp); | |
619 if(input->performer) g_free(input->performer); | |
620 if(input->album_name) g_free(input->album_name); | |
621 if(input->track_name) g_free(input->track_name); | |
622 if(input->genre) g_free(input->genre); | |
623 g_free(input); | |
624 bufferconsumed = faacDecInit(decoder, | |
625 buffer, | |
626 buffervalid, | |
627 &samplerate, | |
628 &channels); | |
629 if(playback->output->open_audio(FMT_S16_NE,samplerate,channels) == FALSE){ | |
630 g_print("AAC: Output Error\n"); | |
631 g_free(buffer); buffer=0; | |
632 faacDecClose(decoder); | |
633 vfs_fclose(file); | |
634 playback->output->close_audio(); | |
635 g_free(xmmstitle); | |
636 buffer_playing = FALSE; | |
637 g_static_mutex_unlock(&mutex); | |
638 g_thread_exit(NULL); | |
639 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
640 |
583 | 641 mp4_ip.set_info(xmmstitle, -1, -1, samplerate, channels); |
642 playback->output->flush(0); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
643 |
583 | 644 while(buffer_playing && buffervalid > 0){ |
645 faacDecFrameInfo finfo; | |
646 unsigned long samplesdecoded; | |
647 char* sample_buffer = NULL; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
648 |
583 | 649 if(bufferconsumed > 0){ |
650 memmove(buffer, &buffer[bufferconsumed], buffervalid-bufferconsumed); | |
651 buffervalid -= bufferconsumed; | |
652 buffervalid += vfs_fread(&buffer[buffervalid], 1, | |
653 BUFFER_SIZE-buffervalid, file); | |
654 bufferconsumed = 0; | |
655 } | |
656 sample_buffer = faacDecDecode(decoder, &finfo, buffer, buffervalid); | |
657 if(finfo.error){ | |
658 config = faacDecGetCurrentConfiguration(decoder); | |
659 if(config->useOldADTSFormat != 1){ | |
660 faacDecClose(decoder); | |
661 decoder = faacDecOpen(); | |
662 config = faacDecGetCurrentConfiguration(decoder); | |
663 config->useOldADTSFormat = 1; | |
664 faacDecSetConfiguration(decoder, config); | |
665 finfo.bytesconsumed=0; | |
666 finfo.samples = 0; | |
667 faacDecInit(decoder, | |
668 buffer, | |
669 buffervalid, | |
670 &samplerate, | |
671 &channels); | |
672 }else{ | |
673 g_print("FAAD2 Warning %s\n", faacDecGetErrorMessage(finfo.error)); | |
674 buffervalid = 0; | |
675 } | |
676 } | |
677 bufferconsumed += finfo.bytesconsumed; | |
678 samplesdecoded = finfo.samples; | |
679 if((samplesdecoded<=0) && !sample_buffer){ | |
680 g_print("AAC: error sample decoding\n"); | |
681 continue; | |
682 } | |
683 produce_audio(playback->output->written_time(), | |
684 FMT_S16_LE, channels, | |
685 samplesdecoded<<1, sample_buffer, &buffer_playing); | |
686 } | |
687 playback->output->buffer_free(); | |
688 playback->output->close_audio(); | |
689 buffer_playing = FALSE; | |
690 g_free(buffer); | |
691 faacDecClose(decoder); | |
692 g_free(xmmstitle); | |
693 vfs_fclose(file); | |
694 seekPosition = -1; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
695 |
583 | 696 buffer_playing = FALSE; |
697 g_static_mutex_unlock(&mutex); | |
698 g_thread_exit(NULL); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
699 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
700 |
583 | 701 static void *mp4_decode( void *args ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
702 { |
583 | 703 mp4ff_callback_t *mp4cb = g_malloc0(sizeof(mp4ff_callback_t)); |
704 VFSFile *mp4fh; | |
705 mp4ff_t *mp4file; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
706 |
583 | 707 InputPlayback *playback = args; |
708 char *filename = playback->filename; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
709 |
583 | 710 mp4fh = vfs_fopen(filename, "rb"); |
711 mp4cb->read = mp4_read_callback; | |
712 mp4cb->seek = mp4_seek_callback; | |
713 mp4cb->user_data = mp4fh; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
714 |
583 | 715 g_static_mutex_lock(&mutex); |
716 seekPosition= -1; | |
717 buffer_playing= TRUE; | |
718 g_static_mutex_unlock(&mutex); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
719 |
583 | 720 mp4file= mp4ff_open_read(mp4cb); |
721 if( !mp4file ) { | |
722 mp4cfg.file_type = FILE_AAC; | |
723 vfs_fclose(mp4fh); | |
724 g_free(mp4cb); | |
725 } | |
726 else { | |
727 mp4cfg.file_type = FILE_MP4; | |
728 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
729 |
583 | 730 if ( mp4cfg.file_type == FILE_MP4 ) { |
731 my_decode_mp4( playback, filename, mp4file ); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
732 |
595
99e8b9881cb9
[svn] - Uncommented some (obviously unneeded?) stuff -> fixed crash
mf0102
parents:
584
diff
changeset
|
733 /* |
99e8b9881cb9
[svn] - Uncommented some (obviously unneeded?) stuff -> fixed crash
mf0102
parents:
584
diff
changeset
|
734 * What's this shit good for? |
583 | 735 g_free(args); |
736 vfs_fclose(mp4fh); | |
737 g_static_mutex_lock(&mutex); | |
738 buffer_playing = FALSE; | |
739 g_static_mutex_unlock(&mutex); | |
740 g_thread_exit(NULL); | |
595
99e8b9881cb9
[svn] - Uncommented some (obviously unneeded?) stuff -> fixed crash
mf0102
parents:
584
diff
changeset
|
741 */ |
583 | 742 } |
743 else { | |
744 my_decode_aac( playback, filename ); | |
745 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
746 |
583 | 747 return NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
748 } |