all repos — mgba @ ef68c84e76bfd95b454bcbc3eec4d6946d23a282

mGBA Game Boy Advance Emulator

SDL: Remove GBAThread reference
Jeffrey Pfau jeffrey@endrift.com
Tue, 09 Feb 2016 20:40:49 -0800
commit

ef68c84e76bfd95b454bcbc3eec4d6946d23a282

parent

13f1ab5ab84c83129e96ae80a9d261806b91289f

M src/platform/qt/AudioDevice.cppsrc/platform/qt/AudioDevice.cpp

@@ -9,7 +9,6 @@ #include "LogController.h"

extern "C" { #include "core/thread.h" -#include "gba/gba.h" #include "gba/audio.h" }
M src/platform/qt/AudioProcessorQt.cppsrc/platform/qt/AudioProcessorQt.cpp

@@ -11,7 +11,7 @@

#include <QAudioOutput> extern "C" { -#include "gba/supervisor/thread.h" +#include "core/thread.h" } using namespace QGBA;
M src/platform/qt/AudioProcessorSDL.cppsrc/platform/qt/AudioProcessorSDL.cpp

@@ -7,10 +7,6 @@ #include "AudioProcessorSDL.h"

#include "LogController.h" -extern "C" { -#include "gba/supervisor/thread.h" -} - using namespace QGBA; AudioProcessorSDL::AudioProcessorSDL(QObject* parent)

@@ -23,26 +19,28 @@ AudioProcessorSDL::~AudioProcessorSDL() {

mSDLDeinitAudio(&m_audio); } +void AudioProcessorSDL::setInput(mCoreThread* input) { + AudioProcessor::setInput(input); + if (m_audio.core) { + mSDLDeinitAudio(&m_audio); + mSDLInitAudio(&m_audio, input); + } +} + bool AudioProcessorSDL::start() { if (!input()) { LOG(QT, WARN) << tr("Can't start an audio processor without input"); return false; } - if (m_audio.thread) { + if (m_audio.core) { mSDLResumeAudio(&m_audio); return true; } else { if (!m_audio.samples) { m_audio.samples = 2048; // TODO? } - if (mSDLInitAudio(&m_audio, nullptr)) { - m_audio.core = input()->core; - m_audio.sync = &input()->sync; - mSDLResumeAudio(&m_audio); - return true; - } - return false; + return mSDLInitAudio(&m_audio, input()); } }

@@ -53,12 +51,9 @@

void AudioProcessorSDL::setBufferSamples(int samples) { AudioProcessor::setBufferSamples(samples); m_audio.samples = samples; - if (m_audio.thread) { + if (m_audio.core) { mSDLDeinitAudio(&m_audio); - mSDLInitAudio(&m_audio, nullptr); - m_audio.core = input()->core; - m_audio.sync = &input()->sync; - mSDLResumeAudio(&m_audio); + mSDLInitAudio(&m_audio, input()); } }

@@ -67,17 +62,14 @@ }

void AudioProcessorSDL::requestSampleRate(unsigned rate) { m_audio.sampleRate = rate; - if (m_audio.thread) { + if (m_audio.core) { mSDLDeinitAudio(&m_audio); - mSDLInitAudio(&m_audio, nullptr); - m_audio.core = input()->core; - m_audio.sync = &input()->sync; - mSDLResumeAudio(&m_audio); + mSDLInitAudio(&m_audio, input()); } } unsigned AudioProcessorSDL::sampleRate() const { - if (m_audio.thread) { + if (m_audio.core) { return m_audio.obtainedSpec.freq; } else { return 0;
M src/platform/qt/AudioProcessorSDL.hsrc/platform/qt/AudioProcessorSDL.h

@@ -22,6 +22,7 @@ public:

AudioProcessorSDL(QObject* parent = nullptr); ~AudioProcessorSDL(); + virtual void setInput(mCoreThread* input) override; virtual unsigned sampleRate() const override; public slots:
M src/platform/sdl/main.csrc/platform/sdl/main.c

@@ -174,17 +174,13 @@

renderer->audio.samples = renderer->core->opts.audioBuffers; renderer->audio.sampleRate = 44100; - bool didFail = !mSDLInitAudio(&renderer->audio, 0); + bool didFail = !mSDLInitAudio(&renderer->audio, &thread); if (!didFail) { #if SDL_VERSION_ATLEAST(2, 0, 0) mSDLSetScreensaverSuspendable(&renderer->events, renderer->core->opts.suspendScreensaver); mSDLSuspendScreensaver(&renderer->events); #endif - renderer->audio.core = renderer->core; - renderer->audio.sync = &thread.sync; - if (mCoreThreadStart(&thread)) { - mSDLResumeAudio(&renderer->audio); renderer->runloop(renderer, &thread); mCoreThreadJoin(&thread); } else {
M src/platform/sdl/sdl-audio.csrc/platform/sdl/sdl-audio.c

@@ -14,7 +14,7 @@ #define BUFFER_SIZE (GBA_AUDIO_SAMPLES >> 2)

static void _mSDLAudioCallback(void* context, Uint8* data, int len); -bool mSDLInitAudio(struct mSDLAudio* context, struct GBAThread* threadContext) { +bool mSDLInitAudio(struct mSDLAudio* context, struct mCoreThread* threadContext) { if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) { GBALog(0, GBA_LOG_ERROR, "Could not initialize SDL sound system: %s", SDL_GetError()); return false;

@@ -40,6 +40,7 @@ context->samples = context->obtainedSpec.samples;

context->core = 0; if (threadContext) { + context->core = threadContext->core; context->sync = &threadContext->sync; #if SDL_VERSION_ATLEAST(2, 0, 0)
M src/platform/sdl/sdl-audio.hsrc/platform/sdl/sdl-audio.h

@@ -23,11 +23,11 @@ SDL_AudioDeviceID deviceId;

#endif struct mCore* core; - struct GBAThread* thread; struct mCoreSync* sync; }; -bool mSDLInitAudio(struct mSDLAudio* context, struct GBAThread*); +struct mCoreThread; +bool mSDLInitAudio(struct mSDLAudio* context, struct mCoreThread*); void mSDLDeinitAudio(struct mSDLAudio* context); void mSDLPauseAudio(struct mSDLAudio* context); void mSDLResumeAudio(struct mSDLAudio* context);