mirror of
https://github.com/mpv-player/mpv
synced 2025-01-13 00:06:25 +01:00
core, demux: fix video index handling in stream switching
Fix bugs in the handling of stream index values in video stream
switching. This is similar to what commit 90bedd0b87
did for audio.
Also clean up the corresponding audio code a little bit.
This commit is contained in:
parent
5c731e2ea6
commit
df31b077b4
26
command.c
26
command.c
@ -991,8 +991,8 @@ static int mp_property_audio(m_option_t *prop, int action, void *arg,
|
||||
uninit_player(mpctx, INITIALIZED_AO | INITIALIZED_ACODEC);
|
||||
if (new_id != current_id && new_id >= 0) {
|
||||
sh_audio_t *sh2;
|
||||
sh2 = mpctx->d_audio->demuxer->a_streams[mpctx->demuxer->audio->id];
|
||||
sh2->ds = mpctx->demuxer->audio;
|
||||
sh2 = mpctx->d_audio->demuxer->a_streams[mpctx->d_audio->id];
|
||||
sh2->ds = mpctx->d_audio;
|
||||
mpctx->sh_audio = sh2;
|
||||
reinit_audio_chain(mpctx);
|
||||
}
|
||||
@ -1012,7 +1012,7 @@ static int mp_property_video(m_option_t *prop, int action, void *arg,
|
||||
int current_id, tmp;
|
||||
if (!mpctx->demuxer || !mpctx->d_video)
|
||||
return M_PROPERTY_UNAVAILABLE;
|
||||
current_id = mpctx->d_video->id;
|
||||
current_id = mpctx->sh_video ? mpctx->sh_video->vid : -2;
|
||||
|
||||
switch (action) {
|
||||
case M_PROPERTY_GET:
|
||||
@ -1040,22 +1040,18 @@ static int mp_property_video(m_option_t *prop, int action, void *arg,
|
||||
tmp = *((int *) arg);
|
||||
else
|
||||
tmp = -1;
|
||||
opts->video_id = demuxer_switch_video(mpctx->d_video->demuxer, tmp);
|
||||
if (opts->video_id == -2
|
||||
|| (opts->video_id > -1 && mpctx->d_video->id != current_id
|
||||
&& current_id != -2))
|
||||
int new_id = demuxer_switch_video(mpctx->d_video->demuxer, tmp);
|
||||
if (new_id != current_id)
|
||||
uninit_player(mpctx, INITIALIZED_VCODEC |
|
||||
(mpctx->opts.fixed_vo && opts->video_id != -2 ? 0 : INITIALIZED_VO));
|
||||
if (opts->video_id > -1 && mpctx->d_video->id != current_id) {
|
||||
(opts->fixed_vo && new_id >= 0 ? 0 : INITIALIZED_VO));
|
||||
if (new_id != current_id && new_id >= 0) {
|
||||
sh_video_t *sh2;
|
||||
sh2 = mpctx->d_video->demuxer->v_streams[mpctx->d_video->id];
|
||||
if (sh2) {
|
||||
sh2->ds = mpctx->d_video;
|
||||
mpctx->sh_video = sh2;
|
||||
reinit_video_chain(mpctx);
|
||||
}
|
||||
sh2->ds = mpctx->d_video;
|
||||
mpctx->sh_video = sh2;
|
||||
reinit_video_chain(mpctx);
|
||||
}
|
||||
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_TRACK=%d\n", opts->video_id);
|
||||
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_TRACK=%d\n", new_id);
|
||||
return M_PROPERTY_OK;
|
||||
|
||||
default:
|
||||
|
@ -1351,11 +1351,15 @@ int demuxer_switch_audio(demuxer_t *demuxer, int index)
|
||||
int demuxer_switch_video(demuxer_t *demuxer, int index)
|
||||
{
|
||||
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
|
||||
if (res == DEMUXER_CTRL_NOTIMPL) {
|
||||
struct sh_video *sh_video = demuxer->video->sh;
|
||||
return sh_video ? sh_video->vid : -2;
|
||||
}
|
||||
if (demuxer->video->id >= 0) {
|
||||
struct sh_video *sh_video = demuxer->v_streams[demuxer->video->id];
|
||||
demuxer->video->sh = sh_video;
|
||||
index = sh_video->vid; // internal MPEG demuxers don't set it right
|
||||
} else
|
||||
demuxer->video->sh = NULL;
|
||||
return index;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user