audio: Made some SDL_AudioDevice fields atomic.

This makes sure they're properly communicated to the audio threads.
This commit is contained in:
Ryan C. Gordon
2016-08-02 13:48:52 -04:00
parent b35b9f950e
commit 6d5c9c1e67
11 changed files with 38 additions and 38 deletions

View File

@@ -283,7 +283,7 @@ outputCallback(void *inRefCon,
UInt32 i;
/* Only do anything if audio is enabled and not paused */
if (!this->enabled || this->paused) {
if (!SDL_AtomicGet(&this->enabled) || SDL_AtomicGet(&this->paused)) {
for (i = 0; i < ioData->mNumberBuffers; i++) {
abuf = &ioData->mBuffers[i];
SDL_memset(abuf->mData, this->spec.silence, abuf->mDataByteSize);
@@ -335,7 +335,7 @@ inputCallback(void *inRefCon,
AudioBufferList *ioData)
{
SDL_AudioDevice *this = (SDL_AudioDevice *) inRefCon;
if (!this->enabled || this->paused) {
if (!SDL_AtomicGet(&this->enabled) || SDL_AtomicGet(&this->paused)) {
return noErr; /* just drop this if we're not accepting input. */
}
@@ -391,7 +391,7 @@ device_unplugged(AudioObjectID devid, UInt32 num_addr, const AudioObjectProperty
UInt32 size = sizeof (isAlive);
OSStatus error;
if (!this->enabled) {
if (!SDL_AtomicGet(&this->enabled)) {
return 0; /* already known to be dead. */
}