diff options
author | Chris Robinson <[email protected]> | 2014-07-31 07:20:36 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-07-31 07:20:36 -0700 |
commit | 15a58eb38375247b6c57a7ceab5aa74895d638cd (patch) | |
tree | 5f546bab5504768356c27903a02b271c619b7d09 /Alc/mixer.c | |
parent | cdfc5a4d31d17e156736bb8bdcaf93ea505237ac (diff) |
Make the source's buffer queue head and current queue item atomic
Diffstat (limited to 'Alc/mixer.c')
-rw-r--r-- | Alc/mixer.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/Alc/mixer.c b/Alc/mixer.c index 7141a8ae..f3b8f599 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -198,7 +198,7 @@ ALvoid MixSource(ALactivesource *src, ALCdevice *Device, ALuint SamplesToDo) /* Get source info */ State = Source->state; - BufferListItem = Source->current_buffer; + BufferListItem = ATOMIC_LOAD(&Source->current_buffer); DataPosInt = Source->position; DataPosFrac = Source->position_fraction; Looping = Source->Looping; @@ -397,7 +397,7 @@ ALvoid MixSource(ALactivesource *src, ALCdevice *Device, ALuint SamplesToDo) } tmpiter = tmpiter->next; if(!tmpiter && Looping) - tmpiter = Source->queue; + tmpiter = ATOMIC_LOAD(&Source->queue); else if(!tmpiter) { SilenceSamples(&SrcData[SrcDataSize], SrcBufferSize - SrcDataSize); @@ -484,17 +484,18 @@ ALvoid MixSource(ALactivesource *src, ALCdevice *Device, ALuint SamplesToDo) if(DataSize > DataPosInt) break; - if(BufferListItem->next) - BufferListItem = BufferListItem->next; - else if(Looping) - BufferListItem = Source->queue; - else + if(!(BufferListItem=BufferListItem->next)) { - State = AL_STOPPED; - BufferListItem = NULL; - DataPosInt = 0; - DataPosFrac = 0; - break; + if(Looping) + BufferListItem = ATOMIC_LOAD(&Source->queue); + else + { + State = AL_STOPPED; + BufferListItem = NULL; + DataPosInt = 0; + DataPosFrac = 0; + break; + } } DataPosInt -= DataSize; @@ -503,7 +504,7 @@ ALvoid MixSource(ALactivesource *src, ALCdevice *Device, ALuint SamplesToDo) /* Update source info */ Source->state = State; - Source->current_buffer = BufferListItem; + ATOMIC_STORE(&Source->current_buffer, BufferListItem); Source->position = DataPosInt; Source->position_fraction = DataPosFrac; } |