Mercurial > audlegacy
annotate Plugins/Input/aac/src/libmp4.c @ 319:1e642d74d68c trunk
[svn] Do not abort if libmpc is not found, just disable musepack plugin.
author | chainsaw |
---|---|
date | Sun, 18 Dec 2005 09:06:02 -0800 |
parents | b9e6cdce7219 |
children | d8889f819081 |
rev | line source |
---|---|
61 | 1 /* |
2 * MP4/AAC decoder for xmms | |
3 * | |
4 * This decoding source code is completly independent of the faad2 | |
5 * package. | |
6 * This package exist for people who don't want to install | |
7 * faad2 and mpeg4ip project files. | |
8 * | |
9 * OPTIONNAL need | |
10 * -------------- | |
11 * libid3 (3.8.x - www.id3.org) | |
12 */ | |
13 | |
14 #include <gtk/gtk.h> | |
15 #include "faad.h" | |
16 #include "mp4.h" | |
17 | |
18 #include <audacious/plugin.h> | |
19 #include <libaudacious/util.h> | |
20 #include <libaudacious/titlestring.h> | |
21 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
22 #define MP4_DESCRIPTION "MP4 & MPEG2/4-AAC for bmp-0.9.7" |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
23 #define MP4_VERSION "ver.- 15 December 2004" |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
24 #define LIBMP4V2_VERSION "1.2.0" |
61 | 25 #define MP4_ABOUT "Written by ciberfred" |
26 #define BUFFER_SIZE FAAD_MIN_STREAMSIZE*64 | |
27 | |
28 static void mp4_init(void); | |
29 static void mp4_about(void); | |
30 static void mp4_play(char *); | |
31 static void mp4_stop(void); | |
32 static void mp4_pause(short); | |
33 static void mp4_seek(int); | |
34 static int mp4_getTime(void); | |
35 static void mp4_cleanup(void); | |
36 static void mp4_getSongInfo(char *); | |
37 static int mp4_isFile(char *); | |
38 static void* mp4Decode(void *); | |
39 | |
40 InputPlugin mp4_ip = | |
41 { | |
42 0, // handle | |
43 0, // filename | |
44 MP4_DESCRIPTION, | |
45 mp4_init, | |
46 mp4_about, | |
47 0, // configuration | |
48 mp4_isFile, | |
49 0, //scandir | |
50 mp4_play, | |
51 mp4_stop, | |
52 mp4_pause, | |
53 mp4_seek, | |
54 0, // set equalizer | |
55 mp4_getTime, | |
56 0, // get volume | |
57 0, | |
58 mp4_cleanup, | |
59 0, // obsolete | |
60 0, // send visualisation data | |
61 0, // set player window info | |
62 0, // set song title text | |
63 0, // get song title text | |
64 mp4_getSongInfo, // info box | |
65 0, // to output plugin | |
66 }; | |
67 | |
68 typedef struct _mp4cfg{ | |
69 gshort file_type; | |
70 #define FILE_UNKNOW 0 | |
71 #define FILE_MP4 1 | |
72 #define FILE_AAC 2 | |
73 } Mp4Config; | |
74 | |
75 static Mp4Config mp4cfg; | |
76 static gboolean bPlaying = FALSE; | |
200
094ef8a0a9fd
[svn] GThreadify plugin. Adds a return statement and removes a pragma statement to please GCC.
chainsaw
parents:
199
diff
changeset
|
77 static GThread *decodeThread; |
094ef8a0a9fd
[svn] GThreadify plugin. Adds a return statement and removes a pragma statement to please GCC.
chainsaw
parents:
199
diff
changeset
|
78 GStaticMutex mutex = G_STATIC_MUTEX_INIT; |
61 | 79 static int seekPosition = -1; |
80 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
81 void getMP4info(char*); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
82 int getAACTrack(MP4FileHandle); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
83 |
61 | 84 |
85 InputPlugin *get_iplugin_info(void) | |
86 { | |
87 return(&mp4_ip); | |
88 } | |
89 | |
90 static void mp4_init(void) | |
91 { | |
92 mp4cfg.file_type = FILE_UNKNOW; | |
93 seekPosition = -1; | |
94 return; | |
95 } | |
96 | |
97 static void mp4_play(char *filename) | |
98 { | |
99 bPlaying = TRUE; | |
200
094ef8a0a9fd
[svn] GThreadify plugin. Adds a return statement and removes a pragma statement to please GCC.
chainsaw
parents:
199
diff
changeset
|
100 decodeThread = g_thread_create((GThreadFunc)mp4Decode, g_strdup(filename), TRUE, NULL); |
61 | 101 return; |
102 } | |
103 | |
104 static void mp4_stop(void) | |
105 { | |
106 if(bPlaying){ | |
107 bPlaying = FALSE; | |
200
094ef8a0a9fd
[svn] GThreadify plugin. Adds a return statement and removes a pragma statement to please GCC.
chainsaw
parents:
199
diff
changeset
|
108 g_thread_join(decodeThread); |
61 | 109 mp4_ip.output->close_audio(); |
110 } | |
111 } | |
112 | |
113 static int mp4_isFile(char *filename) | |
114 { | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
115 if(filename){ |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
116 gchar* extention; |
61 | 117 |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
118 extention = strrchr(filename, '.'); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
119 if (extention &&( |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
120 !strcasecmp(extention, ".mp4") || // official extention |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
121 !strcasecmp(extention, ".m4a") || // Apple mp4 extention |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
122 !strcasecmp(extention, ".aac") // old MPEG2/4-AAC extention |
61 | 123 )){ |
124 return (1); | |
125 } | |
126 } | |
127 return(0); | |
128 } | |
129 | |
130 static void mp4_about(void) | |
131 { | |
132 static GtkWidget *aboutbox; | |
133 | |
134 if(aboutbox!=NULL) | |
135 return; | |
136 aboutbox = xmms_show_message("About MP4 AAC player plugin", | |
137 "libfaad2-" FAAD2_VERSION "\n" | |
138 "libmp4v2-" LIBMP4V2_VERSION "\n" | |
139 "plugin version: " MP4_VERSION "\n" | |
140 MP4_ABOUT, | |
141 "Ok", FALSE, NULL, NULL); | |
142 gtk_signal_connect(GTK_OBJECT(aboutbox), "destroy", | |
143 GTK_SIGNAL_FUNC(gtk_widget_destroyed), | |
144 &aboutbox); | |
145 } | |
146 | |
147 static void mp4_pause(short flag) | |
148 { | |
149 mp4_ip.output->pause(flag); | |
150 } | |
151 | |
152 static void mp4_seek(int time) | |
153 { | |
154 seekPosition = time; | |
155 while(bPlaying && seekPosition!=-1) | |
156 xmms_usleep(10000); | |
157 } | |
158 | |
159 static int mp4_getTime(void) | |
160 { | |
161 if(!bPlaying) | |
162 return (-1); | |
163 else | |
164 return (mp4_ip.output->output_time()); | |
165 } | |
166 | |
167 static void mp4_cleanup(void) | |
168 { | |
169 } | |
170 | |
171 static void mp4_getSongInfo(char *filename) | |
172 { | |
173 if(mp4cfg.file_type == FILE_MP4) | |
174 getMP4info(filename); | |
175 else if(mp4cfg.file_type == FILE_AAC) | |
176 ; | |
177 } | |
178 | |
179 static void *mp4Decode(void *args) | |
180 { | |
181 MP4FileHandle mp4file; | |
182 | |
200
094ef8a0a9fd
[svn] GThreadify plugin. Adds a return statement and removes a pragma statement to please GCC.
chainsaw
parents:
199
diff
changeset
|
183 g_static_mutex_lock(&mutex); |
61 | 184 seekPosition = -1; |
185 bPlaying = TRUE; | |
186 if(!(mp4file = MP4Read(args, 0))){ | |
187 mp4cfg.file_type = FILE_AAC; | |
188 MP4Close(mp4file); | |
189 }else{ | |
190 mp4cfg.file_type = FILE_MP4; | |
191 } | |
192 | |
193 if(mp4cfg.file_type == FILE_MP4){ | |
194 // We are reading a MP4 file | |
195 gint mp4track; | |
196 | |
197 if((mp4track = getAACTrack(mp4file)) < 0){ | |
198 //TODO: check here for others Audio format..... | |
199 g_print("Unsupported Audio track type\n"); | |
200 g_free(args); | |
201 MP4Close(mp4file); | |
202 bPlaying = FALSE; | |
200
094ef8a0a9fd
[svn] GThreadify plugin. Adds a return statement and removes a pragma statement to please GCC.
chainsaw
parents:
199
diff
changeset
|
203 g_static_mutex_unlock(&mutex); |
094ef8a0a9fd
[svn] GThreadify plugin. Adds a return statement and removes a pragma statement to please GCC.
chainsaw
parents:
199
diff
changeset
|
204 g_thread_exit(NULL); |
250
b9e6cdce7219
[svn] Reduce code duplication and add a return statement.
chainsaw
parents:
200
diff
changeset
|
205 return(NULL); |
61 | 206 }else{ |
207 faacDecHandle decoder; | |
208 unsigned char *buffer = NULL; | |
209 guint bufferSize = 0; | |
210 gulong samplerate; | |
211 guchar channels; | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
212 //guint avgBitrate; |
61 | 213 MP4Duration duration; |
214 gulong msDuration; | |
215 MP4SampleId numSamples; | |
216 MP4SampleId sampleID = 1; | |
217 | |
218 decoder = faacDecOpen(); | |
219 MP4GetTrackESConfiguration(mp4file, mp4track, &buffer, &bufferSize); | |
250
b9e6cdce7219
[svn] Reduce code duplication and add a return statement.
chainsaw
parents:
200
diff
changeset
|
220 if(!buffer) |
b9e6cdce7219
[svn] Reduce code duplication and add a return statement.
chainsaw
parents:
200
diff
changeset
|
221 goto out; |
b9e6cdce7219
[svn] Reduce code duplication and add a return statement.
chainsaw
parents:
200
diff
changeset
|
222 if(faacDecInit2(decoder, buffer, bufferSize, &samplerate, &channels)<0) |
b9e6cdce7219
[svn] Reduce code duplication and add a return statement.
chainsaw
parents:
200
diff
changeset
|
223 goto out; |
61 | 224 g_free(buffer); |
225 if(channels == 0){ | |
226 g_print("Number of Channels not supported\n"); | |
250
b9e6cdce7219
[svn] Reduce code duplication and add a return statement.
chainsaw
parents:
200
diff
changeset
|
227 goto out; |
61 | 228 } |
229 duration = MP4GetTrackDuration(mp4file, mp4track); | |
230 msDuration = MP4ConvertFromTrackDuration(mp4file, mp4track, duration, | |
231 MP4_MSECS_TIME_SCALE); | |
232 numSamples = MP4GetTrackNumberOfSamples(mp4file, mp4track); | |
233 mp4_ip.output->open_audio(FMT_S16_NE, samplerate, channels); | |
234 mp4_ip.output->flush(0); | |
235 mp4_ip.set_info(args, msDuration, -1, samplerate/1000, channels); | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
236 g_print("MP4 - %d channels @ %d Hz\n", channels, (int)samplerate); |
61 | 237 |
238 while(bPlaying){ | |
239 void* sampleBuffer; | |
240 faacDecFrameInfo frameInfo; | |
241 gint rc; | |
242 | |
243 if(seekPosition!=-1){ | |
244 duration = MP4ConvertToTrackDuration(mp4file, | |
245 mp4track, | |
246 seekPosition*1000, | |
247 MP4_MSECS_TIME_SCALE); | |
248 sampleID = MP4GetSampleIdFromTime(mp4file, mp4track, duration, 0); | |
249 mp4_ip.output->flush(seekPosition*1000); | |
250 seekPosition = -1; | |
251 } | |
252 buffer=NULL; | |
253 bufferSize=0; | |
254 if(sampleID > numSamples){ | |
250
b9e6cdce7219
[svn] Reduce code duplication and add a return statement.
chainsaw
parents:
200
diff
changeset
|
255 goto out; |
61 | 256 } |
257 rc = MP4ReadSample(mp4file, mp4track, sampleID++, &buffer, &bufferSize, | |
258 NULL, NULL, NULL, NULL); | |
259 //g_print("%d/%d\n", sampleID-1, numSamples); | |
260 if((rc==0) || (buffer== NULL)){ | |
261 g_print("MP4: read error\n"); | |
262 sampleBuffer = NULL; | |
263 sampleID=0; | |
264 mp4_ip.output->buffer_free(); | |
250
b9e6cdce7219
[svn] Reduce code duplication and add a return statement.
chainsaw
parents:
200
diff
changeset
|
265 goto out; |
61 | 266 }else{ |
267 sampleBuffer = faacDecDecode(decoder, &frameInfo, buffer, bufferSize); | |
268 if(frameInfo.error > 0){ | |
269 g_print("MP4: %s\n", | |
270 faacDecGetErrorMessage(frameInfo.error)); | |
250
b9e6cdce7219
[svn] Reduce code duplication and add a return statement.
chainsaw
parents:
200
diff
changeset
|
271 goto out; |
61 | 272 } |
273 if(buffer){ | |
274 g_free(buffer); buffer=NULL; bufferSize=0; | |
275 } | |
276 while(bPlaying && mp4_ip.output->buffer_free()<frameInfo.samples<<1) | |
277 xmms_usleep(30000); | |
278 } | |
279 mp4_ip.add_vis_pcm(mp4_ip.output->written_time(), | |
280 FMT_S16_NE, | |
281 channels, | |
282 frameInfo.samples<<1, | |
283 sampleBuffer); | |
284 mp4_ip.output->write_audio(sampleBuffer, frameInfo.samples<<1); | |
285 } | |
286 while(bPlaying && mp4_ip.output->buffer_free()){ | |
287 xmms_usleep(10000); | |
288 } | |
250
b9e6cdce7219
[svn] Reduce code duplication and add a return statement.
chainsaw
parents:
200
diff
changeset
|
289 out: |
61 | 290 mp4_ip.output->close_audio(); |
291 g_free(args); | |
292 faacDecClose(decoder); | |
293 MP4Close(mp4file); | |
294 bPlaying = FALSE; | |
200
094ef8a0a9fd
[svn] GThreadify plugin. Adds a return statement and removes a pragma statement to please GCC.
chainsaw
parents:
199
diff
changeset
|
295 g_static_mutex_unlock(&mutex); |
094ef8a0a9fd
[svn] GThreadify plugin. Adds a return statement and removes a pragma statement to please GCC.
chainsaw
parents:
199
diff
changeset
|
296 g_thread_exit(NULL); |
250
b9e6cdce7219
[svn] Reduce code duplication and add a return statement.
chainsaw
parents:
200
diff
changeset
|
297 return(NULL); |
61 | 298 } |
299 } else{ | |
300 // WE ARE READING AN AAC FILE | |
301 FILE *file = NULL; | |
302 faacDecHandle decoder = 0; | |
303 guchar *buffer = 0; | |
304 gulong bufferconsumed = 0; | |
305 gulong samplerate = 0; | |
306 guchar channels; | |
307 gulong buffervalid = 0; | |
308 TitleInput* input; | |
309 gchar *temp = g_strdup(args); | |
310 gchar *ext = strrchr(temp, '.'); | |
311 gchar *xmmstitle = NULL; | |
312 faacDecConfigurationPtr config; | |
313 | |
314 if((file = fopen(args, "rb")) == 0){ | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
315 g_print("AAC: can't find file %s\n", (char*)args); |
61 | 316 bPlaying = FALSE; |
200
094ef8a0a9fd
[svn] GThreadify plugin. Adds a return statement and removes a pragma statement to please GCC.
chainsaw
parents:
199
diff
changeset
|
317 g_static_mutex_unlock(&mutex); |
094ef8a0a9fd
[svn] GThreadify plugin. Adds a return statement and removes a pragma statement to please GCC.
chainsaw
parents:
199
diff
changeset
|
318 g_thread_exit(NULL); |
61 | 319 } |
320 if((decoder = faacDecOpen()) == NULL){ | |
321 g_print("AAC: Open Decoder Error\n"); | |
322 fclose(file); | |
323 bPlaying = FALSE; | |
200
094ef8a0a9fd
[svn] GThreadify plugin. Adds a return statement and removes a pragma statement to please GCC.
chainsaw
parents:
199
diff
changeset
|
324 g_static_mutex_unlock(&mutex); |
094ef8a0a9fd
[svn] GThreadify plugin. Adds a return statement and removes a pragma statement to please GCC.
chainsaw
parents:
199
diff
changeset
|
325 g_thread_exit(NULL); |
61 | 326 } |
327 config = faacDecGetCurrentConfiguration(decoder); | |
328 config->useOldADTSFormat = 0; | |
329 faacDecSetConfiguration(decoder, config); | |
330 if((buffer = g_malloc(BUFFER_SIZE)) == NULL){ | |
331 g_print("AAC: error g_malloc\n"); | |
332 fclose(file); | |
333 bPlaying = FALSE; | |
334 faacDecClose(decoder); | |
200
094ef8a0a9fd
[svn] GThreadify plugin. Adds a return statement and removes a pragma statement to please GCC.
chainsaw
parents:
199
diff
changeset
|
335 g_static_mutex_unlock(&mutex); |
094ef8a0a9fd
[svn] GThreadify plugin. Adds a return statement and removes a pragma statement to please GCC.
chainsaw
parents:
199
diff
changeset
|
336 g_thread_exit(NULL); |
61 | 337 } |
338 if((buffervalid = fread(buffer, 1, BUFFER_SIZE, file))==0){ | |
339 g_print("AAC: Error reading file\n"); | |
340 g_free(buffer); | |
341 fclose(file); | |
342 bPlaying = FALSE; | |
343 faacDecClose(decoder); | |
200
094ef8a0a9fd
[svn] GThreadify plugin. Adds a return statement and removes a pragma statement to please GCC.
chainsaw
parents:
199
diff
changeset
|
344 g_static_mutex_unlock(&mutex); |
094ef8a0a9fd
[svn] GThreadify plugin. Adds a return statement and removes a pragma statement to please GCC.
chainsaw
parents:
199
diff
changeset
|
345 g_thread_exit(NULL); |
61 | 346 } |
347 XMMS_NEW_TITLEINPUT(input); | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
348 input->file_name = (char*)g_basename(temp); |
61 | 349 input->file_ext = ext ? ext+1 : NULL; |
350 input->file_path = temp; | |
351 if(!strncmp(buffer, "ID3", 3)){ | |
352 gint size = 0; | |
353 | |
354 fseek(file, 0, SEEK_SET); | |
355 size = (buffer[6]<<21) | (buffer[7]<<14) | (buffer[8]<<7) | buffer[9]; | |
356 size+=10; | |
357 fread(buffer, 1, size, file); | |
358 buffervalid = fread(buffer, 1, BUFFER_SIZE, file); | |
359 } | |
360 xmmstitle = xmms_get_titlestring(xmms_get_gentitle_format(), input); | |
361 if(xmmstitle == NULL) | |
362 xmmstitle = g_strdup(input->file_name); | |
363 if(temp) g_free(temp); | |
364 if(input->performer) g_free(input->performer); | |
365 if(input->album_name) g_free(input->album_name); | |
366 if(input->track_name) g_free(input->track_name); | |
367 if(input->genre) g_free(input->genre); | |
368 g_free(input); | |
369 bufferconsumed = faacDecInit(decoder, | |
370 buffer, | |
371 buffervalid, | |
372 &samplerate, | |
373 &channels); | |
374 if(mp4_ip.output->open_audio(FMT_S16_NE,samplerate,channels) == FALSE){ | |
375 g_print("AAC: Output Error\n"); | |
376 g_free(buffer); buffer=0; | |
377 faacDecClose(decoder); | |
378 fclose(file); | |
379 mp4_ip.output->close_audio(); | |
380 /* | |
381 if(positionTable){ | |
382 g_free(positionTable); positionTable=0; | |
383 } | |
384 */ | |
385 g_free(xmmstitle); | |
386 bPlaying = FALSE; | |
200
094ef8a0a9fd
[svn] GThreadify plugin. Adds a return statement and removes a pragma statement to please GCC.
chainsaw
parents:
199
diff
changeset
|
387 g_static_mutex_unlock(&mutex); |
094ef8a0a9fd
[svn] GThreadify plugin. Adds a return statement and removes a pragma statement to please GCC.
chainsaw
parents:
199
diff
changeset
|
388 g_thread_exit(NULL); |
61 | 389 } |
390 //if(bSeek){ | |
391 //mp4_ip.set_info(xmmstitle, lenght*1000, -1, samplerate, channels); | |
392 //}else{ | |
393 mp4_ip.set_info(xmmstitle, -1, -1, samplerate, channels); | |
394 //} | |
395 mp4_ip.output->flush(0); | |
396 | |
397 while(bPlaying && buffervalid > 0){ | |
398 faacDecFrameInfo finfo; | |
399 unsigned long samplesdecoded; | |
400 char* sample_buffer = NULL; | |
401 /* | |
402 if(bSeek && seekPosition!=-1){ | |
403 fseek(file, positionTable[seekPosition], SEEK_SET); | |
404 bufferconsumed=0; | |
405 buffervalid = fread(buffer, 1, BUFFER_SIZE, file); | |
406 aac_ip.output->flush(seekPosition*1000); | |
407 seekPosition=-1; | |
408 } | |
409 */ | |
410 if(bufferconsumed > 0){ | |
411 memmove(buffer, &buffer[bufferconsumed], buffervalid-bufferconsumed); | |
412 buffervalid -= bufferconsumed; | |
413 buffervalid += fread(&buffer[buffervalid], 1, | |
414 BUFFER_SIZE-buffervalid, file); | |
415 bufferconsumed = 0; | |
416 } | |
417 sample_buffer = faacDecDecode(decoder, &finfo, buffer, buffervalid); | |
418 if(finfo.error){ | |
419 config = faacDecGetCurrentConfiguration(decoder); | |
420 if(config->useOldADTSFormat != 1){ | |
421 faacDecClose(decoder); | |
422 decoder = faacDecOpen(); | |
423 config = faacDecGetCurrentConfiguration(decoder); | |
424 config->useOldADTSFormat = 1; | |
425 faacDecSetConfiguration(decoder, config); | |
426 finfo.bytesconsumed=0; | |
427 finfo.samples = 0; | |
428 faacDecInit(decoder, | |
429 buffer, | |
430 buffervalid, | |
431 &samplerate, | |
432 &channels); | |
433 }else{ | |
434 g_print("FAAD2 Warning %s\n", faacDecGetErrorMessage(finfo.error)); | |
435 buffervalid = 0; | |
436 } | |
437 } | |
438 bufferconsumed += finfo.bytesconsumed; | |
439 samplesdecoded = finfo.samples; | |
440 if((samplesdecoded<=0) && !sample_buffer){ | |
441 g_print("AAC: error sample decoding\n"); | |
442 continue; | |
443 } | |
444 while(bPlaying && mp4_ip.output->buffer_free() < (samplesdecoded<<1)){ | |
445 xmms_usleep(10000); | |
446 } | |
447 mp4_ip.add_vis_pcm(mp4_ip.output->written_time(), | |
448 FMT_S16_LE, channels, | |
449 samplesdecoded<<1, sample_buffer); | |
450 mp4_ip.output->write_audio(sample_buffer, samplesdecoded<<1); | |
451 } | |
452 while(bPlaying && mp4_ip.output->buffer_playing()){ | |
453 xmms_usleep(10000); | |
454 } | |
455 mp4_ip.output->buffer_free(); | |
456 mp4_ip.output->close_audio(); | |
457 bPlaying = FALSE; | |
458 g_free(buffer); | |
459 faacDecClose(decoder); | |
460 g_free(xmmstitle); | |
461 fclose(file); | |
462 seekPosition = -1; | |
463 /* | |
464 if(positionTable){ | |
465 g_free(positionTable); positionTable=0; | |
466 } | |
467 */ | |
468 bPlaying = FALSE; | |
200
094ef8a0a9fd
[svn] GThreadify plugin. Adds a return statement and removes a pragma statement to please GCC.
chainsaw
parents:
199
diff
changeset
|
469 g_static_mutex_unlock(&mutex); |
094ef8a0a9fd
[svn] GThreadify plugin. Adds a return statement and removes a pragma statement to please GCC.
chainsaw
parents:
199
diff
changeset
|
470 g_thread_exit(NULL); |
094ef8a0a9fd
[svn] GThreadify plugin. Adds a return statement and removes a pragma statement to please GCC.
chainsaw
parents:
199
diff
changeset
|
471 return(NULL); |
61 | 472 } |
473 } |