deleting buffers/sources before or after destroying context/device
BENMOUSSA Younes <[email protected]>
| Newsgroups | gmane.comp.lib.openal |
|---|---|
| Message-ID | <[email protected]> |
Hi everyone,
i want to know when we create sources and buffers we should free them
after or before destroying context/device ?.
Because i had i little problem when i try to free my buffers here is my
source code:
/**************************************************/
void ASS_SoundFree(ASS_Sound* sound)
{
ALuint buffer;
int queued;
int i;
if(sound)
{
alGetSourcei(sound->source, AL_BUFFERS_QUEUED, &queued);
while(queued--) alSourceUnqueueBuffers(sound->source, 1, &buffer);
for(i=0;i<ASS_SOUND_MAX_BUFFERS;i++) /* ASS_SOUND_MAX_BUFFERS=4*/
{
if( alIsBuffer(sound->bid[i]))
alDeleteBuffers(1,&sound->bid[i]);
}
ASS_SoundSourceFree(sound->source);
if(sound->file) sf_close(sound->file),sound->file=NULL;
pthread_join(sound->thread,NULL);
free(sound);
}
}
/**************************************************/
so the problm is when i close my device i got this in the stdin:
AL lib: ALc.c:1818: alcCloseDevice(): deleting 4 buffer(s).
Why this function delete my buffers ? its already done with my function
ASS_SoundFree ? i dont understand...
here is another functions how i init and shutdown openAL:
/******************************************************/
static ASS_Device* d=NULL; /* global variable */
void ASS_Close(void)
{
int i;
if (d) /* a structur contain ALCdevice context and more
informations...*/
{
for(i=0; i<ASS_MAX_SOURCES; i++) /* delete all allocated sources */
{
if( alIsSource(d->sources[i].id) )
alDeleteSources(1,&d->sources[i].id);
}
alcMakeContextCurrent(NULL);
alcDestroyContext(d->context);
alcCloseDevice(d->device);
if(d->sources) free(d->sources);
free(d);
}
}
/******************************************************/
ASSboolean ASS_Init(void)
{
ASSuint current_source=0;
int i=0;
if (!(d=(ASS_Device*)malloc(sizeof(*d)))) return 0;
d->device=NULL;
d->context=NULL;
d->device = alcOpenDevice(NULL);
if (! d->device )
return 0;
d->context = alcCreateContext(d->device, NULL);
if (!d->context)
return 0;
if (!alcMakeContextCurrent(d->context))
return 0;
d->max_sources=0;
for(i=0; (i<ASS_MAX_SOURCES) && (alGetError() == AL_NO_ERROR) ; i++)
{
alGenSources(1,¤t_source);
if(alIsSource(current_source))
{
d->sources[i].id=current_source;
d->sources[i].used=ASS_FALSE;
}
}
d->max_sources=i;
return 1;
}
/******************************************************/
Thank you.
_______________________________________________
Openal mailing list
[email protected]
http://opensource.creative.com/mailman/listinfo/openal