aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-09-11 09:28:30 -0700
committerChris Robinson <[email protected]>2011-09-11 09:28:30 -0700
commit8f456f68ff15e3965ffdf579ed3f10bad996b594 (patch)
treef3b7b2ca1d2be121ccf10025b6842f321724b2d8 /OpenAL32
parent54a421ec58e72e602285c115312332c3e70b7615 (diff)
Remove GetLockedContext
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alMain.h5
-rw-r--r--OpenAL32/alSource.c41
2 files changed, 31 insertions, 15 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index ddc3857f..3d030f94 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -635,6 +635,8 @@ struct ALCcontext_struct
ALCcontext *volatile next;
};
+ALCcontext *GetContextRef(void);
+
void ALCcontext_IncRef(ALCcontext *context);
void ALCcontext_DecRef(ALCcontext *context);
@@ -652,9 +654,6 @@ ALCvoid UnlockContext(ALCcontext *context);
ALvoid *StartThread(ALuint (*func)(ALvoid*), ALvoid *ptr);
ALuint StopThread(ALvoid *thread);
-ALCcontext *GetLockedContext(void);
-ALCcontext *GetContextRef(void);
-
typedef struct RingBuffer RingBuffer;
RingBuffer *CreateRingBuffer(ALsizei frame_size, ALsizei length);
void DestroyRingBuffer(RingBuffer *ring);
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index 68c3e092..a093af4e 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -1383,7 +1383,7 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources)
ALsource *Source;
ALsizei i;
- Context = GetLockedContext();
+ Context = GetContextRef();
if(!Context) return;
if(n < 0)
@@ -1407,6 +1407,7 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources)
}
}
+ LockContext(Context);
while(Context->MaxActiveSources-Context->ActiveSourceCount < n)
{
void *temp = NULL;
@@ -1418,6 +1419,7 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources)
sizeof(*Context->ActiveSources) * newcount);
if(!temp)
{
+ UnlockContext(Context);
alSetError(Context, AL_OUT_OF_MEMORY);
goto done;
}
@@ -1432,9 +1434,10 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources)
if(Context->DeferUpdates) Source->new_state = AL_PLAYING;
else SetSourceState(Source, Context, AL_PLAYING);
}
+ UnlockContext(Context);
done:
- UnlockContext(Context);
+ ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alSourcePause(ALuint source)
@@ -1448,7 +1451,7 @@ AL_API ALvoid AL_APIENTRY alSourcePausev(ALsizei n, const ALuint *sources)
ALsource *Source;
ALsizei i;
- Context = GetLockedContext();
+ Context = GetContextRef();
if(!Context) return;
if(n < 0)
@@ -1472,15 +1475,17 @@ AL_API ALvoid AL_APIENTRY alSourcePausev(ALsizei n, const ALuint *sources)
}
}
+ LockContext(Context);
for(i = 0;i < n;i++)
{
Source = LookupSource(Context->SourceMap, sources[i]);
if(Context->DeferUpdates) Source->new_state = AL_PAUSED;
else SetSourceState(Source, Context, AL_PAUSED);
}
+ UnlockContext(Context);
done:
- UnlockContext(Context);
+ ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alSourceStop(ALuint source)
@@ -1494,7 +1499,7 @@ AL_API ALvoid AL_APIENTRY alSourceStopv(ALsizei n, const ALuint *sources)
ALsource *Source;
ALsizei i;
- Context = GetLockedContext();
+ Context = GetContextRef();
if(!Context) return;
if(n < 0)
@@ -1518,15 +1523,17 @@ AL_API ALvoid AL_APIENTRY alSourceStopv(ALsizei n, const ALuint *sources)
}
}
+ LockContext(Context);
for(i = 0;i < n;i++)
{
Source = LookupSource(Context->SourceMap, sources[i]);
Source->new_state = AL_NONE;
SetSourceState(Source, Context, AL_STOPPED);
}
+ UnlockContext(Context);
done:
- UnlockContext(Context);
+ ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alSourceRewind(ALuint source)
@@ -1540,7 +1547,7 @@ AL_API ALvoid AL_APIENTRY alSourceRewindv(ALsizei n, const ALuint *sources)
ALsource *Source;
ALsizei i;
- Context = GetLockedContext();
+ Context = GetContextRef();
if(!Context) return;
if(n < 0)
@@ -1564,15 +1571,17 @@ AL_API ALvoid AL_APIENTRY alSourceRewindv(ALsizei n, const ALuint *sources)
}
}
+ LockContext(Context);
for(i = 0;i < n;i++)
{
Source = LookupSource(Context->SourceMap, sources[i]);
Source->new_state = AL_NONE;
SetSourceState(Source, Context, AL_INITIAL);
}
+ UnlockContext(Context);
done:
- UnlockContext(Context);
+ ALCcontext_DecRef(Context);
}
@@ -1589,7 +1598,7 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei n, const A
if(n == 0)
return;
- Context = GetLockedContext();
+ Context = GetContextRef();
if(!Context) return;
if(n < 0)
@@ -1607,9 +1616,11 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei n, const A
goto error;
}
+ LockContext(Context);
// Check that this is not a STATIC Source
if(Source->lSourceType == AL_STATIC)
{
+ UnlockContext(Context);
// Invalid Source Type (can't queue on a Static Source)
alSetError(Context, AL_INVALID_OPERATION);
goto error;
@@ -1636,6 +1647,7 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei n, const A
ALbuffer *buffer = NULL;
if(buffers[i] && (buffer=LookupBuffer(device->BufferMap, buffers[i])) == NULL)
{
+ UnlockContext(Context);
alSetError(Context, AL_INVALID_NAME);
goto error;
}
@@ -1679,6 +1691,7 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei n, const A
BufferFmt->OriginalType != buffer->OriginalType)
{
ReadUnlock(&buffer->lock);
+ UnlockContext(Context);
alSetError(Context, AL_INVALID_OPERATION);
goto error;
}
@@ -1705,6 +1718,7 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei n, const A
Source->BuffersInQueue += n;
UnlockContext(Context);
+ ALCcontext_DecRef(Context);
return;
error:
@@ -1717,7 +1731,7 @@ error:
DecrementRef(&BufferList->buffer->ref);
free(BufferList);
}
- UnlockContext(Context);
+ ALCcontext_DecRef(Context);
}
@@ -1733,7 +1747,7 @@ AL_API ALvoid AL_APIENTRY alSourceUnqueueBuffers( ALuint source, ALsizei n, ALui
if(n == 0)
return;
- Context = GetLockedContext();
+ Context = GetContextRef();
if(!Context) return;
if(n < 0)
@@ -1748,9 +1762,11 @@ AL_API ALvoid AL_APIENTRY alSourceUnqueueBuffers( ALuint source, ALsizei n, ALui
goto done;
}
+ LockContext(Context);
if(Source->bLooping || Source->lSourceType != AL_STREAMING ||
(ALuint)n > Source->BuffersPlayed)
{
+ UnlockContext(Context);
// Some buffers can't be unqueue because they have not been processed
alSetError(Context, AL_INVALID_VALUE);
goto done;
@@ -1778,9 +1794,10 @@ AL_API ALvoid AL_APIENTRY alSourceUnqueueBuffers( ALuint source, ALsizei n, ALui
}
if(Source->queue)
Source->queue->prev = NULL;
+ UnlockContext(Context);
done:
- UnlockContext(Context);
+ ALCcontext_DecRef(Context);
}