Audio Queue Services now queries user-configured sample rate from device

This commit is contained in:
Jack Andersen 2016-06-08 15:51:21 -10:00
parent 65a63bcab5
commit e62e8952b5
1 changed files with 20 additions and 2 deletions

View File

@ -560,10 +560,28 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
return;
}
m_mixInfo.m_sampleRate = 96000.0;
Float64 actualSampleRate;
UInt32 argSize = 8;
err = AudioQueueGetProperty(m_queue, kAudioQueueDeviceProperty_SampleRate, &actualSampleRate, &argSize);
AudioQueueDispose(m_queue, true);
if (err)
{
Log.report(logvisor::Fatal, "unable to get native sample rate from audio queue");
return;
}
desc.mSampleRate = actualSampleRate;
if ((err = AudioQueueNewOutput(&desc, AudioQueueOutputCallback(Callback),
this, nullptr, nullptr, 0, &m_queue)))
{
Log.report(logvisor::Fatal, "unable to create output audio queue");
return;
}
m_mixInfo.m_sampleRate = actualSampleRate;
m_mixInfo.m_sampleFormat = SOXR_INT32_I;
m_mixInfo.m_bitsPerSample = 32;
m_5msFrames = 96000 * 5 / 1000;
m_5msFrames = actualSampleRate * 5 / 1000;
ChannelMap& chMapOut = m_mixInfo.m_channelMap;
if (chCount > 2)