mirror of https://github.com/stella-emu/stella.git
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:
parent
6a4af2b17a
commit
e123a4f22f
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <fstream>
|
||||
|
@ -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;
|
||||
|
|
|
@ -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 <alsa/asoundlib.h>
|
||||
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <fcntl.h>
|
||||
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <SDL.h>
|
||||
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue