memory fixes
							parent
							
								
									ed5f0e46fd
								
							
						
					
					
						commit
						fc8949d79d
					
				|  | @ -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 <stdio.h> | ||||
|  | @ -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; | ||||
| } | ||||
|  |  | |||
|  | @ -98,6 +98,7 @@ | |||
|     <ClCompile Include="..\src\FAudioGMS.c" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClInclude Include="..\lib\dr_wav.h" /> | ||||
|     <ClInclude Include="..\src\FAudioGMS.h" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue