summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-09-21 16:54:33 -0700
committerChris Robinson <[email protected]>2010-09-21 16:54:33 -0700
commit97daaade8a123a8bcac52752febbca9f1d43b0aa (patch)
tree70d3c92437ea6d65ec73065472d0d96825784347
parent8a1d5a21c3b569424bdbe5b92d9e53aab00a60c6 (diff)
Reduce some more indentation
-rw-r--r--OpenAL32/alAuxEffectSlot.c49
-rw-r--r--OpenAL32/alBuffer.c68
-rw-r--r--OpenAL32/alDatabuffer.c78
-rw-r--r--OpenAL32/alEffect.c44
-rw-r--r--OpenAL32/alFilter.c46
-rw-r--r--OpenAL32/alSource.c86
6 files changed, 188 insertions, 183 deletions
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c
index dfc0ad18..5d86409f 100644
--- a/OpenAL32/alAuxEffectSlot.c
+++ b/OpenAL32/alAuxEffectSlot.c
@@ -104,52 +104,53 @@ AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, ALuint *effect
{
ALCcontext *Context;
ALeffectslot *EffectSlot;
+ ALboolean SlotsValid = AL_FALSE;
ALsizei i;
Context = GetContextSuspended();
if(!Context) return;
- if (n >= 0)
+ if(n < 0)
+ alSetError(Context, AL_INVALID_VALUE);
+ else
{
+ SlotsValid = AL_TRUE;
// Check that all effectslots are valid
- for (i = 0; i < n; i++)
+ for(i = 0;i < n;i++)
{
if((EffectSlot=LookupEffectSlot(Context->EffectSlotMap, effectslots[i])) == NULL)
{
alSetError(Context, AL_INVALID_NAME);
+ SlotsValid = AL_FALSE;
break;
}
- else
+ else if(EffectSlot->refcount > 0)
{
- if(EffectSlot->refcount > 0)
- {
- alSetError(Context, AL_INVALID_NAME);
- break;
- }
+ alSetError(Context, AL_INVALID_NAME);
+ SlotsValid = AL_FALSE;
+ break;
}
}
+ }
- if (i == n)
+ if(SlotsValid)
+ {
+ // All effectslots are valid
+ for(i = 0;i < n;i++)
{
- // All effectslots are valid
- for (i = 0; i < n; i++)
- {
- // Recheck that the effectslot is valid, because there could be duplicated names
- if((EffectSlot=LookupEffectSlot(Context->EffectSlotMap, effectslots[i])) != NULL)
- {
- ALEffect_Destroy(EffectSlot->EffectState);
+ // Recheck that the effectslot is valid, because there could be duplicated names
+ if((EffectSlot=LookupEffectSlot(Context->EffectSlotMap, effectslots[i])) == NULL)
+ continue;
- RemoveUIntMapKey(&Context->EffectSlotMap, EffectSlot->effectslot);
- ALTHUNK_REMOVEENTRY(EffectSlot->effectslot);
+ ALEffect_Destroy(EffectSlot->EffectState);
- memset(EffectSlot, 0, sizeof(ALeffectslot));
- free(EffectSlot);
- }
- }
+ RemoveUIntMapKey(&Context->EffectSlotMap, EffectSlot->effectslot);
+ ALTHUNK_REMOVEENTRY(EffectSlot->effectslot);
+
+ memset(EffectSlot, 0, sizeof(ALeffectslot));
+ free(EffectSlot);
}
}
- else
- alSetError(Context, AL_INVALID_VALUE);
ProcessContext(Context);
}
diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c
index f00ac58b..00920794 100644
--- a/OpenAL32/alBuffer.c
+++ b/OpenAL32/alBuffer.c
@@ -157,67 +157,67 @@ AL_API ALvoid AL_APIENTRY alGenBuffers(ALsizei n, ALuint *buffers)
*
* Deletes the n AL Buffers pointed to by puiBuffers
*/
-AL_API ALvoid AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *puiBuffers)
+AL_API ALvoid AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *buffers)
{
ALCcontext *Context;
+ ALCdevice *device;
+ ALboolean Failed;
ALbuffer *ALBuf;
ALsizei i;
Context = GetContextSuspended();
if(!Context) return;
- // Check we are actually Deleting some Buffers
+ Failed = AL_TRUE;
+ device = Context->Device;
+ /* Check we are actually Deleting some Buffers */
if(n < 0)
alSetError(Context, AL_INVALID_VALUE);
else
{
- ALCdevice *device = Context->Device;
- ALboolean bFailed = AL_FALSE;
+ Failed = AL_FALSE;
- // Check that all the buffers are valid and can actually be deleted
+ /* Check that all the buffers are valid and can actually be deleted */
for(i = 0;i < n;i++)
{
- if(!puiBuffers[i])
+ if(!buffers[i])
continue;
- // Check for valid Buffer ID (can be NULL buffer)
- if((ALBuf=LookupBuffer(device->BufferMap, puiBuffers[i])) != NULL)
- {
- if(ALBuf->refcount != 0)
- {
- // Buffer still in use, cannot be deleted
- alSetError(Context, AL_INVALID_OPERATION);
- bFailed = AL_TRUE;
- break;
- }
- }
- else
+ /* Check for valid Buffer ID (can be NULL buffer) */
+ if((ALBuf=LookupBuffer(device->BufferMap, buffers[i])) == NULL)
{
// Invalid Buffer
alSetError(Context, AL_INVALID_NAME);
- bFailed = AL_TRUE;
+ Failed = AL_TRUE;
+ break;
+ }
+ else if(ALBuf->refcount != 0)
+ {
+ /* Buffer still in use, cannot be deleted */
+ alSetError(Context, AL_INVALID_OPERATION);
+ Failed = AL_TRUE;
break;
}
}
+ }
- // If all the Buffers were valid (and have Reference Counts of 0), then we can delete them
- if(!bFailed)
+ /* If all the Buffers were valid (and have Reference Counts of 0), then we can delete them */
+ if(!Failed)
+ {
+ for(i = 0;i < n;i++)
{
- for(i = 0;i < n;i++)
- {
- if((ALBuf=LookupBuffer(device->BufferMap, puiBuffers[i])) != NULL)
- {
- // Release the memory used to store audio data
- free(ALBuf->data);
+ if((ALBuf=LookupBuffer(device->BufferMap, buffers[i])) == NULL)
+ continue;
- // Release buffer structure
- RemoveUIntMapKey(&device->BufferMap, ALBuf->buffer);
- ALTHUNK_REMOVEENTRY(ALBuf->buffer);
+ /* Release the memory used to store audio data */
+ free(ALBuf->data);
- memset(ALBuf, 0, sizeof(ALbuffer));
- free(ALBuf);
- }
- }
+ /* Release buffer structure */
+ RemoveUIntMapKey(&device->BufferMap, ALBuf->buffer);
+ ALTHUNK_REMOVEENTRY(ALBuf->buffer);
+
+ memset(ALBuf, 0, sizeof(ALbuffer));
+ free(ALBuf);
}
}
diff --git a/OpenAL32/alDatabuffer.c b/OpenAL32/alDatabuffer.c
index 060aaf0c..06a5a94f 100644
--- a/OpenAL32/alDatabuffer.c
+++ b/OpenAL32/alDatabuffer.c
@@ -93,76 +93,74 @@ AL_API ALvoid AL_APIENTRY alGenDatabuffersEXT(ALsizei n,ALuint *puiBuffers)
*
* Deletes the n AL Databuffers pointed to by puiBuffers
*/
-AL_API ALvoid AL_APIENTRY alDeleteDatabuffersEXT(ALsizei n, const ALuint *puiBuffers)
+AL_API ALvoid AL_APIENTRY alDeleteDatabuffersEXT(ALsizei n, const ALuint *buffers)
{
ALCcontext *Context;
+ ALCdevice *device;
ALdatabuffer *ALBuf;
+ ALboolean Failed;
ALsizei i;
- ALboolean bFailed = AL_FALSE;
Context = GetContextSuspended();
if(!Context) return;
/* Check we are actually Deleting some Databuffers */
- if(n >= 0)
+ Failed = AL_TRUE;
+ device = Context->Device;
+ if(n < 0)
+ alSetError(Context, AL_INVALID_VALUE);
+ else
{
- ALCdevice *device = Context->Device;
-
+ Failed = AL_FALSE;
/* Check that all the databuffers are valid and can actually be
* deleted */
for(i = 0;i < n;i++)
{
- if(!puiBuffers[i])
+ if(!buffers[i])
continue;
/* Check for valid Buffer ID */
- if((ALBuf=LookupDatabuffer(device->DatabufferMap, puiBuffers[i])) != NULL)
- {
- if(ALBuf->state != UNMAPPED)
- {
- /* Databuffer still in use, cannot be deleted */
- alSetError(Context, AL_INVALID_OPERATION);
- bFailed = AL_TRUE;
- break;
- }
- }
- else
+ if((ALBuf=LookupDatabuffer(device->DatabufferMap, buffers[i])) == NULL)
{
/* Invalid Databuffer */
alSetError(Context, AL_INVALID_NAME);
- bFailed = AL_TRUE;
+ Failed = AL_TRUE;
+ break;
+ }
+ else if(ALBuf->state != UNMAPPED)
+ {
+ /* Databuffer still in use, cannot be deleted */
+ alSetError(Context, AL_INVALID_OPERATION);
+ Failed = AL_TRUE;
break;
}
}
+ }
- /* If all the Databuffers were valid (and unmapped), then we can
- * delete them */
- if(!bFailed)
+ /* If all the Databuffers were valid (and unmapped), then we can delete them */
+ if(!Failed)
+ {
+ for(i = 0;i < n;i++)
{
- for(i = 0;i < n;i++)
- {
- if((ALBuf=LookupDatabuffer(device->DatabufferMap, puiBuffers[i])) != NULL)
- {
- if(ALBuf == Context->SampleSource)
- Context->SampleSource = NULL;
- if(ALBuf == Context->SampleSink)
- Context->SampleSink = NULL;
+ if((ALBuf=LookupDatabuffer(device->DatabufferMap, buffers[i])) == NULL)
+ continue;
- // Release the memory used to store audio data
- free(ALBuf->data);
+ if(ALBuf == Context->SampleSource)
+ Context->SampleSource = NULL;
+ if(ALBuf == Context->SampleSink)
+ Context->SampleSink = NULL;
- // Release buffer structure
- RemoveUIntMapKey(&device->DatabufferMap, ALBuf->databuffer);
- ALTHUNK_REMOVEENTRY(puiBuffers[i]);
+ // Release the memory used to store audio data
+ free(ALBuf->data);
- memset(ALBuf, 0, sizeof(ALdatabuffer));
- free(ALBuf);
- }
- }
+ // Release buffer structure
+ RemoveUIntMapKey(&device->DatabufferMap, ALBuf->databuffer);
+ ALTHUNK_REMOVEENTRY(puiBuffers[i]);
+
+ memset(ALBuf, 0, sizeof(ALdatabuffer));
+ free(ALBuf);
}
}
- else
- alSetError(Context, AL_INVALID_VALUE);
ProcessContext(Context);
}
diff --git a/OpenAL32/alEffect.c b/OpenAL32/alEffect.c
index e1c022a0..0814cfe0 100644
--- a/OpenAL32/alEffect.c
+++ b/OpenAL32/alEffect.c
@@ -87,48 +87,52 @@ AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects)
AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, ALuint *effects)
{
ALCcontext *Context;
+ ALCdevice *device;
ALeffect *ALEffect;
+ ALboolean Failed;
ALsizei i;
Context = GetContextSuspended();
if(!Context) return;
- if (n >= 0)
+ Failed = AL_TRUE;
+ device = Context->Device;
+ if(n < 0)
+ alSetError(Context, AL_INVALID_VALUE);
+ else
{
- ALCdevice *device = Context->Device;
-
+ Failed = AL_FALSE;
// Check that all effects are valid
- for (i = 0; i < n; i++)
+ for(i = 0;i < n;i++)
{
if(!effects[i])
continue;
- if(!LookupEffect(device->EffectMap, effects[i]))
+ if(LookupEffect(device->EffectMap, effects[i]) == NULL)
{
alSetError(Context, AL_INVALID_NAME);
+ Failed = AL_TRUE;
break;
}
}
+ }
- if (i == n)
+ if(!Failed)
+ {
+ // All effects are valid
+ for(i = 0;i < n;i++)
{
- // All effects are valid
- for (i = 0; i < n; i++)
- {
- // Recheck that the effect is valid, because there could be duplicated names
- if((ALEffect=LookupEffect(device->EffectMap, effects[i])) != NULL)
- {
- RemoveUIntMapKey(&device->EffectMap, ALEffect->effect);
- ALTHUNK_REMOVEENTRY(ALEffect->effect);
+ // Recheck that the effect is valid, because there could be duplicated names
+ if((ALEffect=LookupEffect(device->EffectMap, effects[i])) == NULL)
+ continue;
- memset(ALEffect, 0, sizeof(ALeffect));
- free(ALEffect);
- }
- }
+ RemoveUIntMapKey(&device->EffectMap, ALEffect->effect);
+ ALTHUNK_REMOVEENTRY(ALEffect->effect);
+
+ memset(ALEffect, 0, sizeof(ALeffect));
+ free(ALEffect);
}
}
- else
- alSetError(Context, AL_INVALID_VALUE);
ProcessContext(Context);
}
diff --git a/OpenAL32/alFilter.c b/OpenAL32/alFilter.c
index 0d66b531..d63e8e8a 100644
--- a/OpenAL32/alFilter.c
+++ b/OpenAL32/alFilter.c
@@ -83,48 +83,52 @@ AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters)
AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, ALuint *filters)
{
ALCcontext *Context;
+ ALCdevice *device;
ALfilter *ALFilter;
+ ALboolean Failed;
ALsizei i;
Context = GetContextSuspended();
if(!Context) return;
- if (n >= 0)
+ Failed = AL_TRUE;
+ device = Context->Device;
+ if(n < 0)
+ alSetError(Context, AL_INVALID_VALUE);
+ else
{
- ALCdevice *device = Context->Device;
-
+ Failed = AL_FALSE;
// Check that all filters are valid
- for (i = 0; i < n; i++)
+ for(i = 0;i < n;i++)
{
if(!filters[i])
continue;
- if(!LookupFilter(device->FilterMap, filters[i]))
+ if(LookupFilter(device->FilterMap, filters[i]) == NULL)
{
alSetError(Context, AL_INVALID_NAME);
+ Failed = AL_TRUE;
break;
}
}
+ }
- if (i == n)
+ if(!Failed)
+ {
+ // All filters are valid
+ for(i = 0;i < n;i++)
{
- // All filters are valid
- for (i = 0; i < n; i++)
- {
- // Recheck that the filter is valid, because there could be duplicated names
- if((ALFilter=LookupFilter(device->FilterMap, filters[i])) != NULL)
- {
- RemoveUIntMapKey(&device->FilterMap, ALFilter->filter);
- ALTHUNK_REMOVEENTRY(ALFilter->filter);
-
- memset(ALFilter, 0, sizeof(ALfilter));
- free(ALFilter);
- }
- }
+ // Recheck that the filter is valid, because there could be duplicated names
+ if((ALFilter=LookupFilter(device->FilterMap, filters[i])) == NULL)
+ continue;
+
+ RemoveUIntMapKey(&device->FilterMap, ALFilter->filter);
+ ALTHUNK_REMOVEENTRY(ALFilter->filter);
+
+ memset(ALFilter, 0, sizeof(ALfilter));
+ free(ALFilter);
}
}
- else
- alSetError(Context, AL_INVALID_VALUE);
ProcessContext(Context);
}
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index a863876e..3b877926 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -99,11 +99,10 @@ AL_API ALvoid AL_APIENTRY alGenSources(ALsizei n,ALuint *sources)
AL_API ALvoid AL_APIENTRY alDeleteSources(ALsizei n, const ALuint *sources)
{
ALCcontext *Context;
- ALCdevice *Device;
ALsource *Source;
ALsizei i, j;
ALbufferlistitem *BufferList;
- ALboolean bSourcesValid = AL_TRUE;
+ ALboolean SourcesValid = AL_FALSE;
Context = GetContextSuspended();
if(!Context) return;
@@ -112,65 +111,64 @@ AL_API ALvoid AL_APIENTRY alDeleteSources(ALsizei n, const ALuint *sources)
alSetError(Context, AL_INVALID_VALUE);
else
{
- Device = Context->Device;
-
+ SourcesValid = AL_TRUE;
// Check that all Sources are valid (and can therefore be deleted)
for(i = 0;i < n;i++)
{
if(LookupSource(Context->SourceMap, sources[i]) == NULL)
{
alSetError(Context, AL_INVALID_NAME);
- bSourcesValid = AL_FALSE;
+ SourcesValid = AL_FALSE;
break;
}
}
+ }
- if(bSourcesValid)
+ if(SourcesValid)
+ {
+ // All Sources are valid, and can be deleted
+ for(i = 0;i < n;i++)
{
- // All Sources are valid, and can be deleted
- for(i = 0;i < n;i++)
+ // Recheck that the Source is valid, because there could be duplicated Source names
+ if((Source=LookupSource(Context->SourceMap, sources[i])) == NULL)
+ continue;
+
+ for(j = 0;j < Context->ActiveSourceCount;j++)
{
- // Recheck that the Source is valid, because there could be duplicated Source names
- if((Source=LookupSource(Context->SourceMap, sources[i])) != NULL)
+ if(Context->ActiveSources[j] == Source)
{
- for(j = 0;j < Context->ActiveSourceCount;j++)
- {
- if(Context->ActiveSources[j] == Source)
- {
- ALsizei end = --(Context->ActiveSourceCount);
- Context->ActiveSources[j] = Context->ActiveSources[end];
- break;
- }
- }
+ ALsizei end = --(Context->ActiveSourceCount);
+ Context->ActiveSources[j] = Context->ActiveSources[end];
+ break;
+ }
+ }
- // For each buffer in the source's queue, decrement its reference counter and remove it
- while(Source->queue != NULL)
- {
- BufferList = Source->queue;
- // Decrement buffer's reference counter
- if(BufferList->buffer != NULL)
- BufferList->buffer->refcount--;
- // Update queue to point to next element in list
- Source->queue = BufferList->next;
- // Release memory allocated for buffer list item
- free(BufferList);
- }
+ // For each buffer in the source's queue...
+ while(Source->queue != NULL)
+ {
+ BufferList = Source->queue;
+ // Decrement buffer's reference counter
+ if(BufferList->buffer != NULL)
+ BufferList->buffer->refcount--;
+ // Update queue to point to next element in list
+ Source->queue = BufferList->next;
+ // Release memory allocated for buffer list item
+ free(BufferList);
+ }
- for(j = 0;j < MAX_SENDS;++j)
- {
- if(Source->Send[j].Slot)
- Source->Send[j].Slot->refcount--;
- Source->Send[j].Slot = NULL;
- }
+ for(j = 0;j < MAX_SENDS;++j)
+ {
+ if(Source->Send[j].Slot)
+ Source->Send[j].Slot->refcount--;
+ Source->Send[j].Slot = NULL;
+ }
- // Remove Source from list of Sources
- RemoveUIntMapKey(&Context->SourceMap, Source->source);
- ALTHUNK_REMOVEENTRY(Source->source);
+ // Remove Source from list of Sources
+ RemoveUIntMapKey(&Context->SourceMap, Source->source);
+ ALTHUNK_REMOVEENTRY(Source->source);
- memset(Source,0,sizeof(ALsource));
- free(Source);
- }
- }
+ memset(Source,0,sizeof(ALsource));
+ free(Source);
}
}