[Scummvm-cvs-logs] SF.net SVN: scummvm: [24691] scummvm/trunk/backends/platform

knakos at users.sourceforge.net knakos at users.sourceforge.net
Sun Nov 12 12:47:50 CET 2006


Revision: 24691
          http://svn.sourceforge.net/scummvm/?rev=24691&view=rev
Author:   knakos
Date:     2006-11-12 03:47:43 -0800 (Sun, 12 Nov 2006)

Log Message:
-----------
Implement Fingolfin's modular backend timer, savefile and mixer managers

Modified Paths:
--------------
    scummvm/trunk/backends/platform/sdl/sdl.cpp
    scummvm/trunk/backends/platform/wince/wince-sdl.cpp
    scummvm/trunk/backends/platform/wince/wince-sdl.h

Modified: scummvm/trunk/backends/platform/sdl/sdl.cpp
===================================================================
--- scummvm/trunk/backends/platform/sdl/sdl.cpp	2006-11-12 11:43:46 UTC (rev 24690)
+++ scummvm/trunk/backends/platform/sdl/sdl.cpp	2006-11-12 11:47:43 UTC (rev 24691)
@@ -37,8 +37,15 @@
 #include "SymbianOs.h"
 #endif
 
-#if !defined(_WIN32_WCE) && !defined(__MAEMO__)
+#ifndef __MAEMO__
 
+static Uint32 timer_handler(Uint32 interval, void *param) {
+	((DefaultTimerManager *)param)->handler();
+	return interval;
+}
+
+#ifndef _WIN32_WCE
+
 #if defined (WIN32)
 int __stdcall WinMain(HINSTANCE /*hInst*/, HINSTANCE /*hPrevInst*/,  LPSTR /*lpCmdLine*/, int /*iShowCmd*/) {
 	SDL_SetModuleHandle(GetModuleHandle(NULL));
@@ -46,11 +53,6 @@
 }
 #endif
 
-static Uint32 timer_handler(Uint32 interval, void *param) {
-	((DefaultTimerManager *)param)->handler();
-	return interval;
-}
-
 int main(int argc, char *argv[]) {
 
 #if defined(__SYMBIAN32__)
@@ -114,7 +116,8 @@
 	g_system->quit();	// TODO: Consider removing / replacing this!
 	return res;
 }
-#endif
+#endif	// defined(_WIN32_WCE)
+#endif	// defined(__MAEMO__)
 
 void OSystem_SDL::initBackend() {
 	assert(!_inited);

Modified: scummvm/trunk/backends/platform/wince/wince-sdl.cpp
===================================================================
--- scummvm/trunk/backends/platform/wince/wince-sdl.cpp	2006-11-12 11:43:46 UTC (rev 24690)
+++ scummvm/trunk/backends/platform/wince/wince-sdl.cpp	2006-11-12 11:47:43 UTC (rev 24691)
@@ -28,6 +28,7 @@
 #include "base/main.h"
 #include "base/plugins.h"
 #include "common/timer.h"
+#include "sound/mixer.h"
 
 #include "common/config-manager.h"
 
@@ -79,9 +80,9 @@
 static FILE *stderr_file;
 
 // Static member inits
-
+typedef void (*SoundProc)(void *param, byte *buf, int len);
 bool OSystem_WINCE3::_soundMaster = true;
-OSystem::SoundProc OSystem_WINCE3::_originalSoundProc = NULL;
+SoundProc OSystem_WINCE3::_originalSoundProc = NULL;
 
 bool _isSmartphone = false;
 bool _hasSmartphoneResolution = false;
@@ -247,11 +248,14 @@
 
 	loadDeviceConfiguration();
 
-	// FIXME: We are currently not calling OSystem_SDL::initBackend() here.
-	// Maybe on purpose, but this is possibly a bit risky... E.g. _inited
-	// won't be set correctly due to this... Can we change this? Maybe after
-	// some changes to the base SDL backend?
-	//OSystem_SDL::initBackend();
+	// Instantiate our own sound mixer
+	// mixer init is postponed until a game engine is selected.
+	if (_mixer == 0) {
+		_mixer = new Audio::Mixer();
+	}
+
+	// Chain init
+	OSystem_SDL::initBackend();
 }
 
 int OSystem_WINCE3::getScreenWidth() {
@@ -307,6 +311,7 @@
 	if (_hasSmartphoneResolution) _panelVisible = false;	// init correctly in smartphones
 	create_toolbar();
 
+	_mixer = 0;
 
 	// Mouse backup (temporary code)
 	_mouseBackupOld = (byte*)malloc(MAX_MOUSE_W * MAX_MOUSE_H * MAX_SCALING * 2);
@@ -604,6 +609,41 @@
 	_toolbarHandler.setVisible(false);
 }
 
+bool OSystem_WINCE3::setSoundCallback(SoundProc proc, void *param) {
+	SDL_AudioSpec desired;
+	int thread_priority;
+
+	if (_sampleRate == 0)
+		warning("setSoundCallback called with 0 _sampleRate. Audio will not work.");
+
+	memset(&desired, 0, sizeof(desired));
+
+	_originalSoundProc = proc;
+	desired.freq = _sampleRate;
+	desired.format = AUDIO_S16SYS;
+	desired.channels = 2;
+	//desired.samples = 2048;
+	desired.samples = 128;
+	desired.callback = private_sound_proc;
+	desired.userdata = param;
+
+	// Add sound thread priority
+	if (!ConfMan.hasKey("sound_thread_priority")) {
+		thread_priority = THREAD_PRIORITY_NORMAL;
+	}
+	else
+		thread_priority = ConfMan.getInt("sound_thread_priority");
+
+	desired.thread_priority = thread_priority;
+
+	if (SDL_OpenAudio(&desired, NULL) != 0) {
+		warning("Could not open audio device: %s", SDL_GetError());
+		return false;
+	}
+	SDL_PauseAudio(0);
+	return true;
+}
+
 void OSystem_WINCE3::private_sound_proc(void *param, byte *buf, int len) {
 	(*_originalSoundProc)(param, buf, len);
 	if (!_soundMaster)
@@ -647,7 +687,7 @@
 	}
 	// See if the output frequency is forced by the game
 	if (gameid == "ft" || gameid == "dig" || gameid == "comi" || gameid == "queen" ||
-		strncmp(gameid.c_str(), "sword", 5) == 0 ||	strncmp(gameid.c_str(), "sky", 3) == 0)
+		strncmp(gameid.c_str(), "sword", 5) == 0 || strncmp(gameid.c_str(), "sky", 3) == 0)
 			_sampleRate = SAMPLES_PER_SEC_NEW;
 	else {
 		if (ConfMan.hasKey("high_sample_rate") && ConfMan.getBool("high_sample_rate"))
@@ -669,9 +709,14 @@
 }
 
 void OSystem_WINCE3::setWindowCaption(const char *caption) {
+//void OSystem_WINCE3::engineInit() {
 	check_mappings(); // called here to initialize virtual keys handling
+	
 	//update_game_settings();
-	get_sample_rate(); // called here to initialize mixer
+	// finalize mixer init
+	get_sample_rate();
+	bool result = setSoundCallback(Audio::Mixer::mixCallback, _mixer);
+	_mixer->setReady(result);
 }
 
 bool OSystem_WINCE3::openCD(int drive) {
@@ -728,37 +773,6 @@
 	return OSystem_SDL::getFeatureState(f);
 }
 
-bool OSystem_WINCE3::setSoundCallback(SoundProc proc, void *param) {
-	SDL_AudioSpec desired;
-	int thread_priority;
-
-	memset(&desired, 0, sizeof(desired));
-
-	_originalSoundProc = proc;
-	desired.freq = _sampleRate;
-	desired.format = AUDIO_S16SYS;
-	desired.channels = 2;
-	//desired.samples = 2048;
-	desired.samples = 128;
-	desired.callback = private_sound_proc;
-	desired.userdata = param;
-
-	// Add sound thread priority
-	if (!ConfMan.hasKey("sound_thread_priority")) {
-		thread_priority = THREAD_PRIORITY_NORMAL;
-	}
-	else
-		thread_priority = ConfMan.getInt("sound_thread_priority");
-
-	desired.thread_priority = thread_priority;
-
-	if (SDL_OpenAudio(&desired, NULL) != 0) {
-		return false;
-	}
-	SDL_PauseAudio(0);
-	return true;
-}
-
 void OSystem_WINCE3::check_mappings() {
 		CEActionsPocket *instance;
 

Modified: scummvm/trunk/backends/platform/wince/wince-sdl.h
===================================================================
--- scummvm/trunk/backends/platform/wince/wince-sdl.h	2006-11-12 11:43:46 UTC (rev 24690)
+++ scummvm/trunk/backends/platform/wince/wince-sdl.h	2006-11-12 11:47:43 UTC (rev 24691)
@@ -82,13 +82,15 @@
 	void quit();
 	// Overloaded from SDL_Commmon (master volume and sample rate subtleties)
 	bool setSoundCallback(SoundProc proc, void *param);
+	// Overloaded from OSystem
+	//void engineInit();
 
 	// Overloaded from SDL_Common (FIXME)
 	void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale); // overloaded by CE backend
 	void undrawMouse();
 	void blitCursor();
 	void setMousePos(int x, int y);
-    void copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h); // overloaded by CE backend (FIXME)
+	void copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h); // overloaded by CE backend (FIXME)
 	void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h);
 	void showOverlay();
 	void hideOverlay();


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