Qt: Ensure proper audio sample rate is used when resampling audio
Jeffrey Pfau jeffrey@endrift.com
Sun, 12 Jul 2015 00:19:17 -0700
6 files changed,
18 insertions(+),
1 deletions(-)
M
src/platform/qt/AudioProcessor.h
→
src/platform/qt/AudioProcessor.h
@@ -39,6 +39,8 @@
virtual void setBufferSamples(int samples) = 0; virtual void inputParametersChanged() = 0; + virtual unsigned sampleRate() const = 0; + protected: GBAThread* input() { return m_context; }
M
src/platform/qt/AudioProcessorQt.cpp
→
src/platform/qt/AudioProcessorQt.cpp
@@ -83,3 +83,10 @@ if (m_device) {
m_device->setFormat(m_audioOutput->format()); } } + +unsigned AudioProcessorQt::sampleRate() const { + if (!m_audioOutput) { + return 0; + } + return m_audioOutput->format().sampleRate(); +}
M
src/platform/qt/AudioProcessorQt.h
→
src/platform/qt/AudioProcessorQt.h
@@ -28,6 +28,8 @@
virtual void setBufferSamples(int samples); virtual void inputParametersChanged(); + virtual unsigned sampleRate() const override; + private: QAudioOutput* m_audioOutput; AudioDevice* m_device;
M
src/platform/qt/AudioProcessorSDL.cpp
→
src/platform/qt/AudioProcessorSDL.cpp
@@ -54,3 +54,7 @@ }
void AudioProcessorSDL::inputParametersChanged() { } + +unsigned AudioProcessorSDL::sampleRate() const { + return m_audio.obtainedSpec.freq; +}
M
src/platform/qt/AudioProcessorSDL.h
→
src/platform/qt/AudioProcessorSDL.h
@@ -29,6 +29,8 @@
virtual void setBufferSamples(int samples); virtual void inputParametersChanged(); + virtual unsigned sampleRate() const override; + private: GBASDLAudio m_audio; };
M
src/platform/qt/GameController.cpp
→
src/platform/qt/GameController.cpp
@@ -746,7 +746,7 @@ float ratio;
if (m_threadContext.gba) { sampleRate = m_threadContext.gba->audio.sampleRate; } - ratio = GBAAudioCalculateRatio(sampleRate, m_threadContext.fpsTarget, 44100); + ratio = GBAAudioCalculateRatio(sampleRate, m_threadContext.fpsTarget, m_audioProcess->sampleRate()); m_threadContext.audioBuffers = ceil(samples / ratio); #else m_threadContext.audioBuffers = samples;