Skip to content

Commit

Permalink
This still segfaults
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed May 7, 2017
1 parent 03db246 commit e0082c1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions audiomixer-test.diff
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;

3 comments on commit e0082c1

@inactive123
Copy link
Contributor Author

@inactive123 inactive123 commented on e0082c1 May 7, 2017

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.

@leiradel
Copy link
Contributor

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 its audio_mixer_sound_t* return value. When you want to play the sound, call audio_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, the audio_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.

@leiradel
Copy link
Contributor

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.

Please sign in to comment.