From e123a4f22f552155268e8a809f8b1c81d35cc7b9 Mon Sep 17 00:00:00 2001 From: stephena Date: Tue, 18 Nov 2003 21:39:02 +0000 Subject: [PATCH] Some cosmetic changes to the sound classes, in preparation for a minor reorganization of Sound code (the update performed in the main loop will eventually be done by Console::update() only, instead of updating the display and sound separately). git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@213 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/emucore/Sound.cxx | 10 +++------- stella/src/emucore/Sound.hxx | 26 +++++++++++++++----------- stella/src/ui/sdl/mainSDL.cxx | 4 ++-- stella/src/ui/sound/SoundALSA.cxx | 7 +++---- stella/src/ui/sound/SoundALSA.hxx | 17 +++-------------- stella/src/ui/sound/SoundOSS.cxx | 7 +++---- stella/src/ui/sound/SoundOSS.hxx | 17 +++-------------- stella/src/ui/sound/SoundSDL.cxx | 11 +++++------ stella/src/ui/sound/SoundSDL.hxx | 21 +++++---------------- 9 files changed, 42 insertions(+), 78 deletions(-) diff --git a/stella/src/emucore/Sound.cxx b/stella/src/emucore/Sound.cxx index 987d78384..e14b5a306 100644 --- a/stella/src/emucore/Sound.cxx +++ b/stella/src/emucore/Sound.cxx @@ -13,13 +13,14 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Sound.cxx,v 1.6 2003-11-06 22:22:32 stephena Exp $ +// $Id: Sound.cxx,v 1.7 2003-11-18 21:39:02 stephena Exp $ //============================================================================ #include "Sound.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Sound::Sound() + : myPauseStatus(false) { } @@ -46,12 +47,7 @@ bool Sound::isSuccessfullyInitialized() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Sound::setSoundVolume(Int32 volume) -{ -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Sound::pause(bool status) +void Sound::setVolume(Int32 volume) { } diff --git a/stella/src/emucore/Sound.hxx b/stella/src/emucore/Sound.hxx index fbe8412fe..52f7d827b 100644 --- a/stella/src/emucore/Sound.hxx +++ b/stella/src/emucore/Sound.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Sound.hxx,v 1.6 2003-11-06 22:22:32 stephena Exp $ +// $Id: Sound.hxx,v 1.7 2003-11-18 21:39:02 stephena Exp $ //============================================================================ #ifndef SOUND_HXX @@ -28,7 +28,7 @@ to compile Stella with no sound support whatsoever. @author Stephen Anthony - @version $Id: Sound.hxx,v 1.6 2003-11-06 22:22:32 stephena Exp $ + @version $Id: Sound.hxx,v 1.7 2003-11-18 21:39:02 stephena Exp $ */ class Sound { @@ -70,15 +70,7 @@ class Sound @param percent The new volume percentage level for the sound device */ - virtual void setSoundVolume(Int32 percent); - - /** - Sets the pause status. While pause is selected, updateSound() - should not play any sound. - - @param status Toggle pause based on status - */ - virtual void pause(bool status); + virtual void setVolume(Int32 percent); /** Update the sound device using the audio sample from the specified @@ -87,5 +79,17 @@ class Sound @param mediaSource The media source to get audio samples from. */ virtual void updateSound(MediaSource& mediaSource); + + /** + Sets the pause status. While pause is selected, update() + should not play any sound. + + @param status Toggle pause based on status + */ + void pause(bool status) { myPauseStatus = status; } + + protected: + // The pause status + bool myPauseStatus; }; #endif diff --git a/stella/src/ui/sdl/mainSDL.cxx b/stella/src/ui/sdl/mainSDL.cxx index 79276e17b..fcd07a179 100644 --- a/stella/src/ui/sdl/mainSDL.cxx +++ b/stella/src/ui/sdl/mainSDL.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: mainSDL.cxx,v 1.58 2003-11-09 23:53:20 stephena Exp $ +// $Id: mainSDL.cxx,v 1.59 2003-11-18 21:39:02 stephena Exp $ //============================================================================ #include @@ -771,7 +771,7 @@ int main(int argc, char* argv[]) theSound = new Sound(); } - theSound->setSoundVolume(theSettings->getInt("volume")); + theSound->setVolume(theSettings->getInt("volume")); // Get just the filename of the file containing the ROM image const char* filename = (!strrchr(file, '/')) ? file : strrchr(file, '/') + 1; diff --git a/stella/src/ui/sound/SoundALSA.cxx b/stella/src/ui/sound/SoundALSA.cxx index 4943d0f08..60f5caf0b 100644 --- a/stella/src/ui/sound/SoundALSA.cxx +++ b/stella/src/ui/sound/SoundALSA.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: SoundALSA.cxx,v 1.4 2003-11-06 22:22:32 stephena Exp $ +// $Id: SoundALSA.cxx,v 1.5 2003-11-18 21:39:02 stephena Exp $ //============================================================================ #include @@ -30,8 +30,7 @@ SoundALSA::SoundALSA() myOriginalVolumeLeft(-1), myOriginalVolumeRight(-1), myBufferSize(0), - mySampleRate(0), - myPauseStatus(false) + mySampleRate(0) { Int32 err; char pcmName[] = "plughw:0,0"; @@ -216,7 +215,7 @@ bool SoundALSA::isSuccessfullyInitialized() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void SoundALSA::setSoundVolume(Int32 percent) +void SoundALSA::setVolume(Int32 percent) { if(myIsInitializedFlag && myMixerElem) { diff --git a/stella/src/ui/sound/SoundALSA.hxx b/stella/src/ui/sound/SoundALSA.hxx index fd8f04fca..53a75c513 100644 --- a/stella/src/ui/sound/SoundALSA.hxx +++ b/stella/src/ui/sound/SoundALSA.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: SoundALSA.hxx,v 1.4 2003-11-06 22:22:32 stephena Exp $ +// $Id: SoundALSA.hxx,v 1.5 2003-11-18 21:39:02 stephena Exp $ //============================================================================ #ifndef SOUNDALSA_HXX @@ -30,7 +30,7 @@ Advanced Linux Sound Architecture (ALSA) version 0.9.x API. @author Stephen Anthony - @version $Id: SoundALSA.hxx,v 1.4 2003-11-06 22:22:32 stephena Exp $ + @version $Id: SoundALSA.hxx,v 1.5 2003-11-18 21:39:02 stephena Exp $ */ class SoundALSA : public Sound { @@ -72,15 +72,7 @@ class SoundALSA : public Sound @param percent The new volume percentage level for the sound device */ - void setSoundVolume(Int32 percent); - - /** - Sets the pause status. While pause is selected, updateSound() - should not play any sound. - - @param status Toggle pause based on status - */ - void pause(bool status) { myPauseStatus = status; } + void setVolume(Int32 percent); /** Update the sound device using the audio sample from the specified @@ -118,8 +110,5 @@ class SoundALSA : public Sound // PCM sample rate uInt32 mySampleRate; - - // The pause status - bool myPauseStatus; }; #endif diff --git a/stella/src/ui/sound/SoundOSS.cxx b/stella/src/ui/sound/SoundOSS.cxx index 3541e014b..c30518d3a 100644 --- a/stella/src/ui/sound/SoundOSS.cxx +++ b/stella/src/ui/sound/SoundOSS.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: SoundOSS.cxx,v 1.3 2003-11-06 22:22:32 stephena Exp $ +// $Id: SoundOSS.cxx,v 1.4 2003-11-18 21:39:02 stephena Exp $ //============================================================================ #include @@ -39,8 +39,7 @@ SoundOSS::SoundOSS() myDspFd(-1), myMixerFd(-1), myOriginalVolume(-1), - mySampleRate(0), - myPauseStatus(false) + mySampleRate(0) { // Open the sound device for writing if((myDspFd = open(DSP_DEVICE, O_WRONLY, 0)) == -1) @@ -172,7 +171,7 @@ bool SoundOSS::isSuccessfullyInitialized() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void SoundOSS::setSoundVolume(Int32 percent) +void SoundOSS::setVolume(Int32 percent) { if(myIsInitializedFlag && (myMixerFd != -1)) { diff --git a/stella/src/ui/sound/SoundOSS.hxx b/stella/src/ui/sound/SoundOSS.hxx index 274399e02..63455c727 100644 --- a/stella/src/ui/sound/SoundOSS.hxx +++ b/stella/src/ui/sound/SoundOSS.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: SoundOSS.hxx,v 1.3 2003-11-06 22:22:32 stephena Exp $ +// $Id: SoundOSS.hxx,v 1.4 2003-11-18 21:39:02 stephena Exp $ //============================================================================ #ifndef SOUNDOSS_HXX @@ -28,7 +28,7 @@ Open Sound System (OSS) API. @author Bradford W. Mott - @version $Id: SoundOSS.hxx,v 1.3 2003-11-06 22:22:32 stephena Exp $ + @version $Id: SoundOSS.hxx,v 1.4 2003-11-18 21:39:02 stephena Exp $ */ class SoundOSS : public Sound { @@ -70,15 +70,7 @@ class SoundOSS : public Sound @param percent The new volume percentage level for the sound device */ - void setSoundVolume(Int32 percent); - - /** - Sets the pause status. While pause is selected, updateSound() - should not play any sound. - - @param status Toggle pause based on status - */ - void pause(bool status) { myPauseStatus = status; } + void setVolume(Int32 percent); /** Update the sound device using the audio sample from the specified @@ -103,8 +95,5 @@ class SoundOSS : public Sound // DSP sample rate uInt32 mySampleRate; - - // The pause status - bool myPauseStatus; }; #endif diff --git a/stella/src/ui/sound/SoundSDL.cxx b/stella/src/ui/sound/SoundSDL.cxx index 4f67fd81f..35d36ce8a 100644 --- a/stella/src/ui/sound/SoundSDL.cxx +++ b/stella/src/ui/sound/SoundSDL.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: SoundSDL.cxx,v 1.3 2003-11-06 22:22:33 stephena Exp $ +// $Id: SoundSDL.cxx,v 1.4 2003-11-18 21:39:02 stephena Exp $ //============================================================================ #include @@ -21,16 +21,15 @@ #include "SoundSDL.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -SoundSDL::SoundSDL(bool activate) +SoundSDL::SoundSDL() : myCurrentVolume(SDL_MIX_MAXVOLUME), myFragmentSize(1024), myIsInitializedFlag(false), myIsMuted(false), mySampleRate(31400), - mySampleQueue(mySampleRate), - myPauseStatus(false) + mySampleQueue(mySampleRate) { - if(activate) + if(1) { if(SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) { @@ -144,7 +143,7 @@ void SoundSDL::closeDevice() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void SoundSDL::setSoundVolume(Int32 percent) +void SoundSDL::setVolume(Int32 percent) { if(myIsInitializedFlag) { diff --git a/stella/src/ui/sound/SoundSDL.hxx b/stella/src/ui/sound/SoundSDL.hxx index 97233c09c..4775b0a5a 100644 --- a/stella/src/ui/sound/SoundSDL.hxx +++ b/stella/src/ui/sound/SoundSDL.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: SoundSDL.hxx,v 1.3 2003-11-06 22:22:33 stephena Exp $ +// $Id: SoundSDL.hxx,v 1.4 2003-11-18 21:39:02 stephena Exp $ //============================================================================ #ifndef SOUNDSDL_HXX @@ -29,7 +29,7 @@ This class implements the sound API for SDL. @author Stephen Anthony and Bradford W. Mott - @version $Id: SoundSDL.hxx,v 1.3 2003-11-06 22:22:33 stephena Exp $ + @version $Id: SoundSDL.hxx,v 1.4 2003-11-18 21:39:02 stephena Exp $ */ class SoundSDL : public Sound { @@ -37,7 +37,7 @@ class SoundSDL : public Sound /** Create a new sound object */ - SoundSDL(bool activate = true); + SoundSDL(); /** Destructor @@ -78,15 +78,7 @@ class SoundSDL : public Sound @param percent The new volume percentage level for the sound device */ - void setSoundVolume(Int32 percent); - - /** - Sets the pause status. While pause is selected, updateSound() - should not play any sound. - - @param status Toggle pause based on status - */ - void pause(bool status) { myPauseStatus = status; } + void setVolume(Int32 percent); /** Update the sound device using the audio sample from the specified @@ -173,12 +165,9 @@ class SoundSDL : public Sound // Queue which holds samples from the media source before they are played SampleQueue mySampleQueue; - // The pause status - bool myPauseStatus; - private: // Callback function invoked by the SDL Audio library when it needs data static void callback(void* udata, uInt8* stream, int len); }; -#endif +#endif