SDL_MixAudio broken?

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 :)–
Bye,
Gabry

This was an intentional change by Ryan to remove a memset in the audio
mixing callback. In general you’re filling audio entirely, and if you’re
not you can do a memset yourself before passing the buffer around to be
mixed into.On Thu, Nov 15, 2012 at 2:51 AM, Gabriele Greco <gabriele.greco at darts.it>wrote:

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 :slight_smile:


Bye,
Gabry


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

This was an intentional change by Ryan to remove a memset in the audio
mixing callback. In general you’re filling audio entirely, and if you’re
not you can do a memset yourself before passing the buffer around to be
mixed into.

Yep you are right… adding memset in the mix callback solves the
problem… this is why I could not find SDL_MixAudio changes in the HG
history :)On Fri, Nov 16, 2012 at 7:08 AM, Sam Lantinga wrote:


Bye,
Gabry