diff options
author | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-05-22 10:38:55 +0300 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-05-22 10:38:55 +0300 |
commit | 9b94b3fb309ae9c0817485b58125d92dbe3ff28d (patch) | |
tree | bbb0286035966f341f7ac292178adc584586b547 /libmpdemux/demux_mkv.c | |
parent | fc39d484653e40f9b79d33a595cfd550d61a6a34 (diff) | |
download | mpv-9b94b3fb309ae9c0817485b58125d92dbe3ff28d.tar.bz2 mpv-9b94b3fb309ae9c0817485b58125d92dbe3ff28d.tar.xz |
demux_mkv: support switching to/from -nosound
Allow audio stream switching to turn off sound or enable it, and also
include nosound as one of the values cycled through when stepping to
the next audio stream.
Diffstat (limited to 'libmpdemux/demux_mkv.c')
-rw-r--r-- | libmpdemux/demux_mkv.c | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/libmpdemux/demux_mkv.c b/libmpdemux/demux_mkv.c index 97e0e3866b..d4a3a8994a 100644 --- a/libmpdemux/demux_mkv.c +++ b/libmpdemux/demux_mkv.c @@ -2609,24 +2609,19 @@ static int demux_mkv_control(demuxer_t *demuxer, int cmd, void *arg) *((int *) arg) = (int) (100 * mkv_d->last_pts / mkv_d->duration); return DEMUXER_CTRL_OK; - case DEMUXER_CTRL_SWITCH_AUDIO: - if (demuxer->audio && demuxer->audio->sh) { - sh_audio_t *sh = demuxer->a_streams[demuxer->audio->id]; - int aid = *(int *) arg; - if (aid < 0) - aid = (sh->aid + 1) % mkv_d->num_audio_tracks; - if (aid != sh->aid) { - mkv_track_t *track = - find_track_by_num(mkv_d, aid, MATROSKA_TRACK_AUDIO); - if (track) { - demuxer->audio->id = track->id; - sh = demuxer->a_streams[demuxer->audio->id]; - ds_free_packs(demuxer->audio); - } - } - *(int *) arg = sh->aid; - } else - *(int *) arg = -2; + case DEMUXER_CTRL_SWITCH_AUDIO:; + int new_aid = *(int *) 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) + new_aid = -2; + *(int *) arg = new_aid; + if (current_aid != new_aid) + ds_free_packs(demuxer->audio); + demuxer->audio->id = new_aid; return DEMUXER_CTRL_OK; default: |