Fixes for SDL throttle
- Throttle should be set on init - SDL auido device was not being correctly closed on throttle change
This commit is contained in:
parent
8fcc32eeeb
commit
891f17d62f
|
@ -28,7 +28,7 @@ const float SoundSDL::_delay = 0.032f;
|
||||||
SoundSDL::SoundSDL():
|
SoundSDL::SoundSDL():
|
||||||
_rbuf(0),
|
_rbuf(0),
|
||||||
_dev(-1),
|
_dev(-1),
|
||||||
current_rate(0),
|
current_rate(throttle),
|
||||||
_initialized(false)
|
_initialized(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -91,8 +91,9 @@ void SoundSDL::write(uint16_t * finalWave, int length)
|
||||||
SDL_SemWait(_semBufferEmpty);
|
SDL_SemWait(_semBufferEmpty);
|
||||||
if (throttle > 0 && throttle != current_rate)
|
if (throttle > 0 && throttle != current_rate)
|
||||||
{
|
{
|
||||||
SDL_CloseAudio();
|
SDL_CloseAudioDevice(_dev);
|
||||||
init(soundGetSampleRate() * throttle / 100);
|
//Reinit on throttle change:
|
||||||
|
init(soundGetSampleRate());
|
||||||
current_rate = throttle;
|
current_rate = throttle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,7 +114,7 @@ void SoundSDL::write(uint16_t * finalWave, int length)
|
||||||
bool SoundSDL::init(long sampleRate)
|
bool SoundSDL::init(long sampleRate)
|
||||||
{
|
{
|
||||||
SDL_AudioSpec audio;
|
SDL_AudioSpec audio;
|
||||||
audio.freq = sampleRate;
|
audio.freq = sampleRate * throttle / 100;
|
||||||
audio.format = AUDIO_S16SYS;
|
audio.format = AUDIO_S16SYS;
|
||||||
audio.channels = 2;
|
audio.channels = 2;
|
||||||
audio.samples = 1024;
|
audio.samples = 1024;
|
||||||
|
|
Loading…
Reference in New Issue