From 078eade9b4a427497250ca567ebe1865ecd47a8f Mon Sep 17 00:00:00 2001 From: Torsten Jager Date: Mon, 22 Aug 2011 11:49:01 +0200 Subject: Audio crash fix Audio decoder loop creates a sorted map of available audio channels on the fly. If neither user nor dvdnav intervene, it will pass the first (= lowest index) audio channel to decoders. Now imagine a TV recording with 2 audio channels: audio.0: eac3 5.1 (fra) audio.1: eac3 stereo (qaa) By chance, first audio frame to be demuxed is for channel #1. Track map will be [0]: eac3, channel 1 Audio loop opens ffmpeg audio decoder / stereo out. Fine. Then, first frame for channel #0 comes in. [0]: eac3, channel 0 [1]: eac3, channel 1 Both are same codec, so audio loop just switches to channel 0 without further notice. Audio decoder then runs into a mem leak, or worse, crashes audio out who still thinks we're only stereo. Whenever we insert something at track map index 0, and its going to be auto-selected later, reset current codec type. This forces a clean decoder/output switch. --- src/xine-engine/audio_decoder.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/xine-engine/audio_decoder.c b/src/xine-engine/audio_decoder.c index 3d5ef7e6f..10c20f231 100644 --- a/src/xine-engine/audio_decoder.c +++ b/src/xine-engine/audio_decoder.c @@ -283,6 +283,9 @@ static void *audio_decoder_loop (void *stream_gen) { } stream->audio_track_map[i] = buf->type; stream->audio_track_map_entries++; + /* implicit channel change - reopen decoder below */ + if ((i == 0) && (audio_channel_user == -1) && (stream->audio_channel_auto < 0)) + stream->audio_decoder_streamtype = -1; ui_event.type = XINE_EVENT_UI_CHANNELS_CHANGED; ui_event.data_length = 0; -- cgit v1.2.3