Qt: Fix QtMultimedia build with blip
Jeffrey Pfau jeffrey@endrift.com
Sat, 21 Feb 2015 01:02:26 -0800
1 files changed,
18 insertions(+),
0 deletions(-)
jump to
M
src/platform/qt/AudioDevice.cpp
→
src/platform/qt/AudioDevice.cpp
@@ -25,9 +25,16 @@ void AudioDevice::setFormat(const QAudioFormat& format) {
if (!GBAThreadHasStarted(m_context)) { return; } +#if RESAMPLE_LIBRARY == RESAMPLE_NN GBAThreadInterrupt(m_context); m_ratio = GBAAudioCalculateRatio(m_context->gba->audio.sampleRate, m_context->fpsTarget, format.sampleRate()); GBAThreadContinue(m_context); +#elif RESAMPLE_LIBRARY == RESAMPLE_BLIP_BUF + double fauxClock = GBAAudioCalculateRatio(1, m_context->fpsTarget, 1); + GBASyncLockAudio(&m_context->sync); + blip_set_rates(m_context->gba->audio.left, GBA_ARM7TDMI_FREQUENCY, format.sampleRate() * fauxClock); + blip_set_rates(m_context->gba->audio.right, GBA_ARM7TDMI_FREQUENCY, format.sampleRate() * fauxClock); +#endif } void AudioDevice::setInput(GBAThread* input) {@@ -43,7 +50,18 @@ if (!m_context->gba) {
return 0; } +#if RESAMPLE_LIBRARY == RESAMPLE_NN return GBAAudioResampleNN(&m_context->gba->audio, m_ratio, &m_drift, reinterpret_cast<GBAStereoSample*>(data), maxSize / sizeof(GBAStereoSample)) * sizeof(GBAStereoSample); +#elif RESAMPLE_LIBRARY == RESAMPLE_BLIP_BUF + int available = blip_samples_avail(m_context->gba->audio.left); + if (available > maxSize / sizeof(GBAStereoSample)) { + available = maxSize / sizeof(GBAStereoSample); + } + blip_read_samples(m_context->gba->audio.left, &reinterpret_cast<GBAStereoSample*>(data)->left, available, true); + blip_read_samples(m_context->gba->audio.right, &reinterpret_cast<GBAStereoSample*>(data)->right, available, true); + GBASyncConsumeAudio(&m_context->sync); + return available * sizeof(GBAStereoSample); +#endif } qint64 AudioDevice::writeData(const char*, qint64) {