Qt: Support loading fpsTarget and audioBuffers

This commit is contained in:
Jeffrey Pfau 2014-11-02 02:58:47 -08:00
parent 776c64b0c8
commit 6788008418
3 changed files with 31 additions and 10 deletions

View File

@ -58,10 +58,14 @@ void AudioProcessor::pause() {
}
void AudioProcessor::setBufferSamples(int samples) {
QAudioFormat format = m_audioOutput->format();
m_audioOutput->setBufferSize(samples * format.channelCount() * format.sampleSize() / 8);
if (m_audioOutput) {
QAudioFormat format = m_audioOutput->format();
m_audioOutput->setBufferSize(samples * format.channelCount() * format.sampleSize() / 8);
}
}
void AudioProcessor::inputParametersChanged() {
m_device->setFormat(m_audioOutput->format());
if (m_device) {
m_device->setFormat(m_audioOutput->format());
}
}

View File

@ -243,17 +243,26 @@ void GameController::keyReleased(int key) {
}
void GameController::setAudioBufferSamples(int samples) {
GBAThreadInterrupt(&m_threadContext);
m_threadContext.audioBuffers = samples;
GBAAudioResizeBuffer(&m_threadContext.gba->audio, samples);
GBAThreadContinue(&m_threadContext);
if (m_gameOpen) {
GBAThreadInterrupt(&m_threadContext);
m_threadContext.audioBuffers = samples;
GBAAudioResizeBuffer(&m_threadContext.gba->audio, samples);
GBAThreadContinue(&m_threadContext);
} else {
m_threadContext.audioBuffers = samples;
}
QMetaObject::invokeMethod(m_audioProcessor, "setBufferSamples", Q_ARG(int, samples));
}
void GameController::setFPSTarget(float fps) {
GBAThreadInterrupt(&m_threadContext);
m_threadContext.fpsTarget = fps;
GBAThreadContinue(&m_threadContext);
if (m_gameOpen) {
GBAThreadInterrupt(&m_threadContext);
m_threadContext.fpsTarget = fps;
GBAThreadContinue(&m_threadContext);
} else {
m_threadContext.fpsTarget = fps;
}
QMetaObject::invokeMethod(m_audioProcessor, "inputParametersChanged");
}

View File

@ -118,6 +118,14 @@ void Window::setOptions(GBAOptions* opts) {
if (opts->bios) {
m_controller->loadBIOS(opts->bios);
}
if (opts->fpsTarget) {
emit fpsTargetChanged(opts->fpsTarget);
}
if (opts->audioBuffers) {
emit audioBufferSamplesChanged(opts->audioBuffers);
}
}
void Window::selectROM() {