Skip to content

Commit

Permalink
prefer matching language to the default audio track in auto selection
Browse files Browse the repository at this point in the history
From http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2008-February/046403.html
Streams marked as default are to be selected for playback (or whatever
else) if the user does not have any other preference (like language, or
an exact stream id).
  • Loading branch information
dekarl committed Dec 16, 2012
1 parent 55591ed commit 0e155f7
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions mythtv/libs/libmythtv/avformatdecoder.cpp
Expand Up @@ -3987,18 +3987,6 @@ int AvFormatDecoder::AutoSelectAudioTrack(void)
int selTrack = (1 == numStreams) ? 0 : -1;
int wlang = wtrack.language;

if (selTrack < 0 && numStreams)
{
LOG(VB_AUDIO, LOG_INFO, LOC + "Trying to select default track");
for (uint i = 0; i < atracks.size(); i++) {
int idx = atracks[i].av_stream_index;
if (ic->streams[idx]->disposition & AV_DISPOSITION_DEFAULT)
{
selTrack = i;
break;
}
}
}

if ((selTrack < 0) && (wtrack.av_substream_index >= 0))
{
Expand Down Expand Up @@ -4114,6 +4102,22 @@ int AvFormatDecoder::AutoSelectAudioTrack(void)
selTrack = filter_max_ch(ic, atracks, flang);
}
}

// could not select track based on user preferences (language)
// try to select the default track
if (selTrack < 0 && numStreams)
{
LOG(VB_AUDIO, LOG_INFO, LOC + "Trying to select default track");
for (uint i = 0; i < atracks.size(); i++) {
int idx = atracks[i].av_stream_index;
if (ic->streams[idx]->disposition & AV_DISPOSITION_DEFAULT)
{
selTrack = i;
break;
}
}
}

// try to get best track for any language
if (selTrack < 0)
{
Expand Down

0 comments on commit 0e155f7

Please sign in to comment.