diff options
author | Chris Robinson <[email protected]> | 2016-08-24 02:17:55 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2016-08-24 02:17:55 -0700 |
commit | 849f85549d47a4e1aecdfbdd3300c866fb288fca (patch) | |
tree | b009de71e347243bf632d36f56f848d4e02a25a2 /Alc/ALu.c | |
parent | 8bf4a22876c30c16db71cd9063b9788c5e6a1aa8 (diff) |
Consolidate duplicate code
Diffstat (limited to 'Alc/ALu.c')
-rw-r--r-- | Alc/ALu.c | 62 |
1 files changed, 23 insertions, 39 deletions
@@ -1296,54 +1296,38 @@ static void CalcSourceParams(ALvoice *voice, ALCcontext *context, ALboolean forc struct ALsourceProps *props; props = ATOMIC_EXCHANGE(struct ALsourceProps*, &source->Update, NULL, almemory_order_acq_rel); - if(!props) - { - if(!force) - return; - BufferListItem = ATOMIC_LOAD(&source->queue, almemory_order_relaxed); - while(BufferListItem != NULL) - { - const ALbuffer *buffer; - if((buffer=BufferListItem->buffer) != NULL) - { - if(buffer->FmtChannels == FmtMono) - CalcAttnSourceParams(voice, &voice->Props, buffer, context); - else - CalcNonAttnSourceParams(voice, &voice->Props, buffer, context); - break; - } - BufferListItem = BufferListItem->next; - } - } - else + if(!props && !force) return; + + if(props) { - BufferListItem = ATOMIC_LOAD(&source->queue, almemory_order_relaxed); - while(BufferListItem != NULL) - { - const ALbuffer *buffer; - if((buffer=BufferListItem->buffer) != NULL) - { - if(buffer->FmtChannels == FmtMono) - CalcAttnSourceParams(voice, props, buffer, context); - else - CalcNonAttnSourceParams(voice, props, buffer, context); - break; - } - BufferListItem = BufferListItem->next; - } voice->Props = *props; - /* WARNING: A livelock is theoretically possible if another thread keeps - * changing the freelist head without giving this a chance to actually swap - * in the old container (practically impossible with this little code, - * but...). - */ + /* WARNING: A livelock is theoretically possible if another thread + * keeps changing the freelist head without giving this a chance to + * actually swap in the old container (practically impossible with this + * little code, but...). + */ first = ATOMIC_LOAD(&source->FreeList); do { ATOMIC_STORE(&props->next, first, almemory_order_relaxed); } while(ATOMIC_COMPARE_EXCHANGE_WEAK(struct ALsourceProps*, &source->FreeList, &first, props) == 0); } + + BufferListItem = ATOMIC_LOAD(&source->queue, almemory_order_relaxed); + while(BufferListItem != NULL) + { + const ALbuffer *buffer; + if((buffer=BufferListItem->buffer) != NULL) + { + if(buffer->FmtChannels == FmtMono) + CalcAttnSourceParams(voice, &voice->Props, buffer, context); + else + CalcNonAttnSourceParams(voice, &voice->Props, buffer, context); + break; + } + BufferListItem = BufferListItem->next; + } } |