Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/sanear.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Marsev <alex.marsev@gmail.com>2015-10-17 02:00:58 +0300
committerAlex Marsev <alex.marsev@gmail.com>2015-10-17 08:02:08 +0300
commitdfee95c0b7d941b70f730021e776cdcdb69fe187 (patch)
tree54c72cf02b3fdb465e2a6e802b35139e81f4da92
parent0719663687dc698138864abbfdd7a81f1690b080 (diff)
Add guided reclock method to AudioRenderer
In preparation for IGuidedReclock interface.
-rw-r--r--src/AudioRenderer.cpp18
-rw-r--r--src/AudioRenderer.h4
2 files changed, 19 insertions, 3 deletions
diff --git a/src/AudioRenderer.cpp b/src/AudioRenderer.cpp
index e2a0204..b0bdd3f 100644
--- a/src/AudioRenderer.cpp
+++ b/src/AudioRenderer.cpp
@@ -113,9 +113,19 @@ namespace SaneAudioRenderer
DspChunk::ToFormat(m_device->GetDspFormat(), chunk);
}
- // Apply rate corrections (rate matching and clock slaving).
- if (m_device && !m_device->IsBitstream() && m_device->IsRealtime() && m_state == State_Running)
- ApplyRateCorrection(chunk);
+ if (m_device && !m_device->IsBitstream() && m_state == State_Running)
+ {
+ if (m_device->IsRealtime())
+ {
+ // Apply rate corrections (rate matching and clock slaving).
+ ApplyRateCorrection(chunk);
+ }
+ else if (REFERENCE_TIME offset = std::atomic_exchange(&m_guidedReclockOffset, 0))
+ {
+ // Apply guided reclock adjustment.
+ m_dspRate.Adjust(-offset);
+ }
+ }
// Don't deny the allocator its right to reuse IMediaSample while the chunk is hanging in the buffer.
if (m_device && m_device->IsRealtime())
@@ -448,6 +458,7 @@ namespace SaneAudioRenderer
if (m_device)
{
+ m_guidedReclockOffset = 0;
m_myClock.SlaveClockToAudio(m_device->GetClock(), m_startTime + m_startClockOffset);
m_clockCorrection = 0;
m_device->Start();
@@ -513,6 +524,7 @@ namespace SaneAudioRenderer
CAutoLock objectLock(this);
assert(m_device);
assert(!m_device->IsBitstream());
+ assert(m_device->IsRealtime());
assert(m_state == State_Running);
if (chunk.IsEmpty())
diff --git a/src/AudioRenderer.h b/src/AudioRenderer.h
index 454ae58..a09de1b 100644
--- a/src/AudioRenderer.h
+++ b/src/AudioRenderer.h
@@ -56,6 +56,8 @@ namespace SaneAudioRenderer
const AudioDevice* GetAudioDevice();
std::vector<std::wstring> GetActiveProcessors();
+ void TakeGuidedReclock(REFERENCE_TIME offset) { m_guidedReclockOffset += offset; }
+
private:
void CheckDeviceSettings();
@@ -121,5 +123,7 @@ namespace SaneAudioRenderer
std::atomic<float> m_volume = 1.0f;
std::atomic<float> m_balance = 0.0f;
double m_rate = 1.0;
+
+ std::atomic<REFERENCE_TIME> m_guidedReclockOffset = 0;
};
}