Qt: Fix QtMultimedia build with blip

This commit is contained in:
Jeffrey Pfau 2015-02-21 01:02:26 -08:00
parent 86ff4b1577
commit 7cad9ab33a
1 changed files with 18 additions and 0 deletions

View File

@ -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 @@ qint64 AudioDevice::readData(char* data, qint64 maxSize) {
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) {