Added ability to use either the X11 or SDL sound code. As of now,

the X11 sound code is more mature.

Changed all occurrences of ::close() to ::closeDevice().


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@138 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2002-11-11 22:09:07 +00:00
parent e4f94c55c9
commit af8b8c82f7
1 changed files with 19 additions and 14 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: mainSDL.cxx,v 1.35 2002-11-11 02:56:27 stephena Exp $ // $Id: mainSDL.cxx,v 1.36 2002-11-11 22:09:07 stephena Exp $
//============================================================================ //============================================================================
#include <fstream> #include <fstream>
@ -39,7 +39,12 @@
#include "System.hxx" #include "System.hxx"
#include "RectList.hxx" #include "RectList.hxx"
#include "Settings.hxx" #include "Settings.hxx"
#include "SoundSDL.hxx"
#ifdef USE_OSS_SOUND
#include "SoundX11.hxx"
#else
#include "SoundSDL.hxx"
#endif
#ifdef HAVE_PNG #ifdef HAVE_PNG
#include "Snapshot.hxx" #include "Snapshot.hxx"
@ -1659,7 +1664,12 @@ int main(int argc, char* argv[])
} }
// Create a sound object for playing audio // Create a sound object for playing audio
#ifdef USE_OSS_SOUND
SoundX11 sound;
#else
SoundSDL sound; SoundSDL sound;
#endif
sound.setSoundVolume(settings->theDesiredVolume); sound.setSoundVolume(settings->theDesiredVolume);
// Get just the filename of the file containing the ROM image // Get just the filename of the file containing the ROM image
@ -1682,14 +1692,14 @@ int main(int argc, char* argv[])
if(!setupDisplay()) if(!setupDisplay())
{ {
cerr << "ERROR: Couldn't set up display.\n"; cerr << "ERROR: Couldn't set up display.\n";
sound.close(); sound.closeDevice();
cleanup(); cleanup();
return 0; return 0;
} }
if(!setupJoystick()) if(!setupJoystick())
{ {
cerr << "ERROR: Couldn't set up joysticks.\n"; cerr << "ERROR: Couldn't set up joysticks.\n";
sound.close(); sound.closeDevice();
cleanup(); cleanup();
return 0; return 0;
} }
@ -1702,8 +1712,7 @@ int main(int argc, char* argv[])
{ {
// Set up accurate timing stuff // Set up accurate timing stuff
uInt32 startTime, delta; uInt32 startTime, delta;
uInt32 timePerFrame = uInt32 timePerFrame = (uInt32)(1000000.0 / (double)settings->theDesiredFrameRate);
(uInt32)(1000000.0 / (double)settings->theDesiredFrameRate);
// Set the base for the timers // Set the base for the timers
frameTime = 0; frameTime = 0;
@ -1718,6 +1727,7 @@ int main(int argc, char* argv[])
} }
// Call handleEvents here to see if user pressed pause // Call handleEvents here to see if user pressed pause
startTime = getTicks();
handleEvents(); handleEvents();
if(thePauseIndicator) if(thePauseIndicator)
{ {
@ -1726,11 +1736,9 @@ int main(int argc, char* argv[])
continue; continue;
} }
startTime = getTicks();
theConsole->mediaSource().update(); theConsole->mediaSource().update();
updateDisplay(theConsole->mediaSource()); updateDisplay(theConsole->mediaSource());
sound.updateSound(theConsole->mediaSource()); sound.updateSound(theConsole->mediaSource());
handleEvents();
// Now, waste time if we need to so that we are at the desired frame rate // Now, waste time if we need to so that we are at the desired frame rate
for(;;) for(;;)
@ -1765,16 +1773,13 @@ int main(int argc, char* argv[])
} }
startTime = getTicks(); startTime = getTicks();
handleEvents();
if(!thePauseIndicator) if(!thePauseIndicator)
{ {
theConsole->mediaSource().update(); theConsole->mediaSource().update();
}
updateDisplay(theConsole->mediaSource());
if(!thePauseIndicator)
{
sound.updateSound(theConsole->mediaSource()); sound.updateSound(theConsole->mediaSource());
} }
handleEvents(); updateDisplay(theConsole->mediaSource());
currentTime = getTicks(); currentTime = getTicks();
virtualTime += timePerFrame; virtualTime += timePerFrame;
@ -1805,7 +1810,7 @@ int main(int argc, char* argv[])
} }
// Cleanup time ... // Cleanup time ...
sound.close(); sound.closeDevice();
cleanup(); cleanup();
return 0; return 0;
} }