aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-07-31 07:20:36 -0700
committerChris Robinson <[email protected]>2014-07-31 07:20:36 -0700
commit15a58eb38375247b6c57a7ceab5aa74895d638cd (patch)
tree5f546bab5504768356c27903a02b271c619b7d09 /Alc
parentcdfc5a4d31d17e156736bb8bdcaf93ea505237ac (diff)
Make the source's buffer queue head and current queue item atomic
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALu.c6
-rw-r--r--Alc/mixer.c27
2 files changed, 17 insertions, 16 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 81d062d8..e33a756b 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -260,7 +260,7 @@ ALvoid CalcNonAttnSourceParams(ALactivesource *src, const ALCcontext *ALContext)
/* Calculate the stepping value */
Channels = FmtMono;
- BufferListItem = ALSource->queue;
+ BufferListItem = ATOMIC_LOAD(&ALSource->queue);
while(BufferListItem != NULL)
{
ALbuffer *ALBuffer;
@@ -872,7 +872,7 @@ ALvoid CalcSourceParams(ALactivesource *src, const ALCcontext *ALContext)
clampf(SpeedOfSound-VSS, 1.0f, SpeedOfSound*2.0f - 1.0f);
}
- BufferListItem = ALSource->queue;
+ BufferListItem = ATOMIC_LOAD(&ALSource->queue);
while(BufferListItem != NULL)
{
ALbuffer *ALBuffer;
@@ -1308,7 +1308,7 @@ ALvoid aluHandleDisconnect(ALCdevice *device)
if(source->state == AL_PLAYING)
{
source->state = AL_STOPPED;
- source->current_buffer = NULL;
+ ATOMIC_STORE(&source->current_buffer, NULL);
source->position = 0;
source->position_fraction = 0;
}
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;
}