aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-08-20 23:59:24 -0700
committerChris Robinson <[email protected]>2011-08-20 23:59:24 -0700
commitf196a9fc67551aef43f75c3e36f3031170a03dac (patch)
treeb320e7754450bbd7eddc75875b3e9c21e9857377
parent7ea71d8bfaa7a05e329ab15ca8828cbc7fe7d00f (diff)
Defer source state changes from alSourcePlay/Pause/Stop/Rewind calls
-rw-r--r--OpenAL32/Include/alSource.h1
-rw-r--r--OpenAL32/alSource.c13
-rw-r--r--OpenAL32/alState.c18
3 files changed, 27 insertions, 5 deletions
diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h
index 8906a9ac..87d04eb8 100644
--- a/OpenAL32/Include/alSource.h
+++ b/OpenAL32/Include/alSource.h
@@ -51,6 +51,7 @@ typedef struct ALsource
enum Resampler Resampler;
ALenum state;
+ ALenum new_state;
ALuint position;
ALuint position_fraction;
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index f1007507..113970e6 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -1376,7 +1376,8 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources)
for(i = 0;i < n;i++)
{
Source = (ALsource*)ALTHUNK_LOOKUPENTRY(sources[i]);
- SetSourceState(Source, Context, AL_PLAYING);
+ if(Context->DeferUpdates) Source->new_state = AL_PLAYING;
+ else SetSourceState(Source, Context, AL_PLAYING);
}
done:
@@ -1421,7 +1422,8 @@ AL_API ALvoid AL_APIENTRY alSourcePausev(ALsizei n, const ALuint *sources)
for(i = 0;i < n;i++)
{
Source = (ALsource*)ALTHUNK_LOOKUPENTRY(sources[i]);
- SetSourceState(Source, Context, AL_PAUSED);
+ if(Context->DeferUpdates) Source->new_state = AL_PAUSED;
+ else SetSourceState(Source, Context, AL_PAUSED);
}
done:
@@ -1466,7 +1468,8 @@ AL_API ALvoid AL_APIENTRY alSourceStopv(ALsizei n, const ALuint *sources)
for(i = 0;i < n;i++)
{
Source = (ALsource*)ALTHUNK_LOOKUPENTRY(sources[i]);
- SetSourceState(Source, Context, AL_STOPPED);
+ if(Context->DeferUpdates) Source->new_state = AL_STOPPED;
+ else SetSourceState(Source, Context, AL_STOPPED);
}
done:
@@ -1511,7 +1514,8 @@ AL_API ALvoid AL_APIENTRY alSourceRewindv(ALsizei n, const ALuint *sources)
for(i = 0;i < n;i++)
{
Source = (ALsource*)ALTHUNK_LOOKUPENTRY(sources[i]);
- SetSourceState(Source, Context, AL_INITIAL);
+ if(Context->DeferUpdates) Source->new_state = AL_INITIAL;
+ else SetSourceState(Source, Context, AL_INITIAL);
}
done:
@@ -1772,6 +1776,7 @@ static ALvoid InitSourceParams(ALsource *Source)
Source->Resampler = DefaultResampler;
Source->state = AL_INITIAL;
+ Source->new_state = AL_NONE;
Source->lSourceType = AL_UNDETERMINED;
Source->NeedsUpdate = AL_TRUE;
diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c
index 0e0e5d4b..bb500bf5 100644
--- a/OpenAL32/alState.c
+++ b/OpenAL32/alState.c
@@ -591,7 +591,23 @@ AL_API ALvoid AL_APIENTRY alProcessUpdatesSOFT(void)
Context = GetLockedContext();
if(!Context) return;
- Context->DeferUpdates = AL_FALSE;
+ if(Context->DeferUpdates)
+ {
+ ALsizei pos;
+
+ Context->DeferUpdates = AL_FALSE;
+
+ for(pos = 0;pos < Context->SourceMap.size;pos++)
+ {
+ ALsource *src = Context->SourceMap.array[pos].value;
+ ALenum new_state;
+
+ new_state = src->new_state;
+ src->new_state = AL_NONE;
+ if(new_state)
+ SetSourceState(src, Context, new_state);
+ }
+ }
UnlockContext(Context);
}