aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorAlejandro Marzini2010-06-20 20:19:53 +0000
committerAlejandro Marzini2010-06-20 20:19:53 +0000
commite0fe48032d6e27445a9c963e70cf82bf57b5fd5a (patch)
tree401b0d2e6f9477373ae88033ddfd28362f8db647 /backends
parent4a850209d739111b539fc39bcf003abd6e061538 (diff)
downloadscummvm-rg350-e0fe48032d6e27445a9c963e70cf82bf57b5fd5a.tar.gz
scummvm-rg350-e0fe48032d6e27445a9c963e70cf82bf57b5fd5a.tar.bz2
scummvm-rg350-e0fe48032d6e27445a9c963e70cf82bf57b5fd5a.zip
Made _sampleRate constant again in Audio::MixerImpl. (And Committing "common/timer.h" that should have been included in r50095)
svn-id: r50097
Diffstat (limited to 'backends')
-rw-r--r--backends/mixer/sdl/sdl-mixer.cpp56
-rw-r--r--backends/mixer/sdl/sdl-mixer.h3
2 files changed, 33 insertions, 26 deletions
diff --git a/backends/mixer/sdl/sdl-mixer.cpp b/backends/mixer/sdl/sdl-mixer.cpp
index e56b64f8ec..490489718d 100644
--- a/backends/mixer/sdl/sdl-mixer.cpp
+++ b/backends/mixer/sdl/sdl-mixer.cpp
@@ -39,7 +39,33 @@ SdlMixerImpl::SdlMixerImpl(OSystem *system)
_soundMutex(0), _soundCond(0), _soundThread(0),
_soundThreadIsRunning(false), _soundThreadShouldQuit(false),
#endif
- MixerImpl(system, SAMPLES_PER_SEC) {
+ MixerImpl(system, getSamplesPerSec()) {
+ if (_openAudio) {
+ setReady(true);
+
+#if MIXER_DOUBLE_BUFFERING
+ initThreadedMixer(_obtainedRate.samples * 4);
+#endif
+
+ // start the sound system
+ SDL_PauseAudio(0);
+ }
+ else {
+ setReady(false);
+ }
+}
+
+SdlMixerImpl::~SdlMixerImpl() {
+ setReady(false);
+
+ SDL_CloseAudio();
+
+#if MIXER_DOUBLE_BUFFERING
+ deinitThreadedMixer();
+#endif
+}
+
+uint SdlMixerImpl::getSamplesPerSec() {
SDL_AudioSpec desired;
// Determine the desired output sampling frequency.
@@ -67,38 +93,16 @@ SdlMixerImpl::SdlMixerImpl(OSystem *system)
if (SDL_OpenAudio(&desired, &_obtainedRate) != 0) {
warning("Could not open audio device: %s", SDL_GetError());
-
- setSampleRate(samplesPerSec);
-
- setReady(false);
+ _openAudio = false;
} else {
// Note: This should be the obtained output rate, but it seems that at
// least on some platforms SDL will lie and claim it did get the rate
// even if it didn't. Probably only happens for "weird" rates, though.
samplesPerSec = _obtainedRate.freq;
debug(1, "Output sample rate: %d Hz", samplesPerSec);
-
- setSampleRate(samplesPerSec);
-
- setReady(true);
-
-#if MIXER_DOUBLE_BUFFERING
- initThreadedMixer(_obtainedRate.samples * 4);
-#endif
-
- // start the sound system
- SDL_PauseAudio(0);
+ _openAudio = true;
}
-}
-
-SdlMixerImpl::~SdlMixerImpl() {
- setReady(false);
-
- SDL_CloseAudio();
-
-#if MIXER_DOUBLE_BUFFERING
- deinitThreadedMixer();
-#endif
+ return samplesPerSec;
}
#if MIXER_DOUBLE_BUFFERING
diff --git a/backends/mixer/sdl/sdl-mixer.h b/backends/mixer/sdl/sdl-mixer.h
index 272c3934a6..a21dcfd188 100644
--- a/backends/mixer/sdl/sdl-mixer.h
+++ b/backends/mixer/sdl/sdl-mixer.h
@@ -51,6 +51,9 @@ public:
protected:
SDL_AudioSpec _obtainedRate;
+ bool _openAudio;
+
+ uint getSamplesPerSec();
static void mixSdlCallback(void *s, byte *samples, int len);