Bug fix for SDL sound on FreeBSD OS (Issue #449). Force audio spec sample set size to be a power of 2 per SDL documentation.
This commit is contained in:
parent
333d2364c1
commit
ed4bb30ffe
|
@ -190,6 +190,7 @@ InitSound()
|
||||||
SDL_AudioSpec spec;
|
SDL_AudioSpec spec;
|
||||||
const char *driverName;
|
const char *driverName;
|
||||||
int frmRateSampleAdj = 0;
|
int frmRateSampleAdj = 0;
|
||||||
|
int samplesPerFrame;
|
||||||
|
|
||||||
g_config->getOption("SDL.Sound", &sound);
|
g_config->getOption("SDL.Sound", &sound);
|
||||||
if (!sound)
|
if (!sound)
|
||||||
|
@ -219,17 +220,23 @@ InitSound()
|
||||||
spec.freq = s_SampleRate = soundrate;
|
spec.freq = s_SampleRate = soundrate;
|
||||||
spec.format = AUDIO_S16SYS;
|
spec.format = AUDIO_S16SYS;
|
||||||
spec.channels = 1;
|
spec.channels = 1;
|
||||||
//spec.samples = 512;
|
spec.samples = 512; // This must stay a power of two per SDL documentation
|
||||||
spec.samples = (int)( ( (double)s_SampleRate / getBaseFrameRate() ) );
|
|
||||||
spec.callback = fillaudio;
|
spec.callback = fillaudio;
|
||||||
spec.userdata = 0;
|
spec.userdata = 0;
|
||||||
|
|
||||||
|
samplesPerFrame = (int)( ( (double)s_SampleRate / getBaseFrameRate() ) );
|
||||||
|
|
||||||
|
if ( samplesPerFrame >= 1024 )
|
||||||
|
{
|
||||||
|
spec.samples = 1024;
|
||||||
|
}
|
||||||
|
|
||||||
s_BufferSize = soundbufsize * soundrate / 1000;
|
s_BufferSize = soundbufsize * soundrate / 1000;
|
||||||
|
|
||||||
// For safety, set a bare minimum:
|
// For safety, set a bare minimum:
|
||||||
if (s_BufferSize < spec.samples * 2)
|
if (s_BufferSize < spec.samples * 4)
|
||||||
{
|
{
|
||||||
s_BufferSize = spec.samples * 2;
|
s_BufferSize = spec.samples * 4;
|
||||||
}
|
}
|
||||||
s_BufferSize25 = s_BufferSize/4;
|
s_BufferSize25 = s_BufferSize/4;
|
||||||
s_BufferSize50 = s_BufferSize/2;
|
s_BufferSize50 = s_BufferSize/2;
|
||||||
|
|
Loading…
Reference in New Issue