directsound: recalculate audiospec size before creating secondary buffer.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 09 Aug 2016 19:35:46 -0400
changeset 10275757db914bde0
parent 10274 cc6461b9c5bc
child 10276 470698f90685
directsound: recalculate audiospec size before creating secondary buffer.

I think this was a bug before? Maybe I'm misunderstanding this, but it looks
like it was working because we allocate room for 8 chunks...
src/audio/directsound/SDL_directsound.c
     1.1 --- a/src/audio/directsound/SDL_directsound.c	Tue Aug 09 16:58:32 2016 -0400
     1.2 +++ b/src/audio/directsound/SDL_directsound.c	Tue Aug 09 19:35:46 2016 -0400
     1.3 @@ -361,9 +361,6 @@
     1.4      wfmt.nBlockAlign = wfmt.nChannels * (wfmt.wBitsPerSample / 8);
     1.5      wfmt.nAvgBytesPerSec = wfmt.nSamplesPerSec * wfmt.nBlockAlign;
     1.6  
     1.7 -    /* Update the fragment size as size in bytes */
     1.8 -    SDL_CalculateAudioSpec(&this->spec);
     1.9 -
    1.10      /* Try to set primary mixing privileges */
    1.11      if (focus) {
    1.12          result = IDirectSound_SetCooperativeLevel(sndObj,
    1.13 @@ -447,6 +444,8 @@
    1.14          case AUDIO_F32:
    1.15              tried_format = SDL_TRUE;
    1.16              this->spec.format = test_format;
    1.17 +            /* Update the fragment size as size in bytes */
    1.18 +            SDL_CalculateAudioSpec(&this->spec);
    1.19              this->hidden->num_buffers = CreateSecondary(this, NULL);
    1.20              if (this->hidden->num_buffers > 0) {
    1.21                  valid_format = SDL_TRUE;