-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
03db246
commit e0082c1
Showing
1 changed file
with
14 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
diff --git a/audio/audio_driver.c b/audio/audio_driver.c | ||
index 10dcbc5b3..dd959f900 100644 | ||
--- a/audio/audio_driver.c | ||
+++ b/audio/audio_driver.c | ||
@@ -597,6 +597,9 @@ static bool audio_driver_flush(const int16_t *data, size_t samples) | ||
|
||
audio_driver_resampler->process(audio_driver_resampler_data, &src_data); | ||
|
||
+ audio_mixer_load_wav("/home/squarepusher/nav.wav"); | ||
+ audio_mixer_mix(audio_driver_output_samples_buf, src_data.output_frames); | ||
+ | ||
output_data = audio_driver_output_samples_buf; | ||
output_frames = (unsigned)src_data.output_frames; | ||
|
e0082c1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leiradel - I get segfaults with this code at audio_mixer.c - specifically the one_shot_resample function.
e0082c1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mixer works similarly to SDL_mixer. Don't load the WAV in
audio_driver_flush
, it'll leask memory every frame with the WAV data. Load it somewhere else (i.e. during initialization), and save itsaudio_mixer_sound_t*
return value. When you want to play the sound, callaudio_mixer_play
(i.e. in response of a button press)with that pointer.
When done with the WAV, call
audio_mixer_destroy
. Make sure it's not playing, theaudio_mixer_stop_cb_t
callback can help keep track of what is playing and what's not.The process is exactly the same with OGG files.
e0082c1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the audio mixer PR, #4687,
nav.wav
segfaulting was fixed in #4712.Maybe increasing the safeguard size? I.e.
*samples_out = samples_in * ratio + 16;
. This is all very fragile, ideally the audio resamplers should provide a function which returns the number of samples required for resampling a buffer.