diff --git a/src/FAudioGMS.c b/src/FAudioGMS.c index 0aa7834..dfc64ed 100644 --- a/src/FAudioGMS.c +++ b/src/FAudioGMS.c @@ -33,6 +33,11 @@ #include "../lib/FAudio/include/FAudio.h" #define DR_WAV_IMPLEMENTATION +#define DRWAV_MALLOC(sz) SDL_malloc((sz)) +#define DRWAV_REALLOC(p, sz) SDL_realloc((p), (sz)) +#define DRWAV_FREE(p) SDL_free((p)) +#define DRWAV_COPY_MEMORY(dst, src, sz) SDL_memcpy((dst), (src), (sz)) +#define DRWAV_ZERO_MEMORY(p, sz) SDL_memset((p), 0, (sz)) #include "../lib/dr_wav.h" #include @@ -361,14 +366,16 @@ double FAudioGMS_StaticSound_LoadWAV(char *filePath) { Log("Error opening WAV file: "); Log(filePath); + SDL_free(sound); + return -1; } - sound->buffer.AudioBytes = (uint32_t)(frameCount * sizeof(float)); + sound->buffer.AudioBytes = (uint32_t)(frameCount * sound->channels * sizeof(float)); sound->buffer.Flags = FAUDIO_END_OF_STREAM; sound->buffer.LoopBegin = 0; sound->buffer.LoopCount = 0; sound->buffer.LoopLength = 0; - sound->buffer.pAudioData = (uint8_t*) pSampleData; + sound->buffer.pAudioData = pSampleData; sound->buffer.pContext = NULL; sound->buffer.PlayBegin = 0; sound->buffer.PlayLength = 0; @@ -388,8 +395,7 @@ double FAudioGMS_StaticSound_LoadWAV(char *filePath) device->staticSoundCount += 1; } - device->staticSounds[device->staticSoundCount] = sound; - device->staticSoundCount += 1; + device->staticSounds[sound->id] = sound; return (double)sound->id; } @@ -652,7 +658,7 @@ static FAudioGMS_SoundInstance* FAudioGMS_INTERNAL_SoundInstance_CreateFromStati device->soundInstanceCount += 1; } - device->soundInstances[device->soundInstanceCount] = instance; + device->soundInstances[instance->id] = instance; return instance; } diff --git a/visualc/FAudioGMS.vcxproj b/visualc/FAudioGMS.vcxproj index 63a0fea..10a7b15 100644 --- a/visualc/FAudioGMS.vcxproj +++ b/visualc/FAudioGMS.vcxproj @@ -98,6 +98,7 @@ +