Limit DirectSound maximum sample rate

This commit is contained in:
Regan Green
2026-03-25 20:44:13 -04:00
committed by Ryan C. Gordon
parent 3debb9e2bb
commit f9e82031f4

View File

@@ -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;