From 6679a926f60da6ef69a84cb4b8039fe632a879dd Mon Sep 17 00:00:00 2001 From: Guenter Bartsch Date: Tue, 1 May 2001 00:55:23 +0000 Subject: added audio track/channel detection CVS patchset: 51 CVS date: 2001/05/01 00:55:23 --- src/xine-engine/audio_decoder.c | 68 ++++++++++++++++++++++++++++++++++------- src/xine-engine/video_decoder.c | 4 +-- src/xine-engine/xine_internal.h | 4 ++- 3 files changed, 62 insertions(+), 14 deletions(-) diff --git a/src/xine-engine/audio_decoder.c b/src/xine-engine/audio_decoder.c index cac4f56dd..209aef15c 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.6 2001/04/29 14:32:11 guenter Exp $ + * $Id: audio_decoder.c,v 1.7 2001/05/01 00:55:23 guenter Exp $ * * * functions that implement audio decoding @@ -34,6 +34,7 @@ void *audio_decoder_loop (void *this_gen) { buf_element_t *buf; xine_t *this = (xine_t *) this_gen; int running = 1; + int i,j; audio_decoder_t *decoder; while (running) { @@ -56,6 +57,11 @@ void *audio_decoder_loop (void *this_gen) { 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_AUDIO_AC3: @@ -63,22 +69,62 @@ void *audio_decoder_loop (void *this_gen) { case BUF_AUDIO_LPCM: case BUF_AUDIO_AVI: - decoder = this->audio_decoder_plugins [(buf->type>>16) & 0xFF]; - - if (decoder) { - if (this->cur_audio_decoder_plugin != decoder) { + printf ("audio_decoder: got an audio buffer, type %08x\n", buf->type); + + /* update track map */ + + i = 0; + while ( (iaudio_track_map_entries) && (this->audio_track_map[i]type) ) + i++; + + if ( (i==this->audio_track_map_entries) || (this->audio_track_map[i] != buf->type) ) { + + printf ("audio_decoder: inserting audio type %08x into track map\n", 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++; - if (this->cur_audio_decoder_plugin) + if (i<=this->audio_channel) { + printf ("audio_decoder: resetting audio decoder because of new channel\n"); + + 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 */ + + if (buf->type == this->audio_track_map[this->audio_channel]) { + + int streamtype = (buf->type>>16) & 0xFF; + + printf ("audio_decoder_c: buffer is from the right track => decode it\n"); + - this->cur_audio_decoder_plugin = decoder; - this->cur_audio_decoder_plugin->init (this->cur_audio_decoder_plugin, this->audio_out); + decoder = this->audio_decoder_plugins [streamtype]; + 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); + + 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); } - + break; case BUF_CONTROL_END: diff --git a/src/xine-engine/video_decoder.c b/src/xine-engine/video_decoder.c index 255c69f6d..e24d4ad4b 100644 --- a/src/xine-engine/video_decoder.c +++ b/src/xine-engine/video_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: video_decoder.c,v 1.10 2001/04/30 23:07:00 guenter Exp $ + * $Id: video_decoder.c,v 1.11 2001/05/01 00:55:23 guenter Exp $ * */ @@ -62,7 +62,7 @@ void *video_decoder_loop (void *this_gen) { streamtype = (buf->type>>16) & 0xFF; - printf ("video_decoder: processing buffer %d, type= %08x (%02x), size=%d\n",buf, buf->type,streamtype, buf->size); + printf ("video_decoder: processing buffer type= %08x (%02x), size=%d\n", buf->type,streamtype, buf->size); decoder = this->video_decoder_plugins [streamtype]; diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h index c446d1e82..d0a3a8f77 100644 --- a/src/xine-engine/xine_internal.h +++ b/src/xine-engine/xine_internal.h @@ -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: xine_internal.h,v 1.16 2001/04/30 23:07:00 guenter Exp $ + * $Id: xine_internal.h,v 1.17 2001/05/01 00:55:23 guenter Exp $ * */ @@ -147,6 +147,8 @@ typedef struct xine_s { audio_decoder_t *audio_decoder_plugins[DECODER_PLUGIN_MAX]; int num_audio_decoder_plugins; audio_decoder_t *cur_audio_decoder_plugin; + uint32_t audio_track_map[50]; + int audio_track_map_entries; int audio_finished; gui_status_callback_func_t status_callback; -- cgit v1.2.3