Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make sure passthru flag is in sync between video decoder and audio fr…

…amework

When entering LiveTV with timestretch enabled via playback group, audio would be broken if watching a channel with AC3 content.
Reason being, audio is set for timestretch, but digital passthrough isn't disabled. We now make sure digital passthrough is disabled should timestretch had been activated earlier on.

Additionally, add the ability to cancel timestretch and audio processing should we revert to a timestretch factor of 1.0. This will only work if no reconfigure is done in between.

Fixes #10612 part 2
  • Loading branch information...
commit c2fccb545d02808b3d16fb73f52aa92ea75ea719 1 parent f7fc68c
@jyavenard jyavenard authored
View
31 mythtv/libs/libmyth/audio/audiooutputbase.cpp
@@ -104,7 +104,7 @@ AudioOutputBase::AudioOutputBase(const AudioSettings &settings) :
memory_corruption_test2(0xdeadbeef),
memory_corruption_test3(0xdeadbeef),
m_configure_succeeded(false),m_length_last_data(0),
- m_spdifenc(NULL)
+ m_spdifenc(NULL), m_forcedprocessing(false)
{
src_in = (float *)AOALIGN(src_in_buf);
memset(&src_data, 0, sizeof(SRC_DATA));
@@ -321,16 +321,33 @@ void AudioOutputBase::SetStretchFactorLocked(float lstretchfactor)
int channels = needs_upmix || needs_downmix ?
configured_channels : source_channels;
- if (channels < 1 || channels > 8)
+ if (channels < 1 || channels > 8 || !m_configure_succeeded)
return;
+ bool willstretch = stretchfactor < 0.99f || stretchfactor > 1.01f;
eff_stretchfactor = (int)(100000.0f * lstretchfactor + 0.5);
+
if (pSoundStretch)
{
- VBGENERAL(QString("Changing time stretch to %1").arg(stretchfactor));
- pSoundStretch->setTempo(stretchfactor);
+ if (!willstretch && m_forcedprocessing)
+ {
+ m_forcedprocessing = false;
+ processing = false;
+ delete pSoundStretch;
+ pSoundStretch = NULL;
+ VBGENERAL(QString("Cancelling time stretch"));
+ bytes_per_frame = m_previousbpf;
+ waud = raud = 0;
+ reset_active.Ref();
+ }
+ else
+ {
+ VBGENERAL(QString("Changing time stretch to %1")
+ .arg(stretchfactor));
+ pSoundStretch->setTempo(stretchfactor);
+ }
}
- else if (stretchfactor != 1.0f)
+ else if (willstretch)
{
VBGENERAL(QString("Using time stretch %1").arg(stretchfactor));
pSoundStretch = new soundtouch::SoundTouch();
@@ -344,6 +361,8 @@ void AudioOutputBase::SetStretchFactorLocked(float lstretchfactor)
if (!processing)
{
processing = true;
+ m_forcedprocessing = true;
+ m_previousbpf = bytes_per_frame;
bytes_per_frame = source_channels *
AudioOutputSettings::SampleSize(FORMAT_FLT);
waud = raud = 0;
@@ -594,7 +613,7 @@ void AudioOutputBase::Reconfigure(const AudioSettings &orig_settings)
waud = raud = 0;
reset_active.Clear();
- actually_paused = processing = false;
+ actually_paused = processing = m_forcedprocessing = false;
channels = settings.channels;
source_channels = lsource_channels;
View
4 mythtv/libs/libmyth/audio/audiooutputbase.h
@@ -282,6 +282,10 @@ class AudioOutputBase : public AudioOutput, public MThread
// SPDIF Encoder for digital passthrough
SPDIFEncoder *m_spdifenc;
+
+ // Flag indicating if SetStretchFactor enabled audio float processing
+ bool m_forcedprocessing;
+ int m_previousbpf;
};
#endif
View
30 mythtv/libs/libmythtv/mythplayer.cpp
@@ -2316,9 +2316,6 @@ void MythPlayer::VideoStart(void)
videoOutput, fr_int, rf_int, m_double_framerate);
}
- if (isDummy)
- ChangeSpeed();
-
InitAVSync();
videosync->Start();
}
@@ -3464,15 +3461,7 @@ void MythPlayer::ChangeSpeed(void)
if (normal_speed && audio.HasAudioOut())
{
audio.SetStretchFactor(play_speed);
- if (decoder)
- {
- bool disable = (play_speed < 0.99f) || (play_speed > 1.01f);
- LOG(VB_PLAYBACK, LOG_INFO, LOC +
- QString("Stretch Factor %1, %2 passthru ")
- .arg(audio.GetStretchFactor())
- .arg((disable) ? "disable" : "allow"));
- decoder->SetDisablePassThrough(disable);
- }
+ syncWithAudioStretch();
}
}
@@ -4901,7 +4890,7 @@ void MythPlayer::SetDecoder(DecoderBase *dec)
}
decoder_change_lock.unlock();
}
-
+ syncWithAudioStretch();
totalDecoderPause = false;
}
@@ -5098,6 +5087,21 @@ void MythPlayer::SaveTotalFrames(void)
decoder->SaveTotalFrames();
}
+void MythPlayer::syncWithAudioStretch()
+{
+ if (decoder && audio.HasAudioOut())
+ {
+ float stretch = audio.GetStretchFactor();
+ bool disable = (stretch < 0.99f) || (stretch > 1.01f);
+ LOG(VB_PLAYBACK, LOG_INFO, LOC +
+ QString("Stretch Factor %1, %2 passthru ")
+ .arg(audio.GetStretchFactor())
+ .arg((disable) ? "disable" : "allow"));
+ decoder->SetDisablePassThrough(disable);
+ }
+ return;
+}
+
static unsigned dbg_ident(const MythPlayer *player)
{
static QMutex dbg_lock;
View
3  mythtv/libs/libmythtv/mythplayer.h
@@ -783,6 +783,9 @@ class MTV_PUBLIC MythPlayer
// Debugging variables
Jitterometer *output_jmeter;
+
+ private:
+ void syncWithAudioStretch();
};
#endif
Please sign in to comment.
Something went wrong with that request. Please try again.