Mercurial > SDL_sound_CoreAudio
diff SDL_sound.c @ 485:137c0b00ea4c
Added Sound_NewSampleFromMem(), and implementation of RWops pooling.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Sun, 27 Feb 2005 19:53:25 +0000 |
parents | 3e705c9180e5 |
children | c00e26a7e0b6 |
line wrap: on
line diff
--- a/SDL_sound.c Sun Feb 27 19:50:54 2005 +0000 +++ b/SDL_sound.c Sun Feb 27 19:53:25 2005 +0000 @@ -450,6 +450,10 @@ static Sound_Sample *alloc_sample(SDL_RWops *rw, Sound_AudioInfo *desired, Uint32 bufferSize) { + /* + * !!! FIXME: We're going to need to pool samples, since the mixer + * !!! FIXME: might be allocating tons of these on a regular basis. + */ Sound_Sample *retval = malloc(sizeof (Sound_Sample)); Sound_SampleInternal *internal = malloc(sizeof (Sound_SampleInternal)); if ((retval == NULL) || (internal == NULL)) @@ -693,6 +697,7 @@ ext = strrchr(filename, '.'); rw = SDL_RWFromFile(filename, "rb"); + /* !!! FIXME: rw = RWops_FromFile(filename, "rb");*/ BAIL_IF_MACRO(rw == NULL, SDL_GetError(), NULL); if (ext != NULL) @@ -702,6 +707,26 @@ } /* Sound_NewSampleFromFile */ +Sound_Sample *Sound_NewSampleFromMem(const Uint8 *data, + Uint32 size, + const char *ext, + Sound_AudioInfo *desired, + Uint32 bufferSize); +{ + SDL_RWops *rw; + + BAIL_IF_MACRO(!initialized, ERR_NOT_INITIALIZED, NULL); + BAIL_IF_MACRO(data == NULL, ERR_INVALID_ARGUMENT, NULL); + BAIL_IF_MACRO(size == 0, ERR_INVALID_ARGUMENT, NULL); + + rw = SDL_RWFromMem(data, size); + /* !!! FIXME: rw = RWops_FromMem(data, size);*/ + BAIL_IF_MACRO(rw == NULL, SDL_GetError(), NULL); + + return(Sound_NewSample(rw, ext, desired, bufferSize)); +} /* Sound_NewSampleFromMem */ + + void Sound_FreeSample(Sound_Sample *sample) { Sound_SampleInternal *internal;