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
This commit is contained in:
stephena 2003-11-18 21:39:02 +00:00
parent 6a4af2b17a
commit e123a4f22f
9 changed files with 42 additions and 78 deletions

View File

@ -13,13 +13,14 @@
// 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: 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" #include "Sound.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Sound::Sound() Sound::Sound()
: myPauseStatus(false)
{ {
} }
@ -46,12 +47,7 @@ bool Sound::isSuccessfullyInitialized() const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Sound::setSoundVolume(Int32 volume) void Sound::setVolume(Int32 volume)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Sound::pause(bool status)
{ {
} }

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: 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 #ifndef SOUND_HXX
@ -28,7 +28,7 @@
to compile Stella with no sound support whatsoever. to compile Stella with no sound support whatsoever.
@author Stephen Anthony @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 class Sound
{ {
@ -70,15 +70,7 @@ class Sound
@param percent The new volume percentage level for the sound device @param percent The new volume percentage level for the sound device
*/ */
virtual void setSoundVolume(Int32 percent); virtual void setVolume(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);
/** /**
Update the sound device using the audio sample from the specified 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. @param mediaSource The media source to get audio samples from.
*/ */
virtual void updateSound(MediaSource& mediaSource); 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 #endif

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.58 2003-11-09 23:53:20 stephena Exp $ // $Id: mainSDL.cxx,v 1.59 2003-11-18 21:39:02 stephena Exp $
//============================================================================ //============================================================================
#include <fstream> #include <fstream>
@ -771,7 +771,7 @@ int main(int argc, char* argv[])
theSound = new Sound(); theSound = new Sound();
} }
theSound->setSoundVolume(theSettings->getInt("volume")); theSound->setVolume(theSettings->getInt("volume"));
// Get just the filename of the file containing the ROM image // Get just the filename of the file containing the ROM image
const char* filename = (!strrchr(file, '/')) ? file : strrchr(file, '/') + 1; const char* filename = (!strrchr(file, '/')) ? file : strrchr(file, '/') + 1;

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: 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 <alsa/asoundlib.h> #include <alsa/asoundlib.h>
@ -30,8 +30,7 @@ SoundALSA::SoundALSA()
myOriginalVolumeLeft(-1), myOriginalVolumeLeft(-1),
myOriginalVolumeRight(-1), myOriginalVolumeRight(-1),
myBufferSize(0), myBufferSize(0),
mySampleRate(0), mySampleRate(0)
myPauseStatus(false)
{ {
Int32 err; Int32 err;
char pcmName[] = "plughw:0,0"; 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) if(myIsInitializedFlag && myMixerElem)
{ {

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: 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 #ifndef SOUNDALSA_HXX
@ -30,7 +30,7 @@
Advanced Linux Sound Architecture (ALSA) version 0.9.x API. Advanced Linux Sound Architecture (ALSA) version 0.9.x API.
@author Stephen Anthony @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 class SoundALSA : public Sound
{ {
@ -72,15 +72,7 @@ class SoundALSA : public Sound
@param percent The new volume percentage level for the sound device @param percent The new volume percentage level for the sound device
*/ */
void setSoundVolume(Int32 percent); void setVolume(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; }
/** /**
Update the sound device using the audio sample from the specified Update the sound device using the audio sample from the specified
@ -118,8 +110,5 @@ class SoundALSA : public Sound
// PCM sample rate // PCM sample rate
uInt32 mySampleRate; uInt32 mySampleRate;
// The pause status
bool myPauseStatus;
}; };
#endif #endif

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: 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 <fcntl.h> #include <fcntl.h>
@ -39,8 +39,7 @@ SoundOSS::SoundOSS()
myDspFd(-1), myDspFd(-1),
myMixerFd(-1), myMixerFd(-1),
myOriginalVolume(-1), myOriginalVolume(-1),
mySampleRate(0), mySampleRate(0)
myPauseStatus(false)
{ {
// Open the sound device for writing // Open the sound device for writing
if((myDspFd = open(DSP_DEVICE, O_WRONLY, 0)) == -1) 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)) if(myIsInitializedFlag && (myMixerFd != -1))
{ {

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: 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 #ifndef SOUNDOSS_HXX
@ -28,7 +28,7 @@
Open Sound System (OSS) API. Open Sound System (OSS) API.
@author Bradford W. Mott @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 class SoundOSS : public Sound
{ {
@ -70,15 +70,7 @@ class SoundOSS : public Sound
@param percent The new volume percentage level for the sound device @param percent The new volume percentage level for the sound device
*/ */
void setSoundVolume(Int32 percent); void setVolume(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; }
/** /**
Update the sound device using the audio sample from the specified Update the sound device using the audio sample from the specified
@ -103,8 +95,5 @@ class SoundOSS : public Sound
// DSP sample rate // DSP sample rate
uInt32 mySampleRate; uInt32 mySampleRate;
// The pause status
bool myPauseStatus;
}; };
#endif #endif

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: 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 <SDL.h> #include <SDL.h>
@ -21,16 +21,15 @@
#include "SoundSDL.hxx" #include "SoundSDL.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SoundSDL::SoundSDL(bool activate) SoundSDL::SoundSDL()
: myCurrentVolume(SDL_MIX_MAXVOLUME), : myCurrentVolume(SDL_MIX_MAXVOLUME),
myFragmentSize(1024), myFragmentSize(1024),
myIsInitializedFlag(false), myIsInitializedFlag(false),
myIsMuted(false), myIsMuted(false),
mySampleRate(31400), mySampleRate(31400),
mySampleQueue(mySampleRate), mySampleQueue(mySampleRate)
myPauseStatus(false)
{ {
if(activate) if(1)
{ {
if(SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) 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) if(myIsInitializedFlag)
{ {

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: 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 #ifndef SOUNDSDL_HXX
@ -29,7 +29,7 @@
This class implements the sound API for SDL. This class implements the sound API for SDL.
@author Stephen Anthony and Bradford W. Mott @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 class SoundSDL : public Sound
{ {
@ -37,7 +37,7 @@ class SoundSDL : public Sound
/** /**
Create a new sound object Create a new sound object
*/ */
SoundSDL(bool activate = true); SoundSDL();
/** /**
Destructor Destructor
@ -78,15 +78,7 @@ class SoundSDL : public Sound
@param percent The new volume percentage level for the sound device @param percent The new volume percentage level for the sound device
*/ */
void setSoundVolume(Int32 percent); void setVolume(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; }
/** /**
Update the sound device using the audio sample from the specified 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 // Queue which holds samples from the media source before they are played
SampleQueue mySampleQueue; SampleQueue mySampleQueue;
// The pause status
bool myPauseStatus;
private: private:
// Callback function invoked by the SDL Audio library when it needs data // Callback function invoked by the SDL Audio library when it needs data
static void callback(void* udata, uInt8* stream, int len); static void callback(void* udata, uInt8* stream, int len);
}; };
#endif
#endif