Skip to content

Commit

Permalink
AvFormatDecoder::AutoSelectAudioTrack(): simplify conditional logic
Browse files Browse the repository at this point in the history
The only difference is it will no longer produce a log message saying
"0 available audio streams"
  • Loading branch information
ulmus-scott authored and bennettpeter committed Jan 6, 2025
1 parent d3b6c3e commit ba8c80d
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions mythtv/libs/libmythtv/decoders/avformatdecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4162,6 +4162,9 @@ int AvFormatDecoder::AutoSelectAudioTrack(void)
int &ctrack = m_currentTrack[kTrackTypeAudio];

uint numStreams = atracks.size();
int selTrack = -1;
if (numStreams > 0)
{
if ((ctrack >= 0) && (ctrack < (int)numStreams))
return ctrack; // audio already selected

Expand All @@ -4176,7 +4179,12 @@ int AvFormatDecoder::AutoSelectAudioTrack(void)
);
}

int selTrack = (1 == numStreams) ? 0 : -1;
if (1 == numStreams)
{
selTrack = 0;
}
else
{
int wlang = wtrack.m_language;

if ((selTrack < 0) && (wtrack.m_av_substream_index >= 0))
Expand All @@ -4197,7 +4205,7 @@ int AvFormatDecoder::AutoSelectAudioTrack(void)
}
}

if ((selTrack < 0) && wlang >= -1 && numStreams)
if ((selTrack < 0) && wlang >= -1)
{
LOG(VB_AUDIO, LOG_INFO, LOC + "Trying to reselect audio track");
// Try to reselect user selected audio stream.
Expand All @@ -4216,7 +4224,7 @@ int AvFormatDecoder::AutoSelectAudioTrack(void)
}
}

if (selTrack < 0 && numStreams)
if (selTrack < 0)
{
LOG(VB_AUDIO, LOG_INFO, LOC + "Trying to select audio track (w/lang)");

Expand Down Expand Up @@ -4339,6 +4347,8 @@ int AvFormatDecoder::AutoSelectAudioTrack(void)
selTrack = filter_max_ch(m_ic, atracks, flang);
}
}
}
}

if (selTrack < 0)
{
Expand Down

0 comments on commit ba8c80d

Please sign in to comment.