1
mirror of https://github.com/mpv-player/mpv synced 2025-01-01 04:36:24 +01:00

demux_mkv, demux_lavf: don't select initial audio track

Remove code that tries to select audio track during demuxer
initialization from demux_mkv and demux_lavf. Just leave audio
disabled at that point; the higher-level select_audio() function will
call the demuxer to switch track later anyway.

Removing this unneeded code also fixes use of these demuxers as the
main demuxer with -audiofile. Before the automatic track selection
would have enabled an audio track (if the file had any); as the main
demuxer was not used for audio the unused packets from this enabled
track would accumulate until they reached queue size limits.
This commit is contained in:
Uoti Urpala 2011-04-02 22:39:01 +03:00
parent 1bda89eaba
commit e3631231a1
2 changed files with 3 additions and 36 deletions

View File

@ -357,12 +357,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
if (st->disposition & AV_DISPOSITION_DEFAULT)
sh_audio->default_track = 1;
if(mp_msg_test(MSGT_HEADER,MSGL_V) ) print_wave_header(sh_audio->wf, MSGL_V);
// select the first audio stream
if (!demuxer->audio->sh) {
demuxer->audio->id = i;
demuxer->audio->sh= demuxer->a_streams[i];
} else
st->discard= AVDISCARD_ALL;
st->discard= AVDISCARD_ALL;
stream_id = priv->audio_streams++;
break;
}
@ -611,8 +606,7 @@ static demuxer_t* demux_open_lavf(demuxer_t *demuxer){
mp_msg(MSGT_HEADER,MSGL_V,"LAVF: %d audio and %d video streams found\n",priv->audio_streams,priv->video_streams);
mp_msg(MSGT_HEADER,MSGL_V,"LAVF: build %d\n", LIBAVFORMAT_BUILD);
if(!priv->audio_streams) demuxer->audio->id=-2; // nosound
// else if(best_audio > 0 && demuxer->audio->id == -1) demuxer->audio->id=best_audio;
demuxer->audio->id = -2; // wait for higher-level code to select track
if(!priv->video_streams){
if(!priv->audio_streams){
mp_msg(MSGT_HEADER,MSGL_ERR,"LAVF: no audio or video headers found - broken file?\n");

View File

@ -1711,34 +1711,7 @@ static int demux_mkv_open(demuxer_t *demuxer)
demuxer->video->id = -2;
}
/* select audio track */
track = NULL;
if (track == NULL)
/* search for an audio track that has the 'default' flag set */
for (i = 0; i < mkv_d->num_tracks; i++)
if (mkv_d->tracks[i]->type == MATROSKA_TRACK_AUDIO
&& mkv_d->tracks[i]->default_track) {
track = mkv_d->tracks[i];
break;
}
if (track == NULL)
/* no track has the 'default' flag set */
/* let's take the first audio track */
for (i = 0; i < mkv_d->num_tracks; i++)
if (mkv_d->tracks[i]->type == MATROSKA_TRACK_AUDIO
&& mkv_d->tracks[i]->id >= 0) {
track = mkv_d->tracks[i];
break;
}
if (track && demuxer->a_streams[track->id]) {
demuxer->audio->id = track->id;
demuxer->audio->sh = demuxer->a_streams[track->id];
} else {
mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[mkv] No audio track found/wanted.\n");
demuxer->audio->id = -2;
}
demuxer->audio->id = -2; // wait for higher-level code to select track
if (s->end_pos == 0)
demuxer->seekable = 0;