Browse Source

Limit DirectSound maximum sample rate

Regan Green 19 hours ago
parent
commit
f9e82031f4
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/audio/directsound/SDL_directsound.c

+ 2 - 1
src/audio/directsound/SDL_directsound.c

@@ -526,6 +526,7 @@ static int DSOUND_OpenDevice(_THIS, const char *devname)
             tried_format = SDL_TRUE;
 
             this->spec.format = test_format;
+            this->spec.freq = SDL_min(DSBFREQUENCY_MAX, this->spec.freq);
 
             /* Update the fragment size as size in bytes */
             SDL_CalculateAudioSpec(&this->spec);
@@ -580,7 +581,7 @@ static int DSOUND_OpenDevice(_THIS, const char *devname)
                 }
 
                 wfmt.Format.wBitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format);
-                wfmt.Format.nChannels = this->spec.channels;
+                wfmt.Format.nChannels = (WORD)this->spec.channels;
                 wfmt.Format.nSamplesPerSec = this->spec.freq;
                 wfmt.Format.nBlockAlign = wfmt.Format.nChannels * (wfmt.Format.wBitsPerSample / 8);
                 wfmt.Format.nAvgBytesPerSec = wfmt.Format.nSamplesPerSec * wfmt.Format.nBlockAlign;