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>2016-01-27 08:55:36 +0300
committerAlex Marsev <alex.marsev@gmail.com>2016-01-27 09:11:52 +0300
commitad977e1db88b955eb424158fc808a5fc3f51d037 (patch)
tree7e4f36a4b79b7c570b461034cbc3d312bfc6b043
parent8659c969d393894ced711060f69308b20c2cf539 (diff)
Request device buffer size only once
-rw-r--r--src/AudioDevice.h8
-rw-r--r--src/AudioDeviceEvent.cpp3
-rw-r--r--src/AudioDeviceManager.cpp4
-rw-r--r--src/AudioDevicePush.cpp12
4 files changed, 14 insertions, 13 deletions
diff --git a/src/AudioDevice.h b/src/AudioDevice.h
index 27f6905..3c73970 100644
--- a/src/AudioDevice.h
+++ b/src/AudioDevice.h
@@ -20,8 +20,12 @@ namespace SaneAudioRenderer
SharedWaveFormat waveFormat;
DspFormat dspFormat;
+
uint32_t bufferDuration;
- REFERENCE_TIME latency;
+
+ REFERENCE_TIME deviceLatency;
+ UINT32 deviceBufferSize;
+
bool exclusive;
bool bitstream;
bool eventMode;
@@ -58,7 +62,7 @@ namespace SaneAudioRenderer
SharedWaveFormat GetWaveFormat() const { return m_backend->waveFormat; }
DspFormat GetDspFormat() const { return m_backend->dspFormat; }
uint32_t GetBufferDuration() const { return m_backend->bufferDuration; }
- REFERENCE_TIME GetStreamLatency() const { return m_backend->latency; }
+ REFERENCE_TIME GetStreamLatency() const { return m_backend->deviceLatency; }
bool IsExclusive() const { return m_backend->exclusive; }
diff --git a/src/AudioDeviceEvent.cpp b/src/AudioDeviceEvent.cpp
index 8ddf5ee..b4fd323 100644
--- a/src/AudioDeviceEvent.cpp
+++ b/src/AudioDeviceEvent.cpp
@@ -176,8 +176,7 @@ namespace SaneAudioRenderer
void AudioDeviceEvent::PushBufferToDevice()
{
- UINT32 deviceFrames;
- ThrowIfFailed(m_backend->audioClient->GetBufferSize(&deviceFrames));
+ UINT32 deviceFrames = m_backend->deviceBufferSize;
if (!m_backend->exclusive)
{
diff --git a/src/AudioDeviceManager.cpp b/src/AudioDeviceManager.cpp
index f8f3d48..8d7b357 100644
--- a/src/AudioDeviceManager.cpp
+++ b/src/AudioDeviceManager.cpp
@@ -388,10 +388,10 @@ namespace SaneAudioRenderer
}
ThrowIfFailed(backend->audioClient->GetService(IID_PPV_ARGS(&backend->audioRenderClient)));
-
ThrowIfFailed(backend->audioClient->GetService(IID_PPV_ARGS(&backend->audioClock)));
- ThrowIfFailed(backend->audioClient->GetStreamLatency(&backend->latency));
+ ThrowIfFailed(backend->audioClient->GetStreamLatency(&backend->deviceLatency));
+ ThrowIfFailed(backend->audioClient->GetBufferSize(&backend->deviceBufferSize));
return S_OK;
}
diff --git a/src/AudioDevicePush.cpp b/src/AudioDevicePush.cpp
index 96ac526..e37d286 100644
--- a/src/AudioDevicePush.cpp
+++ b/src/AudioDevicePush.cpp
@@ -251,12 +251,11 @@ namespace SaneAudioRenderer
void AudioDevicePush::PushToDevice(DspChunk& chunk, CAMEvent* pFilledEvent)
{
// Get up-to-date information on the device buffer.
- UINT32 bufferFrames, bufferPadding;
- ThrowIfFailed(m_backend->audioClient->GetBufferSize(&bufferFrames));
+ UINT32 bufferPadding;
ThrowIfFailed(m_backend->audioClient->GetCurrentPadding(&bufferPadding));
// Find out how many frames we can write this time.
- const UINT32 doFrames = std::min(bufferFrames - bufferPadding, (UINT32)chunk.GetFrameCount());
+ const UINT32 doFrames = std::min(m_backend->deviceBufferSize - bufferPadding, (UINT32)chunk.GetFrameCount());
if (doFrames == 0)
return;
@@ -270,7 +269,7 @@ namespace SaneAudioRenderer
// If the buffer is fully filled, set the corresponding event (if requested).
if (pFilledEvent &&
- bufferPadding + doFrames == bufferFrames)
+ bufferPadding + doFrames == m_backend->deviceBufferSize)
{
pFilledEvent->Set();
}
@@ -284,12 +283,11 @@ namespace SaneAudioRenderer
UINT32 AudioDevicePush::PushSilenceToDevice(UINT32 frames)
{
// Get up-to-date information on the device buffer.
- UINT32 bufferFrames, bufferPadding;
- ThrowIfFailed(m_backend->audioClient->GetBufferSize(&bufferFrames));
+ UINT32 bufferPadding;
ThrowIfFailed(m_backend->audioClient->GetCurrentPadding(&bufferPadding));
// Find out how many frames we can write this time.
- const UINT32 doFrames = std::min(bufferFrames - bufferPadding, frames);
+ const UINT32 doFrames = std::min(m_backend->deviceBufferSize - bufferPadding, frames);
if (doFrames == 0)
return 0;