mirror of https://github.com/stella-emu/stella.git
Avoid race condition in pause, switch to shared_ptr for simpler semantics.
This commit is contained in:
parent
4528b9067a
commit
6b984a8563
|
@ -100,7 +100,7 @@ void SoundSDL2::setEnabled(bool state)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void SoundSDL2::open(AudioQueue* audioQueue)
|
||||
void SoundSDL2::open(shared_ptr<AudioQueue> audioQueue)
|
||||
{
|
||||
myOSystem.logMessage("SoundSDL2::open started ...", 2);
|
||||
mute(true);
|
||||
|
@ -141,10 +141,11 @@ void SoundSDL2::close()
|
|||
{
|
||||
if(!myIsInitializedFlag) return;
|
||||
|
||||
mute(true);
|
||||
|
||||
myAudioQueue = 0;
|
||||
myCurrentFragment = 0;
|
||||
|
||||
mute(true);
|
||||
myOSystem.logMessage("SoundSDL2::close", 2);
|
||||
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ class SoundSDL2 : public Sound
|
|||
Initializes the sound device. This must be called before any
|
||||
calls are made to derived methods.
|
||||
*/
|
||||
void open(AudioQueue* audioQueue) override;
|
||||
void open(shared_ptr<AudioQueue> audioQueue) override;
|
||||
|
||||
/**
|
||||
Should be called to close the sound device. Once called the sound
|
||||
|
@ -117,7 +117,7 @@ class SoundSDL2 : public Sound
|
|||
// Audio specification structure
|
||||
SDL_AudioSpec myHardwareSpec;
|
||||
|
||||
AudioQueue* myAudioQueue;
|
||||
shared_ptr<AudioQueue> myAudioQueue;
|
||||
|
||||
Int16* myCurrentFragment;
|
||||
uInt32 myTimeIndex;
|
||||
|
|
|
@ -183,7 +183,7 @@ Console::Console(OSystem& osystem, unique_ptr<Cartridge>& cart,
|
|||
}
|
||||
|
||||
createAudioQueue();
|
||||
myTIA->setAudioQueue(myAudioQueue.get());
|
||||
myTIA->setAudioQueue(myAudioQueue);
|
||||
|
||||
bool joyallow4 = myOSystem.settings().getBool("joyallow4");
|
||||
myOSystem.eventHandler().allowAllDirections(joyallow4);
|
||||
|
@ -580,7 +580,7 @@ void Console::initializeAudio()
|
|||
// const string& sound = myProperties.get(Cartridge_Sound);
|
||||
// myOSystem.sound().setChannels(sound == "STEREO" ? 2 : 1);
|
||||
|
||||
myOSystem.sound().open(myAudioQueue.get());
|
||||
myOSystem.sound().open(myAudioQueue);
|
||||
|
||||
// Make sure auto-frame calculation is only enabled when necessary
|
||||
myTIA->enableAutoFrame(framerate <= 0);
|
||||
|
@ -754,7 +754,7 @@ void Console::createAudioQueue()
|
|||
throw runtime_error("invalid console timing");
|
||||
}
|
||||
|
||||
myAudioQueue = make_unique<AudioQueue>(
|
||||
myAudioQueue = make_shared<AudioQueue>(
|
||||
fragmentSize,
|
||||
AUDIO_QUEUE_CAPACITY_FRAGMENTS,
|
||||
myProperties.get(Cartridge_Sound) == "STEREO",
|
||||
|
|
|
@ -388,7 +388,7 @@ class Console : public Serializable
|
|||
unique_ptr<AbstractFrameManager> myFrameManager;
|
||||
|
||||
// The audio fragment queue that connects TIA and audio driver
|
||||
unique_ptr<AudioQueue> myAudioQueue;
|
||||
shared_ptr<AudioQueue> myAudioQueue;
|
||||
|
||||
// Pointer to the Cartridge (the debugger needs it)
|
||||
unique_ptr<Cartridge> myCart;
|
||||
|
|
|
@ -51,7 +51,7 @@ class Sound
|
|||
Start the sound system, initializing it if necessary. This must be
|
||||
called before any calls are made to derived methods.
|
||||
*/
|
||||
virtual void open(AudioQueue* audioQueue) = 0;
|
||||
virtual void open(shared_ptr<AudioQueue> audioQueue) = 0;
|
||||
|
||||
/**
|
||||
Should be called to stop the sound system. Once called the sound
|
||||
|
|
|
@ -53,7 +53,7 @@ void Audio::reset()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Audio::setAudioQueue(AudioQueue* queue)
|
||||
void Audio::setAudioQueue(shared_ptr<AudioQueue> queue)
|
||||
{
|
||||
myAudioQueue = queue;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ class Audio
|
|||
|
||||
void reset();
|
||||
|
||||
void setAudioQueue(AudioQueue *queue);
|
||||
void setAudioQueue(shared_ptr<AudioQueue> queue);
|
||||
|
||||
void tick();
|
||||
|
||||
|
@ -42,7 +42,7 @@ class Audio
|
|||
void phase1();
|
||||
|
||||
private:
|
||||
AudioQueue* myAudioQueue;
|
||||
shared_ptr<AudioQueue> myAudioQueue;
|
||||
|
||||
uInt8 myCounter;
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ void TIA::setFrameManager(AbstractFrameManager *frameManager)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void TIA::setAudioQueue(AudioQueue* queue)
|
||||
void TIA::setAudioQueue(shared_ptr<AudioQueue> queue)
|
||||
{
|
||||
myAudio.setAudioQueue(queue);
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ class TIA : public Device
|
|||
Set the audio queue. This needs to be dynamic as the queue is created after
|
||||
the timing has been determined.
|
||||
*/
|
||||
void setAudioQueue(AudioQueue *audioQueue);
|
||||
void setAudioQueue(shared_ptr<AudioQueue> audioQueue);
|
||||
|
||||
/**
|
||||
Clear the configured frame manager and deteach the lifecycle callbacks.
|
||||
|
|
Loading…
Reference in New Issue