diff options
author | Guenter Bartsch <guenter@users.sourceforge.net> | 2001-06-14 09:54:13 +0000 |
---|---|---|
committer | Guenter Bartsch <guenter@users.sourceforge.net> | 2001-06-14 09:54:13 +0000 |
commit | 18b58faa961cb45344c0d00a753c2d65e2ce8a98 (patch) | |
tree | e872df16fa896cc5c794b900a2206020f9877a45 /src/xine-engine/audio_decoder.c | |
parent | 7c2f7f0e1aba2b11b3b7024280a0ac5dc3cd7275 (diff) | |
download | xine-lib-18b58faa961cb45344c0d00a753c2d65e2ce8a98.tar.gz xine-lib-18b58faa961cb45344c0d00a753c2d65e2ce8a98.tar.bz2 |
more small fixes and workarounds
CVS patchset: 176
CVS date: 2001/06/14 09:54:13
Diffstat (limited to 'src/xine-engine/audio_decoder.c')
-rw-r--r-- | src/xine-engine/audio_decoder.c | 246 |
1 files changed, 119 insertions, 127 deletions
diff --git a/src/xine-engine/audio_decoder.c b/src/xine-engine/audio_decoder.c index 0d7af2614..547589604 100644 --- a/src/xine-engine/audio_decoder.c +++ b/src/xine-engine/audio_decoder.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: audio_decoder.c,v 1.16 2001/06/11 03:14:29 heikos Exp $ + * $Id: audio_decoder.c,v 1.17 2001/06/14 09:54:13 guenter Exp $ * * * functions that implement audio decoding @@ -41,140 +41,123 @@ void *audio_decoder_loop (void *this_gen) { buf = this->audio_fifo->get (this->audio_fifo); - if (this->audio_out) { - - this->cur_input_pos = buf->input_pos; - - /* - * Call update status callback function if - * there is no video decoder initialized, like - * in .mp3 playback. - */ - if(this->cur_video_decoder_plugin == NULL) { - if(this->status == XINE_PLAY) - this->status_callback (this->status); + this->cur_input_pos = buf->input_pos; + + /* + * Call update status callback function if + * there is no video decoder initialized, like + * in .mp3 playback. + */ + if(this->cur_video_decoder_plugin == NULL) { + if(this->status == XINE_PLAY) + this->status_callback (this->status); + } + + switch (buf->type) { + + case BUF_CONTROL_START: + if (this->cur_audio_decoder_plugin) { + this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); + this->cur_audio_decoder_plugin = NULL; } - - switch (buf->type) { - - case BUF_CONTROL_START: - if (this->cur_audio_decoder_plugin) { - this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); - this->cur_audio_decoder_plugin = NULL; - } - - pthread_mutex_lock (&this->xine_lock); - this->audio_finished = 0; + + pthread_mutex_lock (&this->xine_lock); + this->audio_finished = 0; + pthread_mutex_unlock (&this->xine_lock); + + for (i=0 ; i<50; i++) + this->audio_track_map[0] = 0; + + this->audio_track_map_entries = 0; + + break; + + case BUF_CONTROL_END: + if (this->cur_audio_decoder_plugin) { + this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); + this->cur_audio_decoder_plugin = NULL; + } + + pthread_mutex_lock (&this->xine_lock); + + this->audio_finished = 1; + + if (this->video_finished) { pthread_mutex_unlock (&this->xine_lock); - - for (i=0 ; i<50; i++) - this->audio_track_map[0] = 0; - - this->audio_track_map_entries = 0; - + xine_notify_stream_finished (this); + } else + pthread_mutex_unlock (&this->xine_lock); + break; - - case BUF_CONTROL_END: - if (this->cur_audio_decoder_plugin) { - this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); - this->cur_audio_decoder_plugin = NULL; - } - - pthread_mutex_lock (&this->xine_lock); - - this->audio_finished = 1; - if (this->video_finished) { - pthread_mutex_unlock (&this->xine_lock); - xine_notify_stream_finished (this); - } else - pthread_mutex_unlock (&this->xine_lock); - - break; - - case BUF_CONTROL_QUIT: - if (this->cur_audio_decoder_plugin) { - this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); - this->cur_audio_decoder_plugin = NULL; - } - running = 0; - break; - - default: - if ( (buf->type & 0xFF000000) == BUF_AUDIO_BASE ) { + case BUF_CONTROL_QUIT: + if (this->cur_audio_decoder_plugin) { + this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); + this->cur_audio_decoder_plugin = NULL; + } + running = 0; + break; - /* printf ("audio_decoder: got an audio buffer, type %08x\n", buf->type); */ - - /* update track map */ - - i = 0; - while ( (i<this->audio_track_map_entries) && (this->audio_track_map[i]<buf->type) ) - i++; - - /* + default: + if ( (buf->type & 0xFF000000) == BUF_AUDIO_BASE ) { + + /* printf ("audio_decoder: got an audio buffer, type %08x\n", buf->type); */ + + /* update track map */ + + i = 0; + while ( (i<this->audio_track_map_entries) && (this->audio_track_map[i]<buf->type) ) + i++; + + /* printf ("audio_decoder: got an audio buffer, type %08x, %d map entries, i=%d\n", - buf->type, this->audio_track_map_entries, i); - */ + buf->type, this->audio_track_map_entries, i); + */ + + if ( (i==this->audio_track_map_entries) || (this->audio_track_map[i] != buf->type) ) { - if ( (i==this->audio_track_map_entries) || (this->audio_track_map[i] != buf->type) ) { + j = this->audio_track_map_entries; + while (j>i) { + this->audio_track_map[j] = this->audio_track_map[j-1]; + j--; + } + this->audio_track_map[i] = buf->type; + this->audio_track_map_entries++; - j = this->audio_track_map_entries; - while (j>i) { - this->audio_track_map[j] = this->audio_track_map[j-1]; - j--; + if (i<=this->audio_channel) { + /* close old audio decoder */ + if (this->cur_audio_decoder_plugin) { + this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); + this->cur_audio_decoder_plugin = NULL; } - this->audio_track_map[i] = buf->type; - this->audio_track_map_entries++; - - if (i<=this->audio_channel) { - /* close old audio decoder */ - if (this->cur_audio_decoder_plugin) { - this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); - this->cur_audio_decoder_plugin = NULL; - } - } - } + + } - /* now, decode this buffer if it's the right track */ + /* now, decode this buffer if it's the right track */ - if (buf->type == this->audio_track_map[this->audio_channel]) { + if (buf->type == this->audio_track_map[this->audio_channel]) { - int streamtype = (buf->type>>16) & 0xFF; + int streamtype = (buf->type>>16) & 0xFF; - decoder = this->audio_decoder_plugins [streamtype]; + decoder = this->audio_decoder_plugins [streamtype]; - if (decoder) { - if (this->cur_audio_decoder_plugin != decoder) { + if (decoder) { + if (this->cur_audio_decoder_plugin != decoder) { - if (this->cur_audio_decoder_plugin) - this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); + if (this->cur_audio_decoder_plugin) + this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); - this->cur_audio_decoder_plugin = decoder; - this->cur_audio_decoder_plugin->init (this->cur_audio_decoder_plugin, this->audio_out); + this->cur_audio_decoder_plugin = decoder; + this->cur_audio_decoder_plugin->init (this->cur_audio_decoder_plugin, this->audio_out); - } - - decoder->decode_data (decoder, buf); } + + decoder->decode_data (decoder, buf); } - } else - printf ("audio_decoder: unknown buffer type: %08x\n", buf->type); - } - } - else { - /* No audio driver loaded */ - pthread_mutex_lock (&this->xine_lock); - - this->audio_finished = 1; - - if (this->video_finished) { - pthread_mutex_unlock (&this->xine_lock); - xine_notify_stream_finished (this); + } } else - pthread_mutex_unlock (&this->xine_lock); - - pthread_exit(NULL); + printf ("audio_decoder: unknown buffer type: %08x\n", buf->type); } buf->free_buffer (buf); @@ -184,20 +167,28 @@ void *audio_decoder_loop (void *this_gen) { } void audio_decoder_init (xine_t *this) { - if (this->audio_out == NULL) - return; + if (this->audio_out == NULL) { + this->audio_finished = 1; + this->audio_fifo = NULL; + return; + } + this->audio_fifo = fifo_buffer_new (1500, 4096); pthread_create (&this->audio_thread, NULL, audio_decoder_loop, this) ; } void audio_decoder_stop (xine_t *this) { - this->audio_fifo->clear(this->audio_fifo); - if (this->cur_audio_decoder_plugin) { - this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); - this->cur_audio_decoder_plugin = NULL; + if (this->audio_fifo) { + + this->audio_fifo->clear(this->audio_fifo); + + if (this->cur_audio_decoder_plugin) { + this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); + this->cur_audio_decoder_plugin = NULL; + } } } @@ -206,13 +197,14 @@ void audio_decoder_shutdown (xine_t *this) { buf_element_t *buf; void *p; - this->audio_fifo->clear(this->audio_fifo); + if (this->audio_fifo) { + this->audio_fifo->clear(this->audio_fifo); - buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->type = BUF_CONTROL_QUIT; - this->audio_fifo->put (this->audio_fifo, buf); - - pthread_join (this->audio_thread, &p); + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + buf->type = BUF_CONTROL_QUIT; + this->audio_fifo->put (this->audio_fifo, buf); + + pthread_join (this->audio_thread, &p); + } } - |