aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlejandro Marzini2010-06-20 20:19:53 +0000
committerAlejandro Marzini2010-06-20 20:19:53 +0000
commite0fe48032d6e27445a9c963e70cf82bf57b5fd5a (patch)
tree401b0d2e6f9477373ae88033ddfd28362f8db647
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
-rw-r--r--backends/mixer/sdl/sdl-mixer.cpp56
-rw-r--r--backends/mixer/sdl/sdl-mixer.h3
-rw-r--r--common/timer.h15
-rw-r--r--sound/mixer.cpp4
-rw-r--r--sound/mixer_intern.h4
5 files changed, 34 insertions, 48 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);
diff --git a/common/timer.h b/common/timer.h
index 057d6268c8..3a48875842 100644
--- a/common/timer.h
+++ b/common/timer.h
@@ -56,21 +56,6 @@ public:
* and no instance of this callback will be running anymore.
*/
virtual void removeTimerProc(TimerProc proc) = 0;
-
- /**
- * Get the number of milliseconds since the program was started.
- */
- virtual uint32 getMillis() = 0;
-
- /**
- * Delay for a specified amount of milliseconds
- */
- virtual void delayMillis(uint msecs) = 0;
-
- /**
- * Get the current time and date
- */
- virtual void getTimeAndDate(TimeDate &t) const = 0;
};
} // End of namespace Common
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index 17ae723650..3d8b55683f 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -431,10 +431,6 @@ int MixerImpl::getVolumeForSoundType(SoundType type) const {
return _volumeForSoundType[type];
}
-void MixerImpl::setSampleRate(uint sampleRate) {
- _sampleRate = sampleRate;
-}
-
#pragma mark -
#pragma mark --- Channel implementations ---
#pragma mark -
diff --git a/sound/mixer_intern.h b/sound/mixer_intern.h
index c1b7df941f..014be7abf2 100644
--- a/sound/mixer_intern.h
+++ b/sound/mixer_intern.h
@@ -60,7 +60,7 @@ private:
OSystem *_syst;
Common::Mutex _mutex;
- uint _sampleRate;
+ const uint _sampleRate;
bool _mixerReady;
uint32 _handleSeed;
@@ -127,8 +127,6 @@ public:
* their audio system has been completed.
*/
void setReady(bool ready);
-
- void setSampleRate(uint sampleRate);
};