Mercurial > audlegacy-plugins
comparison src/wma/wma.c @ 2438:038e90348306
Remove static values, making the plugin re-entrant. As such, remove the now unnecessary playback mutex.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Fri, 07 Mar 2008 15:02:44 -0600 |
parents | 6b07b92a0308 |
children | be645fc2980d |
comparison
equal
deleted
inserted
replaced
2437:6b07b92a0308 | 2438:038e90348306 |
---|---|
50 static const int ST_BUFF = 1024; | 50 static const int ST_BUFF = 1024; |
51 | 51 |
52 static int wma_decode = 0; | 52 static int wma_decode = 0; |
53 static gboolean wma_pause = 0; | 53 static gboolean wma_pause = 0; |
54 static int wma_seekpos = -1; | 54 static int wma_seekpos = -1; |
55 static int wma_st_buff, wma_idx, wma_idx2; | |
56 static GThread *wma_decode_thread; | 55 static GThread *wma_decode_thread; |
57 GStaticMutex wma_mutex = G_STATIC_MUTEX_INIT; | |
58 static uint8_t *wma_outbuf, *wma_s_outbuf; | |
59 | 56 |
60 char description[64]; | 57 char description[64]; |
61 static void wma_about(void); | 58 static void wma_about(void); |
62 static void wma_init(void); | 59 static void wma_init(void); |
63 static int wma_is_our_fd(char *filename, VFSFile *fd); | 60 static int wma_is_our_fd(char *filename, VFSFile *fd); |
296 AVCodecContext *c = NULL; | 293 AVCodecContext *c = NULL; |
297 AVFormatContext *ic = NULL; | 294 AVFormatContext *ic = NULL; |
298 uint8_t *inbuf_ptr; | 295 uint8_t *inbuf_ptr; |
299 int out_size, size, len; | 296 int out_size, size, len; |
300 AVPacket pkt; | 297 AVPacket pkt; |
298 guint8 *wma_outbuf, *wma_s_outbuf; | |
299 int wma_st_buff, wma_idx, wma_idx2; | |
301 | 300 |
302 if(av_open_input_file(&ic, playback->filename, NULL, 0, NULL) < 0) return; | 301 if(av_open_input_file(&ic, playback->filename, NULL, 0, NULL) < 0) return; |
303 | 302 |
304 for(wma_idx = 0; wma_idx < ic->nb_streams; wma_idx++) { | 303 for(wma_idx = 0; wma_idx < ic->nb_streams; wma_idx++) { |
305 c = &ic->streams[wma_idx]->codec; | 304 c = &ic->streams[wma_idx]->codec; |
331 wma_decode = 1; | 330 wma_decode = 1; |
332 playback->playing = 1; | 331 playback->playing = 1; |
333 wma_decode_thread = g_thread_self(); | 332 wma_decode_thread = g_thread_self(); |
334 playback->set_pb_ready(playback); | 333 playback->set_pb_ready(playback); |
335 | 334 |
336 g_static_mutex_lock(&wma_mutex); | |
337 while(playback->playing) | 335 while(playback->playing) |
338 { | 336 { |
339 if(wma_seekpos != -1) | 337 if(wma_seekpos != -1) |
340 { | 338 { |
341 av_seek_frame(ic, wma_idx, wma_seekpos * 1000000LL); | 339 av_seek_frame(ic, wma_idx, wma_seekpos * 1000000LL); |
385 if(wma_s_outbuf) g_free(wma_s_outbuf); | 383 if(wma_s_outbuf) g_free(wma_s_outbuf); |
386 if(wma_outbuf) g_free(wma_outbuf); | 384 if(wma_outbuf) g_free(wma_outbuf); |
387 if(pkt.data) av_free_packet(&pkt); | 385 if(pkt.data) av_free_packet(&pkt); |
388 if(c) avcodec_close(c); | 386 if(c) avcodec_close(c); |
389 if(ic) av_close_input_file(ic); | 387 if(ic) av_close_input_file(ic); |
390 g_static_mutex_unlock(&wma_mutex); | |
391 } | 388 } |
392 | 389 |
393 static void wma_stop(InputPlayback *playback) | 390 static void wma_stop(InputPlayback *playback) |
394 { | 391 { |
395 wma_decode = 0; | 392 wma_decode = 0; |