aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-07-06 05:00:05 -0700
committerChris Robinson <[email protected]>2014-07-06 05:00:05 -0700
commitf809d3c81aa3c9d868a207e291d19e406ad7ee61 (patch)
treea77016fbe087036a111756652fe0b705259b2e12 /OpenAL32
parentd0a64fe191aabe085cabe1737c44ff6a47a3d4d8 (diff)
Allow ALsoundfont_deleteSoundfont to handle multiple buffers
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/alSoundfont.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/OpenAL32/alSoundfont.c b/OpenAL32/alSoundfont.c
index 6ba4772c..40a93021 100644
--- a/OpenAL32/alSoundfont.c
+++ b/OpenAL32/alSoundfont.c
@@ -341,9 +341,10 @@ void ALsoundfont_deleteSoundfont(ALsoundfont *self, ALCdevice *device)
{
ALsfpreset **presets;
ALsizei num_presets;
- ALbuffer *buffer = NULL;
+ VECTOR(ALbuffer*) buffers;
ALsizei i;
+ VECTOR_INIT(buffers);
presets = ExchangePtr((XchgPtr*)&self->Presets, NULL);
num_presets = ExchangeInt(&self->NumPresets, 0);
@@ -374,10 +375,17 @@ void ALsoundfont_deleteSoundfont(ALsoundfont *self, ALCdevice *device)
if(sounds[j] && ReadRef(&sounds[j]->ref) == 0)
{
deleting = AL_TRUE;
- if(!buffer)
- buffer = sounds[j]->Buffer;
- else if(sounds[j]->Buffer)
- assert(sounds[j]->Buffer == buffer);
+ if(sounds[j]->Buffer)
+ {
+ ALbuffer *buffer = sounds[j]->Buffer;
+ ALbuffer **iter;
+
+#define MATCH_BUFFER(_i) (buffer == *(_i))
+ VECTOR_FIND_IF(iter, ALbuffer*, buffers, MATCH_BUFFER);
+ if(iter == VECTOR_ITER_END(buffers))
+ VECTOR_PUSH_BACK(buffers, buffer);
+#undef MATCH_BUFFER
+ }
DeleteFontsound(device, sounds[j]);
sounds[j] = NULL;
}
@@ -389,11 +397,13 @@ void ALsoundfont_deleteSoundfont(ALsoundfont *self, ALCdevice *device)
ALsoundfont_Destruct(self);
free(self);
- if(buffer)
- {
- assert(ReadRef(&buffer->ref) == 0);
- DeleteBuffer(device, buffer);
- }
+#define DELETE_BUFFER(iter) do { \
+ assert(ReadRef(&(*(iter))->ref) == 0); \
+ DeleteBuffer(device, *(iter)); \
+} while(0)
+ VECTOR_FOR_EACH(ALbuffer*, buffers, DELETE_BUFFER);
+ VECTOR_DEINIT(buffers);
+#undef DELETE_BUFFER
}