diff options
author | Chris Robinson <[email protected]> | 2008-07-11 09:12:11 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2008-07-11 09:12:11 -0700 |
commit | 97d3a45aff582242a9e5229c1e170f45ac96e0d9 (patch) | |
tree | 23920261f18dff973850a37037ed4d97ec7cdc21 /OpenAL32/alSource.c | |
parent | 9e9ff44b176578035be146f89c5a06258cb6a019 (diff) |
Don't check the number of objects being deleted with the number currently allocated
Since apps can validly delete buffer 0, and delete the same source/buffer multiple times in a single call
Diffstat (limited to 'OpenAL32/alSource.c')
-rw-r--r-- | OpenAL32/alSource.c | 97 |
1 files changed, 44 insertions, 53 deletions
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index df78de33..88c699cd 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -137,74 +137,65 @@ ALAPI ALvoid ALAPIENTRY alDeleteSources(ALsizei n, const ALuint *sources) if (Device) { - if ((ALuint)n <= Context->SourceCount) + // Check that all Sources are valid (and can therefore be deleted) + for (i = 0; i < n; i++) { - // Check that all Sources are valid (and can therefore be deleted) - for (i = 0; i < n; i++) + if (!alIsSource(sources[i])) { - if (!alIsSource(sources[i])) - { - alSetError(AL_INVALID_NAME); - bSourcesValid = AL_FALSE; - break; - } + alSetError(AL_INVALID_NAME); + bSourcesValid = AL_FALSE; + break; } + } - if (bSourcesValid) + if (bSourcesValid) + { + // 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 (alIsSource(sources[i])) { - // Recheck that the Source is valid, because there could be duplicated Source names - if (alIsSource(sources[i])) - { - ALSource=((ALsource *)ALTHUNK_LOOKUPENTRY(sources[i])); - alSourceStop((ALuint)ALSource->source); + ALSource=((ALsource *)ALTHUNK_LOOKUPENTRY(sources[i])); + alSourceStop((ALuint)ALSource->source); - // For each buffer in the source's queue, decrement its reference counter and remove it - while (ALSource->queue != NULL) - { - ALBufferList = ALSource->queue; - // Decrement buffer's reference counter - if (ALBufferList->buffer != 0) - ((ALbuffer*)(ALTHUNK_LOOKUPENTRY(ALBufferList->buffer)))->refcount--; - // Update queue to point to next element in list - ALSource->queue = ALBufferList->next; - // Release memory allocated for buffer list item - free(ALBufferList); - } + // For each buffer in the source's queue, decrement its reference counter and remove it + while (ALSource->queue != NULL) + { + ALBufferList = ALSource->queue; + // Decrement buffer's reference counter + if (ALBufferList->buffer != 0) + ((ALbuffer*)(ALTHUNK_LOOKUPENTRY(ALBufferList->buffer)))->refcount--; + // Update queue to point to next element in list + ALSource->queue = ALBufferList->next; + // Release memory allocated for buffer list item + free(ALBufferList); + } - for(j = 0;j < MAX_SENDS;++j) - { - if(ALSource->Send[j].Slot) - ALSource->Send[j].Slot->refcount--; - ALSource->Send[j].Slot = NULL; - } + for(j = 0;j < MAX_SENDS;++j) + { + if(ALSource->Send[j].Slot) + ALSource->Send[j].Slot->refcount--; + ALSource->Send[j].Slot = NULL; + } - // Decrement Source count - Context->SourceCount--; + // Decrement Source count + Context->SourceCount--; - // Remove Source from list of Sources - list = &Context->Source; - while(*list && *list != ALSource) - list = &(*list)->next; + // Remove Source from list of Sources + list = &Context->Source; + while(*list && *list != ALSource) + list = &(*list)->next; - if(*list) - *list = (*list)->next; - ALTHUNK_REMOVEENTRY(ALSource->source); + if(*list) + *list = (*list)->next; + ALTHUNK_REMOVEENTRY(ALSource->source); - memset(ALSource,0,sizeof(ALsource)); - free(ALSource); - } + memset(ALSource,0,sizeof(ALsource)); + free(ALSource); } - } } - else - { - // Trying to delete more Sources than have been generated - alSetError(AL_INVALID_NAME); - } } else { |