From d4d5ee3154bc4382c9680ad0b2cd40911c503b25 Mon Sep 17 00:00:00 2001 From: Deve Date: Thu, 21 Sep 2023 23:14:00 +0200 Subject: [PATCH] Free loaded data after alBufferData() (#147) https://github.com/kcat/openal-soft/blob/master/examples/alplay.c#L266 --- src/client/sound_openal.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/client/sound_openal.cpp b/src/client/sound_openal.cpp index 434f3807f..5246c6dcf 100644 --- a/src/client/sound_openal.cpp +++ b/src/client/sound_openal.cpp @@ -109,7 +109,6 @@ struct SoundBuffer ALenum format; ALsizei freq; ALuint buffer_id; - std::vector buffer; }; SoundBuffer *load_opened_ogg_file(OggVorbis_File *oggFile, @@ -120,6 +119,7 @@ SoundBuffer *load_opened_ogg_file(OggVorbis_File *oggFile, long bytes; char array[BUFFER_SIZE]; // Local fixed size array vorbis_info *pInfo; + std::vector buffer; SoundBuffer *snd = new SoundBuffer; @@ -151,12 +151,12 @@ SoundBuffer *load_opened_ogg_file(OggVorbis_File *oggFile, } // Append to end of buffer - snd->buffer.insert(snd->buffer.end(), array, array + bytes); + buffer.insert(buffer.end(), array, array + bytes); } while (bytes > 0); alGenBuffers(1, &snd->buffer_id); alBufferData(snd->buffer_id, snd->format, - &(snd->buffer[0]), snd->buffer.size(), + &buffer[0], buffer.size(), snd->freq); ALenum error = alGetError(); @@ -170,6 +170,7 @@ SoundBuffer *load_opened_ogg_file(OggVorbis_File *oggFile, // << filename_for_logging << " loaded" << std::endl; // Clean up! + buffer.clear(); ov_clear(oggFile); return snd;