Mercurial > mplayer.hg
changeset 21072:e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
author | nicodvb |
---|---|
date | Sun, 19 Nov 2006 23:36:14 +0000 |
parents | 7104020d9f0d |
children | 8f6483942b59 |
files | libmpdemux/demux_ts.c |
diffstat | 1 files changed, 37 insertions(+), 83 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/demux_ts.c Sun Nov 19 23:20:06 2006 +0000 +++ b/libmpdemux/demux_ts.c Sun Nov 19 23:36:14 2006 +0000 @@ -3188,18 +3188,33 @@ 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; + if(cmd == DEMUXER_CTRL_SWITCH_VIDEO) + { + reftype = TYPE_VIDEO; + ds = demuxer->video; + vreset = 1; + } + else + { + reftype = TYPE_AUDIO; + ds = demuxer->audio; + areset = 1; + } n = *((int*)arg); if(n == -2) { - reset_fifos(priv, 1, 0, 0); - demuxer->audio->id = -2; - demuxer->audio->sh = NULL; - ds_free_packs(demuxer->audio); - *((int*)arg) = demuxer->audio->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; } @@ -3207,18 +3222,18 @@ { for(i = 0; i < 8192; i++) { - if(priv->ts.streams[i].id == demuxer->audio->id && priv->ts.streams[i].type == TYPE_AUDIO) + if(priv->ts.streams[i].id == ds->id && priv->ts.streams[i].type == reftype) break; } - while(!sh_a) + while(!sh) { i = (i+1) % 8192; - if(priv->ts.streams[i].type == TYPE_AUDIO) + if(priv->ts.streams[i].type == reftype) { - if(priv->ts.streams[i].id == demuxer->audio->id) //we made a complete loop + if(priv->ts.streams[i].id == ds->id) //we made a complete loop break; - sh_a = (sh_audio_t*)priv->ts.streams[i].sh; + sh = priv->ts.streams[i].sh; } } } @@ -3226,86 +3241,25 @@ { for(i = 0; i < 8192; i++) { - if(priv->ts.streams[i].id == n && priv->ts.streams[i].type == TYPE_AUDIO) + if(priv->ts.streams[i].id == n && priv->ts.streams[i].type == reftype) { - sh_a = (sh_audio_t*)priv->ts.streams[i].sh; + sh = priv->ts.streams[i].sh; break; } } } - if(sh_a) - { - 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); - } - - *((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; - return DEMUXER_CTRL_OK; - } - - if(n < 0) + if(sh) { - for(i = 0; i < 8192; i++) - { - if(priv->ts.streams[i].id == demuxer->video->id && priv->ts.streams[i].type == TYPE_VIDEO) - break; - } - - while(!sh_v) - { - i = (i+1) % 8192; - if(priv->ts.streams[i].type == TYPE_VIDEO) - { - if(priv->ts.streams[i].id == demuxer->video->id) //we made a complete loop - break; - sh_v = (sh_video_t*)priv->ts.streams[i].sh; - } - } + 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); } - else if(n <= priv->last_vid) - { - for(i = 0; i < 8192; i++) - { - if(priv->ts.streams[i].id == n && priv->ts.streams[i].type == TYPE_VIDEO) - { - sh_v = (sh_video_t*)priv->ts.streams[i].sh; - break; - } - } - } - - if(sh_v) - { - 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); - } - - *((int*)arg) = demuxer->video->id; + + *((int*)arg) = ds->id; return DEMUXER_CTRL_OK; }