changeset 26089:e2f35d90ad39

Set audio->sh correctly when switching audio tracks. The same for video tracks. Demuxers almost never update audio->sh or sub->sh when swithing tracks. It is especially bad when switching to no sound, and results in "too many audio packets" error.
author eugeni
date Fri, 29 Feb 2008 17:25:48 +0000
parents 12904c37c798
children c585e2ad8ebf
files libmpdemux/demuxer.c
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demuxer.c	Fri Feb 29 17:25:47 2008 +0000
+++ b/libmpdemux/demuxer.c	Fri Feb 29 17:25:48 2008 +0000
@@ -1142,6 +1142,10 @@
     int res = demux_control(demuxer, DEMUXER_CTRL_SWITCH_AUDIO, &index);
     if (res == DEMUXER_CTRL_NOTIMPL)
       index = demuxer->audio->id;
+    if (demuxer->audio->id >= 0)
+      demuxer->audio->sh = demuxer->a_streams[demuxer->audio->id];
+    else
+      demuxer->audio->sh = NULL;
     return index;
 }
 
@@ -1149,6 +1153,10 @@
     int res = demux_control(demuxer, DEMUXER_CTRL_SWITCH_VIDEO, &index);
     if (res == DEMUXER_CTRL_NOTIMPL)
       index = demuxer->video->id;
+    if (demuxer->video->id >= 0)
+      demuxer->video->sh = demuxer->v_streams[demuxer->video->id];
+    else
+      demuxer->video->sh = NULL;
     return index;
 }