Standardize some New/Delete methods
This commit is contained in:
+3
-3
@@ -1356,7 +1356,7 @@ ALboolean loadSf2(Reader *stream, ALsoundfont *soundfont, ALCcontext *context)
|
||||
Soundfont_Destruct(&sfont);
|
||||
/* If the buffer ends up unused, delete it. */
|
||||
if(ReadRef(&buffer->ref) == 0)
|
||||
DeleteBuffer(context->Device, buffer->id);
|
||||
DeleteBuffer(context->Device, buffer);
|
||||
|
||||
return AL_TRUE;
|
||||
|
||||
@@ -1365,13 +1365,13 @@ error:
|
||||
{
|
||||
ALCdevice *device = context->Device;
|
||||
for(i = 0;i < presets_size;i++)
|
||||
DeletePreset(presets[i], device);
|
||||
DeletePreset(device, presets[i]);
|
||||
free(presets);
|
||||
}
|
||||
|
||||
Soundfont_Destruct(&sfont);
|
||||
if(buffer)
|
||||
DeleteBuffer(context->Device, buffer->id);
|
||||
DeleteBuffer(context->Device, buffer);
|
||||
|
||||
return AL_FALSE;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ typedef struct ALbuffer {
|
||||
} ALbuffer;
|
||||
|
||||
ALbuffer *NewBuffer(ALCcontext *context);
|
||||
void DeleteBuffer(ALCdevice *device, ALuint bufid);
|
||||
void DeleteBuffer(ALCdevice *device, ALbuffer *buffer);
|
||||
|
||||
ALenum LoadData(ALbuffer *buffer, ALuint freq, ALenum NewFormat, ALsizei frames, enum UserFmtChannels SrcChannels, enum UserFmtType SrcType, const ALvoid *data, ALsizei align, ALboolean storesrc);
|
||||
|
||||
|
||||
@@ -92,11 +92,11 @@ typedef struct ALfontsound {
|
||||
ALuint id;
|
||||
} ALfontsound;
|
||||
|
||||
void ALfontsound_Destruct(ALfontsound *self);
|
||||
void ALfontsound_setPropi(ALfontsound *self, ALCcontext *context, ALenum param, ALint value);
|
||||
void ALfontsound_setModStagei(ALfontsound *self, ALCcontext *context, ALsizei stage, ALenum param, ALint value);
|
||||
|
||||
ALfontsound *NewFontsound(ALCcontext *context);
|
||||
void DeleteFontsound(ALCdevice *device, ALfontsound *sound);
|
||||
|
||||
inline struct ALfontsound *LookupFontsound(ALCdevice *device, ALuint id)
|
||||
{ return (struct ALfontsound*)LookupUIntMapKey(&device->FontsoundMap, id); }
|
||||
@@ -124,7 +124,7 @@ typedef struct ALsfpreset {
|
||||
} ALsfpreset;
|
||||
|
||||
ALsfpreset *NewPreset(ALCcontext *context);
|
||||
void DeletePreset(ALsfpreset *preset, ALCdevice *device);
|
||||
void DeletePreset(ALCdevice *device, ALsfpreset *preset);
|
||||
|
||||
inline struct ALsfpreset *LookupPreset(ALCdevice *device, ALuint id)
|
||||
{ return (struct ALsfpreset*)LookupUIntMapKey(&device->PresetMap, id); }
|
||||
|
||||
+6
-6
@@ -104,7 +104,10 @@ AL_API ALvoid AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *buffers)
|
||||
}
|
||||
|
||||
for(i = 0;i < n;i++)
|
||||
DeleteBuffer(device, buffers[i]);
|
||||
{
|
||||
if((ALBuf=LookupBuffer(device, buffers[i])) != NULL)
|
||||
DeleteBuffer(device, ALBuf);
|
||||
}
|
||||
|
||||
done:
|
||||
ALCcontext_DecRef(context);
|
||||
@@ -1294,12 +1297,9 @@ ALbuffer *NewBuffer(ALCcontext *context)
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void DeleteBuffer(ALCdevice *device, ALuint bufid)
|
||||
void DeleteBuffer(ALCdevice *device, ALbuffer *buffer)
|
||||
{
|
||||
ALbuffer *buffer;
|
||||
|
||||
if((buffer=RemoveBuffer(device, bufid)) == NULL)
|
||||
return;
|
||||
RemoveBuffer(device, buffer->id);
|
||||
FreeThunkEntry(buffer->id);
|
||||
|
||||
free(buffer->data);
|
||||
|
||||
+16
-9
@@ -15,9 +15,11 @@
|
||||
|
||||
extern inline struct ALfontsound *LookupFontsound(ALCdevice *device, ALuint id);
|
||||
extern inline struct ALfontsound *RemoveFontsound(ALCdevice *device, ALuint id);
|
||||
extern inline struct ALsfmodulator *LookupModulator(ALfontsound *sound, ALuint id);
|
||||
extern inline struct ALsfmodulator *RemoveModulator(ALfontsound *sound, ALuint id);
|
||||
|
||||
static void ALfontsound_Construct(ALfontsound *self);
|
||||
void ALfontsound_Destruct(ALfontsound *self);
|
||||
static void ALfontsound_Destruct(ALfontsound *self);
|
||||
void ALfontsound_setPropi(ALfontsound *self, ALCcontext *context, ALenum param, ALint value);
|
||||
static ALsfmodulator *ALfontsound_getModStage(ALfontsound *self, ALsizei stage);
|
||||
void ALfontsound_setModStagei(ALfontsound *self, ALCcontext *context, ALsizei stage, ALenum param, ALint value);
|
||||
@@ -76,13 +78,8 @@ AL_API ALvoid AL_APIENTRY alDeleteFontsoundsSOFT(ALsizei n, const ALuint *ids)
|
||||
|
||||
for(i = 0;i < n;i++)
|
||||
{
|
||||
if((inst=RemoveFontsound(device, ids[i])) == NULL)
|
||||
continue;
|
||||
|
||||
ALfontsound_Destruct(inst);
|
||||
|
||||
memset(inst, 0, sizeof(*inst));
|
||||
free(inst);
|
||||
if((inst=LookupFontsound(device, ids[i])) == NULL)
|
||||
DeleteFontsound(device, inst);
|
||||
}
|
||||
|
||||
done:
|
||||
@@ -510,6 +507,16 @@ ALfontsound *NewFontsound(ALCcontext *context)
|
||||
return sound;
|
||||
}
|
||||
|
||||
void DeleteFontsound(ALCdevice *device, ALfontsound *sound)
|
||||
{
|
||||
RemoveFontsound(device, sound->id);
|
||||
|
||||
ALfontsound_Destruct(sound);
|
||||
|
||||
memset(sound, 0, sizeof(*sound));
|
||||
free(sound);
|
||||
}
|
||||
|
||||
|
||||
static void ALfontsound_Construct(ALfontsound *self)
|
||||
{
|
||||
@@ -587,7 +594,7 @@ static void ALfontsound_Construct(ALfontsound *self)
|
||||
self->id = 0;
|
||||
}
|
||||
|
||||
void ALfontsound_Destruct(ALfontsound *self)
|
||||
static void ALfontsound_Destruct(ALfontsound *self)
|
||||
{
|
||||
ALsizei i;
|
||||
|
||||
|
||||
+3
-4
@@ -71,9 +71,8 @@ AL_API ALvoid AL_APIENTRY alDeletePresetsSOFT(ALsizei n, const ALuint *ids)
|
||||
|
||||
for(i = 0;i < n;i++)
|
||||
{
|
||||
if((preset=LookupPreset(device, ids[i])) == NULL)
|
||||
continue;
|
||||
DeletePreset(preset, device);
|
||||
if((preset=LookupPreset(device, ids[i])) != NULL)
|
||||
DeletePreset(device, preset);
|
||||
}
|
||||
|
||||
done:
|
||||
@@ -282,7 +281,7 @@ ALsfpreset *NewPreset(ALCcontext *context)
|
||||
return preset;
|
||||
}
|
||||
|
||||
void DeletePreset(ALsfpreset *preset, ALCdevice *device)
|
||||
void DeletePreset(ALCdevice *device, ALsfpreset *preset)
|
||||
{
|
||||
RemovePreset(device, preset->id);
|
||||
|
||||
|
||||
@@ -357,7 +357,8 @@ void ALsoundfont_deleteSoundfont(ALsoundfont *self, ALCdevice *device)
|
||||
|
||||
sounds = ExchangePtr((XchgPtr*)&preset->Sounds, NULL);
|
||||
num_sounds = ExchangeInt(&preset->NumSounds, 0);
|
||||
DeletePreset(preset, device);
|
||||
|
||||
DeletePreset(device, preset);
|
||||
preset = NULL;
|
||||
|
||||
for(j = 0;j < num_sounds;j++)
|
||||
@@ -377,9 +378,7 @@ void ALsoundfont_deleteSoundfont(ALsoundfont *self, ALCdevice *device)
|
||||
buffer = sounds[j]->Buffer;
|
||||
else if(sounds[j]->Buffer)
|
||||
assert(sounds[j]->Buffer == buffer);
|
||||
RemoveFontsound(device, sounds[j]->id);
|
||||
ALfontsound_Destruct(sounds[j]);
|
||||
free(sounds[j]);
|
||||
DeleteFontsound(device, sounds[j]);
|
||||
sounds[j] = NULL;
|
||||
}
|
||||
}
|
||||
@@ -393,7 +392,7 @@ void ALsoundfont_deleteSoundfont(ALsoundfont *self, ALCdevice *device)
|
||||
if(buffer)
|
||||
{
|
||||
assert(ReadRef(&buffer->ref) == 0);
|
||||
DeleteBuffer(device, buffer->id);
|
||||
DeleteBuffer(device, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user