aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALu.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-08-24 02:17:55 -0700
committerChris Robinson <[email protected]>2016-08-24 02:17:55 -0700
commit849f85549d47a4e1aecdfbdd3300c866fb288fca (patch)
treeb009de71e347243bf632d36f56f848d4e02a25a2 /Alc/ALu.c
parent8bf4a22876c30c16db71cd9063b9788c5e6a1aa8 (diff)
Consolidate duplicate code
Diffstat (limited to 'Alc/ALu.c')
-rw-r--r--Alc/ALu.c62
1 files changed, 23 insertions, 39 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 54905ebd..80a031fc 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -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;
+ }
}