Stops every stream that plays data, frees the bytes it was loaded from and clears it, so that nothing points into it any more.
The player reads the sound's buffer (and the samples and decoder state that point into it) for as long as a stream
uses it, so a loaded sound cannot just be freed while it plays. This stops those streams first, the way
stop_stream_abruptly(data) does: Sound_Player_Config.release_asset is called for each, and the *Sound_Stream pointers
the program holds for them are dead after that, so drop them there. Then buffer is freed with context.allocator, which
is where load_audio_file got it, and data is reset to an empty Sound_Data. Call it from the thread that updates the player.
Do not use it on data whose buffer the program owns some other way (a constant, an arena): stop the streams with
stop_stream_abruptly(data) and leave the memory alone. A stream made with make_stream but not yet started is not known to
the player and must be started or dropped by the caller first.
samples: [64] s16;
data := Sound_Data.{ loaded = true, type = .LINEAR_SAMPLE_ARRAY, samples = samples.data, nsamples_times_nchannels = samples.count };
data.buffer = copy_string("stands in for the file bytes");
release_sound_data(*data);
assert(!data.loaded && data.buffer.count == 0);Doesn't run in the browser (skipped on wasm).
release_sound_data :: (data: *Sound_Data)
Stops every stream that plays data, frees the bytes it was loaded from and clears it, so that nothing points into it any more.
The player reads the sound's buffer (and the samples and decoder state that point into it) for as long as a stream
uses it, so a loaded sound cannot just be freed while it plays. This stops those streams first, the way
stop_stream_abruptly(data) does: Sound_Player_Config.release_asset is called for each, and the *Sound_Stream pointers
the program holds for them are dead after that, so drop them there. Then buffer is freed with context.allocator, which
is where load_audio_file got it, and data is reset to an empty Sound_Data. Call it from the thread that updates the player.
Do not use it on data whose buffer the program owns some other way (a constant, an arena): stop the streams with
stop_stream_abruptly(data) and leave the memory alone. A stream made with make_stream but not yet started is not known to
the player and must be started or dropped by the caller first.
Parameters
- data: *Sound_Data
samples: [64] s16;
data := Sound_Data.{ loaded = true, type = .LINEAR_SAMPLE_ARRAY, samples = samples.data, nsamples_times_nchannels = samples.count };
data.buffer = copy_string("stands in for the file bytes");
release_sound_data(*data);
assert(!data.loaded && data.buffer.count == 0);Doesn't run in the browser (skipped on wasm).