diff options
author | Chris Robinson <[email protected]> | 2017-04-18 00:58:33 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-04-18 00:58:33 -0700 |
commit | de62ab97e912525f20272153f6a4c896e833839d (patch) | |
tree | 84dcb690075f7287d02915fe68b3a21ca497d21b /Alc | |
parent | 45d52f7124312c91ec0259fbb0c72346ee36e03b (diff) |
Store the source queue head in the voice to signify looping
This removes the need to access a couple more source fields in the mixer, and
also makes the looping and queue fields non-atomic.
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/mixer.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/Alc/mixer.c b/Alc/mixer.c index 90f3e05e..8996499d 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -268,6 +268,7 @@ static const ALfloat *DoFilters(ALfilterState *lpfilter, ALfilterState *hpfilter ALboolean MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALsizei SamplesToDo) { ALbufferlistitem *BufferListItem; + ALbufferlistitem *BufferLoopItem; ALsizei NumChannels, SampleSize; ResamplerFunc Resample; ALsizei DataPosInt; @@ -278,16 +279,15 @@ ALboolean MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALsizei ALsizei OutPos; ALsizei IrSize; bool isplaying; - bool islooping; ALsizei chan; ALsizei send; /* Get source info */ isplaying = true; /* Will only be called while playing. */ - islooping = ATOMIC_LOAD(&Source->looping, almemory_order_acquire); - DataPosInt = ATOMIC_LOAD(&voice->position, almemory_order_relaxed); + DataPosInt = ATOMIC_LOAD(&voice->position, almemory_order_acquire); DataPosFrac = ATOMIC_LOAD(&voice->position_fraction, almemory_order_relaxed); BufferListItem = ATOMIC_LOAD(&voice->current_buffer, almemory_order_relaxed); + BufferLoopItem = ATOMIC_LOAD(&voice->loop_buffer, almemory_order_relaxed); NumChannels = voice->NumChannels; SampleSize = voice->SampleSize; increment = voice->Step; @@ -345,9 +345,9 @@ ALboolean MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALsizei Data += chan*SampleSize; /* If current pos is beyond the loop range, do not loop */ - if(!islooping || DataPosInt >= ALBuffer->LoopEnd) + if(!BufferLoopItem || DataPosInt >= ALBuffer->LoopEnd) { - islooping = false; + BufferLoopItem = NULL; /* Load what's left to play from the source buffer, and * clear the rest of the temp buffer */ @@ -415,8 +415,8 @@ ALboolean MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALsizei } } tmpiter = tmpiter->next; - if(!tmpiter && islooping) - tmpiter = ATOMIC_LOAD(&Source->queue, almemory_order_acquire); + if(!tmpiter && BufferLoopItem) + tmpiter = BufferLoopItem; else if(!tmpiter) { SilenceSamples(&SrcData[SrcDataSize], SrcBufferSize - SrcDataSize); @@ -602,7 +602,7 @@ ALboolean MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALsizei break; } - if(islooping && Source->SourceType == AL_STATIC) + if(BufferLoopItem && Source->SourceType == AL_STATIC) { assert(LoopEnd > LoopStart); DataPosInt = ((DataPosInt-LoopStart)%(LoopEnd-LoopStart)) + LoopStart; @@ -614,12 +614,9 @@ ALboolean MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALsizei if(!(BufferListItem=BufferListItem->next)) { - if(islooping) - BufferListItem = ATOMIC_LOAD(&Source->queue, almemory_order_acquire); - else + if(!(BufferListItem=BufferLoopItem)) { isplaying = false; - BufferListItem = NULL; DataPosInt = 0; DataPosFrac = 0; break; |