summaryrefslogtreecommitdiffstats
path: root/libmpdemux
diff options
context:
space:
mode:
authornicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-11-19 23:36:14 +0000
committernicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-11-19 23:36:14 +0000
commit07ccc9193c01d04533c06d15c96e1100c412bce9 (patch)
treedef0243cfda650fe96e3f7b750f21fc3d2277b46 /libmpdemux
parent6fe799fce27157d5b25f14bd74ceabaf5a69f788 (diff)
downloadmpv-07ccc9193c01d04533c06d15c96e1100c412bce9.tar.bz2
mpv-07ccc9193c01d04533c06d15c96e1100c412bce9.tar.xz
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21088 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/demux_ts.c112
1 files changed, 33 insertions, 79 deletions
diff --git a/libmpdemux/demux_ts.c b/libmpdemux/demux_ts.c
index 879dc429ae..30da51da49 100644
--- a/libmpdemux/demux_ts.c
+++ b/libmpdemux/demux_ts.c
@@ -3188,79 +3188,33 @@ static int demux_ts_control(demuxer_t *demuxer, int cmd, void *arg)
switch(cmd)
{
case DEMUXER_CTRL_SWITCH_AUDIO:
+ case DEMUXER_CTRL_SWITCH_VIDEO:
{
- sh_audio_t *sh_a = NULL;
+ void *sh = NULL;
int i, n;
+ int reftype, areset = 0, vreset = 0;
+ demux_stream_t *ds;
- n = *((int*)arg);
- if(n == -2)
+ if(cmd == DEMUXER_CTRL_SWITCH_VIDEO)
{
- reset_fifos(priv, 1, 0, 0);
- demuxer->audio->id = -2;
- demuxer->audio->sh = NULL;
- ds_free_packs(demuxer->audio);
- *((int*)arg) = demuxer->audio->id;
- return DEMUXER_CTRL_OK;
- }
-
- if(n < 0)
- {
- for(i = 0; i < 8192; i++)
- {
- if(priv->ts.streams[i].id == demuxer->audio->id && priv->ts.streams[i].type == TYPE_AUDIO)
- break;
- }
-
- while(!sh_a)
- {
- i = (i+1) % 8192;
- if(priv->ts.streams[i].type == TYPE_AUDIO)
- {
- if(priv->ts.streams[i].id == demuxer->audio->id) //we made a complete loop
- break;
- sh_a = (sh_audio_t*)priv->ts.streams[i].sh;
- }
- }
- }
- else if(n <= priv->last_aid)
- {
- for(i = 0; i < 8192; i++)
- {
- if(priv->ts.streams[i].id == n && priv->ts.streams[i].type == TYPE_AUDIO)
- {
- sh_a = (sh_audio_t*)priv->ts.streams[i].sh;
- break;
- }
- }
+ reftype = TYPE_VIDEO;
+ ds = demuxer->video;
+ vreset = 1;
}
-
- if(sh_a)
+ else
{
- if(demuxer->audio->id != priv->ts.streams[i].id)
- reset_fifos(priv, 1, 0, 0);
- demuxer->audio->id = priv->ts.streams[i].id;
- demuxer->audio->sh = sh_a;
- ds_free_packs(demuxer->audio);
- mp_msg(MSGT_DEMUX, MSGL_V, "\r\ndemux_ts, switched to audio pid %d, id: %d, sh: %p\r\n", i, demuxer->audio->id, sh_a);
+ reftype = TYPE_AUDIO;
+ ds = demuxer->audio;
+ areset = 1;
}
-
- *((int*)arg) = demuxer->audio->id;
- return DEMUXER_CTRL_OK;
- }
-
- case DEMUXER_CTRL_SWITCH_VIDEO:
- {
- sh_video_t *sh_v = NULL;
- int i, n;
-
n = *((int*)arg);
if(n == -2)
{
- reset_fifos(priv, 0, 1, 0);
- demuxer->video->id = -2;
- demuxer->video->sh = NULL;
- ds_free_packs(demuxer->video);
- *((int*)arg) = demuxer->video->id;
+ reset_fifos(priv, areset, vreset, 0);
+ ds->id = -2;
+ ds->sh = NULL;
+ ds_free_packs(ds);
+ *((int*)arg) = ds->id;
return DEMUXER_CTRL_OK;
}
@@ -3268,44 +3222,44 @@ static int demux_ts_control(demuxer_t *demuxer, int cmd, void *arg)
{
for(i = 0; i < 8192; i++)
{
- if(priv->ts.streams[i].id == demuxer->video->id && priv->ts.streams[i].type == TYPE_VIDEO)
+ if(priv->ts.streams[i].id == ds->id && priv->ts.streams[i].type == reftype)
break;
}
- while(!sh_v)
+ while(!sh)
{
i = (i+1) % 8192;
- if(priv->ts.streams[i].type == TYPE_VIDEO)
+ if(priv->ts.streams[i].type == reftype)
{
- if(priv->ts.streams[i].id == demuxer->video->id) //we made a complete loop
+ if(priv->ts.streams[i].id == ds->id) //we made a complete loop
break;
- sh_v = (sh_video_t*)priv->ts.streams[i].sh;
+ sh = priv->ts.streams[i].sh;
}
}
}
- else if(n <= priv->last_vid)
+ else if(n <= priv->last_aid)
{
for(i = 0; i < 8192; i++)
{
- if(priv->ts.streams[i].id == n && priv->ts.streams[i].type == TYPE_VIDEO)
+ if(priv->ts.streams[i].id == n && priv->ts.streams[i].type == reftype)
{
- sh_v = (sh_video_t*)priv->ts.streams[i].sh;
+ sh = priv->ts.streams[i].sh;
break;
}
}
}
- if(sh_v)
+ if(sh)
{
- if(demuxer->video->id != priv->ts.streams[i].id)
- reset_fifos(priv, 0, 1, 0);
- demuxer->video->id = priv->ts.streams[i].id;
- demuxer->video->sh = sh_v;
- ds_free_packs(demuxer->video);
- mp_msg(MSGT_DEMUX, MSGL_V, "\r\ndemux_ts, switched to video pid %d, id: %d, sh: %p\r\n", i, demuxer->video->id, sh_v);
+ if(ds->id != priv->ts.streams[i].id)
+ reset_fifos(priv, areset, vreset, 0);
+ ds->id = priv->ts.streams[i].id;
+ ds->sh = sh;
+ ds_free_packs(ds);
+ mp_msg(MSGT_DEMUX, MSGL_V, "\r\ndemux_ts, switched to audio pid %d, id: %d, sh: %p\r\n", i, ds->id, sh);
}
- *((int*)arg) = demuxer->video->id;
+ *((int*)arg) = ds->id;
return DEMUXER_CTRL_OK;
}