all repos — mgba @ 7cad9ab33a3ac07060bc971c3a2f9e86d15424ff

mGBA Game Boy Advance Emulator

Qt: Fix QtMultimedia build with blip
Jeffrey Pfau jeffrey@endrift.com
Sat, 21 Feb 2015 01:02:26 -0800
commit

7cad9ab33a3ac07060bc971c3a2f9e86d15424ff

parent

86ff4b15771455d0d63c521bcfb5a937e233cfcd

1 files changed, 18 insertions(+), 0 deletions(-)

jump to
M src/platform/qt/AudioDevice.cppsrc/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) {