mirror of
https://github.com/mpv-player/mpv
synced 2024-11-11 00:15:33 +01:00
demux_mkv: check for valid track in video/audio switching
When switching audio or video tracks, demux_mkv only checked that the new index fell in the range corresponding to tracks existing in the file being played. However, if the demuxer can not recognize the format of a track or detects an error, some of those tracks in the file may not be exported from the demuxer and are not visible to the rest of the player. Selecting such a track would cause a crash. Add checks skip such tracks when cycling to next track and switch to nosound instead if given an explicit track number corresponding to such a track.
This commit is contained in:
parent
f253de24af
commit
01fa34d537
@ -2494,9 +2494,16 @@ static int demux_mkv_control(demuxer_t *demuxer, int cmd, void *arg)
|
||||
int current_aid = demuxer->audio->id;
|
||||
if (current_aid < 0)
|
||||
current_aid = -1;
|
||||
if (new_aid == -1) // cycle to next
|
||||
new_aid = (current_aid + 2) % (mkv_d->num_audio_tracks + 1) - 1;
|
||||
if (new_aid < 0 || new_aid >= mkv_d->num_audio_tracks)
|
||||
if (new_aid == -1) { // cycle to next
|
||||
new_aid = current_aid;
|
||||
while (1) {
|
||||
new_aid = (new_aid + 2) % (mkv_d->num_audio_tracks + 1) - 1;
|
||||
if (new_aid == -1 || demuxer->a_streams[new_aid])
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (new_aid < 0 || new_aid >= mkv_d->num_audio_tracks ||
|
||||
!demuxer->a_streams[new_aid])
|
||||
new_aid = -2;
|
||||
*(int *) arg = new_aid;
|
||||
if (current_aid != new_aid)
|
||||
@ -2509,9 +2516,16 @@ static int demux_mkv_control(demuxer_t *demuxer, int cmd, void *arg)
|
||||
int current_vid = demuxer->video->id;
|
||||
if (current_vid < 0)
|
||||
current_vid = -1;
|
||||
if (new_vid == -1) // cycle to next
|
||||
new_vid = (current_vid + 2) % (mkv_d->num_video_tracks + 1) - 1;
|
||||
if (new_vid < 0 || new_vid >= mkv_d->num_video_tracks)
|
||||
if (new_vid == -1) { // cycle to next
|
||||
new_vid = current_vid;
|
||||
while (1) {
|
||||
new_vid = (new_vid + 2) % (mkv_d->num_video_tracks + 1) - 1;
|
||||
if (new_vid == -1 || demuxer->v_streams[new_vid])
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (new_vid < 0 || new_vid >= mkv_d->num_video_tracks ||
|
||||
!demuxer->v_streams[new_vid])
|
||||
new_vid = -2;
|
||||
*(int *) arg = new_vid;
|
||||
if (current_vid != new_vid)
|
||||
|
Loading…
Reference in New Issue
Block a user