[Scummvm-cvs-logs] SF.net SVN: scummvm:[50097] scummvm/branches/gsoc2010-opengl

vgvgf at users.sourceforge.net vgvgf at users.sourceforge.net
Sun Jun 20 22:19:54 CEST 2010


Revision: 50097
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50097&view=rev
Author:   vgvgf
Date:     2010-06-20 20:19:53 +0000 (Sun, 20 Jun 2010)

Log Message:
-----------
Made _sampleRate constant again in Audio::MixerImpl. (And Committing "common/timer.h" that should have been included in r50095)

Modified Paths:
--------------
    scummvm/branches/gsoc2010-opengl/backends/mixer/sdl/sdl-mixer.cpp
    scummvm/branches/gsoc2010-opengl/backends/mixer/sdl/sdl-mixer.h
    scummvm/branches/gsoc2010-opengl/common/timer.h
    scummvm/branches/gsoc2010-opengl/sound/mixer.cpp
    scummvm/branches/gsoc2010-opengl/sound/mixer_intern.h

Modified: scummvm/branches/gsoc2010-opengl/backends/mixer/sdl/sdl-mixer.cpp
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/mixer/sdl/sdl-mixer.cpp	2010-06-20 20:17:22 UTC (rev 50096)
+++ scummvm/branches/gsoc2010-opengl/backends/mixer/sdl/sdl-mixer.cpp	2010-06-20 20:19:53 UTC (rev 50097)
@@ -39,7 +39,33 @@
 	_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,42 +93,20 @@
 
 	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;
 	}
+	return samplesPerSec;
 }
 
-SdlMixerImpl::~SdlMixerImpl() {
-	setReady(false);
-
-	SDL_CloseAudio();
-
 #if MIXER_DOUBLE_BUFFERING
-	deinitThreadedMixer();
-#endif
-}
 
-#if MIXER_DOUBLE_BUFFERING
-
 void SdlMixerImpl::mixerProducerThread() {
 	byte nextSoundBuffer;
 

Modified: scummvm/branches/gsoc2010-opengl/backends/mixer/sdl/sdl-mixer.h
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/mixer/sdl/sdl-mixer.h	2010-06-20 20:17:22 UTC (rev 50096)
+++ scummvm/branches/gsoc2010-opengl/backends/mixer/sdl/sdl-mixer.h	2010-06-20 20:19:53 UTC (rev 50097)
@@ -51,7 +51,10 @@
 
 protected:
 	SDL_AudioSpec _obtainedRate;
+	bool _openAudio;
 
+	uint getSamplesPerSec();
+
 	static void mixSdlCallback(void *s, byte *samples, int len);
 
 #ifdef MIXER_DOUBLE_BUFFERING

Modified: scummvm/branches/gsoc2010-opengl/common/timer.h
===================================================================
--- scummvm/branches/gsoc2010-opengl/common/timer.h	2010-06-20 20:17:22 UTC (rev 50096)
+++ scummvm/branches/gsoc2010-opengl/common/timer.h	2010-06-20 20:19:53 UTC (rev 50097)
@@ -56,21 +56,6 @@
 	 * 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

Modified: scummvm/branches/gsoc2010-opengl/sound/mixer.cpp
===================================================================
--- scummvm/branches/gsoc2010-opengl/sound/mixer.cpp	2010-06-20 20:17:22 UTC (rev 50096)
+++ scummvm/branches/gsoc2010-opengl/sound/mixer.cpp	2010-06-20 20:19:53 UTC (rev 50097)
@@ -431,10 +431,6 @@
 	return _volumeForSoundType[type];
 }
 
-void MixerImpl::setSampleRate(uint sampleRate) {
-	_sampleRate = sampleRate;
-}
-
 #pragma mark -
 #pragma mark --- Channel implementations ---
 #pragma mark -

Modified: scummvm/branches/gsoc2010-opengl/sound/mixer_intern.h
===================================================================
--- scummvm/branches/gsoc2010-opengl/sound/mixer_intern.h	2010-06-20 20:17:22 UTC (rev 50096)
+++ scummvm/branches/gsoc2010-opengl/sound/mixer_intern.h	2010-06-20 20:19:53 UTC (rev 50097)
@@ -60,7 +60,7 @@
 	OSystem *_syst;
 	Common::Mutex _mutex;
 
-	uint _sampleRate;
+	const uint _sampleRate;
 	bool _mixerReady;
 	uint32 _handleSeed;
 
@@ -127,8 +127,6 @@
 	 * their audio system has been completed.
 	 */
 	void setReady(bool ready);
-
-	void setSampleRate(uint sampleRate);
 };
 
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list