Don't allow device format changes in Mix_OpenAudio().
authorRyan C. Gordon <icculus@icculus.org>
Wed, 11 Oct 2017 18:36:53 -0400
changeset 738e6fa426a79dd
parent 737 d3fa63933df2
child 739 70a1cf75d4bc
Don't allow device format changes in Mix_OpenAudio().

This tends to cause problems when you get a float32 format on WASAPI or
CoreAudio but expected Sint16. This change is only for the legacy API: if you
want more control here, use Mix_OpenAudioDevice() instead.
mixer.c
     1.1 --- a/mixer.c	Sat Sep 23 00:06:14 2017 -0700
     1.2 +++ b/mixer.c	Wed Oct 11 18:36:53 2017 -0400
     1.3 @@ -518,8 +518,9 @@
     1.4  /* Open the mixer with a certain desired audio format */
     1.5  int Mix_OpenAudio(int frequency, Uint16 format, int nchannels, int chunksize)
     1.6  {
     1.7 -    return Mix_OpenAudioDevice(frequency, format, nchannels, chunksize,
     1.8 -			       NULL, SDL_AUDIO_ALLOW_ANY_CHANGE);
     1.9 +    return Mix_OpenAudioDevice(frequency, format, nchannels, chunksize, NULL,
    1.10 +                                SDL_AUDIO_ALLOW_FREQUENCY_CHANGE |
    1.11 +                                SDL_AUDIO_ALLOW_CHANNELS_CHANGE);
    1.12  }
    1.13  
    1.14  /* Dynamically change the number of channels managed by the mixer.