| Summary: | SDL_MixAudio broken in SDL 2.0 | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Gabriele Greco <gabriele.greco> |
| Component: | audio | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | major | ||
| Priority: | P2 | CC: | philipp.wiesemann |
| Version: | HG 2.0 | ||
| Hardware: | x86 | ||
| OS: | Linux | ||
SDL_memcpy() replaces content but SDL_MixAudio() mixes with existing content. I think one can not just be replaced with the other. In SDL 1.2 the buffer passed to the audio callback was (always?) filled with silence. In SDL 2.0 this is no more the case (e.g. 2012-07-05). Now silence must be filled in the callback function if SDL_MixAudio() should be used or it will mix with old content. There is an example in the wiki for SDL_MixAudio() but no info in the "Migration Guide". (In reply to comment #1) > SDL_memcpy() replaces content but SDL_MixAudio() mixes with existing > content. I think one can not just be replaced with the other. > > In SDL 1.2 the buffer passed to the audio callback was (always?) filled with > silence. In SDL 2.0 this is no more the case (e.g. 2012-07-05). Now silence > must be filled in the callback function if SDL_MixAudio() should be used or > it will mix with old content. There is an example in the wiki for > SDL_MixAudio() but no info in the "Migration Guide". The "Migration Guide" in the wiki was changed to contain this information. Thanks for updating the Migration Guide! |
It seems that SDL_MixAudio is broken in recent SDL2 releases (at least in linux and iOS), to test this is enough to modify the test loopwave.c in the SDL distribution to use SDL_MixAudio instead of SDL_memcpy (sample human readable diff from HG): @@ -57,14 +57,16 @@ /* Go! */ while (waveleft <= len) { - SDL_memcpy(stream, waveptr, waveleft); + SDL_MixAudio(stream, waveptr, waveleft, SDL_MIX_MAXVOLUME); stream += waveleft; len -= waveleft; waveptr = wave.sound; waveleft = wave.soundlen; wave.soundpos = 0; } - SDL_memcpy(stream, waveptr, len); + SDL_MixAudio(stream, waveptr, len, SDL_MIX_MAXVOLUME); wave.soundpos += len; } ... the audio output is wrong also with the default "sample.wav" I tried to look with HG to the change that caused this regression but I cannot find it. But I'm quite sure that before the naming change from 1.3 -> 2.0 and the removal of the 1.2 compatibility layer SDL_MixAudio used to work :) Anyway hg summary output says I'm using the following version: parent: 6673:78f18a929123 tip Nobody will EVER use more than 8 buttons. Oh wait... Nobody will EVER use more than 32 buttons... branch: default