mirror of https://github.com/stella-emu/stella.git
Created a new Sound class that does almost nothing :) Useful for
compiling (or running) Stella with no sound support whatsoever. Added ability to compile multiple sound backends into the X11 and SDL versions, and to dynamically select from among them at run-time. For now, the X11 version can't use the SDL sound core. This is in preparation for the ALSA sound backend, which may or may not make it into Stella 1.3. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@144 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
39dd0d716f
commit
6a8a689e85
|
@ -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: makefile,v 1.27 2002-11-13 03:47:55 bwmott Exp $
|
||||
## $Id: makefile,v 1.28 2002-11-13 16:19:20 stephena Exp $
|
||||
##============================================================================
|
||||
|
||||
##============================================================================
|
||||
|
@ -37,10 +37,13 @@ OPTIMIZATIONS = -O2 -Wall -Wno-unused
|
|||
# -funroll-loops -fstrength-reduce -fomit-frame-pointer -ffast-math \
|
||||
# -falign-functions=2 -falign-jumps=2 -falign-loops=2
|
||||
|
||||
### which sound code to use for the SDL version
|
||||
### choices are "oss" or "sdl"
|
||||
### which sound drivers to compile for the X11 and SDL versions
|
||||
### OSS is most compatible, SDL for platforms where OSS not available
|
||||
SDL_SOUND = oss
|
||||
### SDL sound not yet supported in the X11 version
|
||||
### comment out all lines to completely disable sound
|
||||
###
|
||||
SOUND_OSS = 1
|
||||
#SOUND_SDL = 1
|
||||
|
||||
### if your C++ compiler doesn't support the bool type
|
||||
# BSPF_BOOL = 1
|
||||
|
@ -145,17 +148,18 @@ OPTS.SDL += -DDEVELOPER_SUPPORT=1
|
|||
OPTS.DOS += -DDEVELOPER_SUPPORT=1
|
||||
endif
|
||||
|
||||
ifdef SDL_SOUND
|
||||
ifeq ($(SDL_SOUND), oss)
|
||||
OPTS.SDL += -DUSE_OSS_SOUND=1
|
||||
OBJS.SDL += SoundX11.o
|
||||
endif
|
||||
ifeq ($(SDL_SOUND), sdl)
|
||||
OBJS.SDL += SoundSDL.o
|
||||
endif
|
||||
else
|
||||
OPTS.SDL += -DUSE_OSS_SOUND=1
|
||||
OBJS.SDL += SoundX11.o
|
||||
ifeq ($(SOUND_OSS), 1)
|
||||
OPTS.X11 += -DSOUND_OSS=1
|
||||
OBJS.X11 += SoundOSS.o
|
||||
OPTS.SDL += -DSOUND_OSS=1
|
||||
OBJS.SDL += SoundOSS.o
|
||||
endif
|
||||
|
||||
ifeq ($(SOUND_SDL), 1)
|
||||
# OPTS.X11 += -DSOUND_OSS=1
|
||||
# OBJS.X11 += SoundOSS.o
|
||||
OPTS.SDL += -DSOUND_SDL=1
|
||||
OBJS.SDL += SoundSDL.o
|
||||
endif
|
||||
|
||||
|
||||
|
@ -189,7 +193,7 @@ dos:
|
|||
|
||||
unix-x:
|
||||
make stella.x11 \
|
||||
INCLUDES="$(INCLUDES) -I$(UI)/x11" \
|
||||
INCLUDES="$(INCLUDES) -I$(UI)/x11 -I$(UI)/sound" \
|
||||
SYS_INCLUDES="" \
|
||||
OPTIONS="-DBSPF_UNIX=1" \
|
||||
OPTIONS+="$(OPTS.X11)" \
|
||||
|
@ -197,11 +201,12 @@ unix-x:
|
|||
LDFLAGS+="$(CFLAGS.X11)" \
|
||||
LDLIBS="-lX11 -lXext" \
|
||||
LDLIBS+="$(LIBS.X11)" \
|
||||
OBJS="mainX11.o SoundX11.o"
|
||||
OBJS="mainX11.o"
|
||||
OBJS+="$(OBJS.X11)"
|
||||
|
||||
linux-x:
|
||||
make stella.x11 \
|
||||
INCLUDES="$(INCLUDES) -I$(UI)/x11" \
|
||||
INCLUDES="$(INCLUDES) -I$(UI)/x11 -I$(UI)/sound" \
|
||||
SYS_INCLUDES="" \
|
||||
OPTIONS="-DBSPF_UNIX=1" \
|
||||
OPTIONS+="$(OPTS.X11)" \
|
||||
|
@ -209,12 +214,12 @@ linux-x:
|
|||
LDFLAGS+="$(CFLAGS.X11)" \
|
||||
LDLIBS="-lX11 -lXext" \
|
||||
LDLIBS+="$(LIBS.X11)" \
|
||||
OBJS="mainX11.o SoundX11.o" \
|
||||
OBJS="mainX11.o" \
|
||||
OBJS+="$(OBJS.X11)"
|
||||
|
||||
linux-sdl:
|
||||
make stella.sdl \
|
||||
INCLUDES="$(INCLUDES) -I$(UI)/sdl -I$(UI)/x11" \
|
||||
INCLUDES="$(INCLUDES) -I$(UI)/sdl -I$(UI)/sound" \
|
||||
SYS_INCLUDES="" \
|
||||
OPTIONS="-DBSPF_UNIX=1" \
|
||||
OPTIONS+="$(OPTS.SDL)" \
|
||||
|
@ -227,7 +232,7 @@ linux-sdl:
|
|||
|
||||
bsdi-x:
|
||||
make stella.x11 \
|
||||
INCLUDES="$(INCLUDES) -I$(UI)/x11" \
|
||||
INCLUDES="$(INCLUDES) -I$(UI)/x11 -I$(UI)/sound" \
|
||||
SYS_INCLUDES="-I/usr/X11R6/include" \
|
||||
OPTIONS="-DBSPF_UNIX=1" \
|
||||
OPTIONS+="$(OPTS.X11)" \
|
||||
|
@ -235,11 +240,12 @@ bsdi-x:
|
|||
LDFLAGS+="$(CFLAGS.X11)" \
|
||||
LDLIBS="-lX11 -lXext" \
|
||||
LDLIBS+="$(LIBS.X11)" \
|
||||
OBJS="mainX11.o SoundX11.o"
|
||||
OBJS="mainX11.o"
|
||||
OBJS+="$(OBJS.X11)"
|
||||
|
||||
solaris-x:
|
||||
make stella.x11 \
|
||||
INCLUDES="$(INCLUDES) -I$(UI)/x11" \
|
||||
INCLUDES="$(INCLUDES) -I$(UI)/x11 -I$(UI)/sound" \
|
||||
SYS_INCLUDES="-I/usr/openwin/include" \
|
||||
OPTIONS="-DBSPF_UNIX=1" \
|
||||
OPTIONS+="$(OPTS.X11)" \
|
||||
|
@ -247,7 +253,8 @@ solaris-x:
|
|||
LDFLAGS+="$(CFLAGS.X11)" \
|
||||
LDLIBS="-lX11 -lXext" \
|
||||
LDLIBS+="$(LIBS.X11)" \
|
||||
OBJS="mainX11.o SoundX11.o"
|
||||
OBJS="mainX11.o"
|
||||
OBJS+="$(OBJS.X11)"
|
||||
|
||||
###############################################################################
|
||||
## List of "core" object files
|
||||
|
@ -259,7 +266,7 @@ CORE_OBJS = Booster.o Cart.o Cart2K.o Cart3F.o Cart4K.o CartAR.o CartDPC.o \
|
|||
CartF8.o CartF8SC.o CartFASC.o CartFE.o CartMC.o CartCV.o \
|
||||
CartMB.o Console.o Control.o Driving.o \
|
||||
Event.o Joystick.o Keyboard.o M6532.o MD5.o MediaSrc.o Paddles.o \
|
||||
Props.o PropsSet.o Random.o Switches.o Settings.o TIA.o \
|
||||
Props.o PropsSet.o Random.o Sound.o Switches.o Settings.o TIA.o \
|
||||
Serializer.o Deserializer.o TIASound.o \
|
||||
$(M6502_OBJS)
|
||||
|
||||
|
@ -404,6 +411,9 @@ Props.o: $(CORE)/Props.cxx
|
|||
Random.o: $(CORE)/Random.cxx
|
||||
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Random.cxx
|
||||
|
||||
Sound.o: $(CORE)/Sound.cxx $(CORE)/Sound.hxx
|
||||
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(LDFLAGS) $(CORE)/Sound.cxx
|
||||
|
||||
Switches.o: $(CORE)/Switches.cxx
|
||||
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Switches.cxx
|
||||
|
||||
|
@ -437,14 +447,14 @@ TermX11.o: $(UI)/x11/TermX11.cxx
|
|||
mainX11.o: $(UI)/x11/mainX11.cxx
|
||||
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/x11/mainX11.cxx
|
||||
|
||||
SoundX11.o: $(UI)/x11/SoundX11.cxx
|
||||
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/x11/SoundX11.cxx
|
||||
SoundOSS.o: $(UI)/sound/SoundOSS.cxx $(UI)/sound/SoundOSS.hxx
|
||||
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/sound/SoundOSS.cxx
|
||||
|
||||
mainSDL.o: $(UI)/sdl/mainSDL.cxx
|
||||
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/sdl/mainSDL.cxx
|
||||
|
||||
SoundSDL.o: $(UI)/sdl/SoundSDL.cxx $(UI)/sdl/SoundSDL.hxx
|
||||
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/sdl/SoundSDL.cxx
|
||||
SoundSDL.o: $(UI)/sound/SoundSDL.cxx $(UI)/sound/SoundSDL.hxx
|
||||
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/sound/SoundSDL.cxx
|
||||
|
||||
RectList.o: $(UI)/sdl/RectList.cxx $(UI)/sdl/RectList.hxx
|
||||
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/sdl/RectList.cxx
|
||||
|
@ -472,4 +482,3 @@ NullDev.o: $(CORE)/m6502/src/NullDev.cxx
|
|||
|
||||
System.o: $(CORE)/m6502/src/System.cxx
|
||||
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/m6502/src/System.cxx
|
||||
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
//============================================================================
|
||||
//
|
||||
// SSSS tt lll lll
|
||||
// SS SS tt ll ll
|
||||
// SS tttttt eeee ll ll aaaa
|
||||
// SSSS tt ee ee ll ll aa
|
||||
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
||||
// SS SS tt ee ll ll aa aa
|
||||
// SSSS ttt eeeee llll llll aaaaa
|
||||
//
|
||||
// Copyright (c) 1995-2002 by Bradford W. Mott
|
||||
//
|
||||
// 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.4 2002-11-13 16:19:20 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include "SoundOSS.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Sound::Sound()
|
||||
{
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Sound::~Sound()
|
||||
{
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Sound::closeDevice()
|
||||
{
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 Sound::getSampleRate() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Sound::isSuccessfullyInitialized() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Sound::setSoundVolume(uInt32 volume)
|
||||
{
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Sound::updateSound(MediaSource& mediaSource)
|
||||
{
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
//============================================================================
|
||||
//
|
||||
// SSSS tt lll lll
|
||||
// SS SS tt ll ll
|
||||
// SS tttttt eeee ll ll aaaa
|
||||
// SSSS tt ee ee ll ll aa
|
||||
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
||||
// SS SS tt ee ll ll aa aa
|
||||
// SSSS ttt eeeee llll llll aaaaa
|
||||
//
|
||||
// Copyright (c) 1995-2002 by Bradford W. Mott
|
||||
//
|
||||
// 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.4 2002-11-13 16:19:20 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef SOUND_HXX
|
||||
#define SOUND_HXX
|
||||
|
||||
#include "bspf.hxx"
|
||||
#include "MediaSrc.hxx"
|
||||
|
||||
/**
|
||||
This class is a base class for the various sound objects.
|
||||
It has almost no functionality, but is useful if one wishes
|
||||
to compile Stella with no sound support whatsoever.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: Sound.hxx,v 1.4 2002-11-13 16:19:20 stephena Exp $
|
||||
*/
|
||||
class Sound
|
||||
{
|
||||
public:
|
||||
/**
|
||||
Create a new sound object
|
||||
*/
|
||||
Sound();
|
||||
|
||||
/**
|
||||
Destructor
|
||||
*/
|
||||
virtual ~Sound();
|
||||
|
||||
public:
|
||||
/**
|
||||
Closes the sound device
|
||||
*/
|
||||
virtual void closeDevice();
|
||||
|
||||
/**
|
||||
Return the playback sample rate for the sound device.
|
||||
|
||||
@return The playback sample rate
|
||||
*/
|
||||
virtual uInt32 getSampleRate() const;
|
||||
|
||||
/**
|
||||
Return true iff the sound device was successfully initialized.
|
||||
|
||||
@return true iff the sound device was successfully initialized.
|
||||
*/
|
||||
virtual bool isSuccessfullyInitialized() const;
|
||||
|
||||
/**
|
||||
Sets the volume of the sound device to the specified level. The
|
||||
volume is given as a precentage from 0 to 100.
|
||||
|
||||
@param volume The new volume for the sound device
|
||||
*/
|
||||
virtual void setSoundVolume(uInt32 volume);
|
||||
|
||||
/**
|
||||
Update the sound device using the audio sample from the specified
|
||||
media source.
|
||||
|
||||
@param mediaSource The media source to get audio samples from.
|
||||
*/
|
||||
virtual void updateSound(MediaSource& mediaSource);
|
||||
};
|
||||
#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: TIA.cxx,v 1.17 2002-10-31 20:46:06 stephena Exp $
|
||||
// $Id: TIA.cxx,v 1.18 2002-11-13 16:19:20 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -370,10 +370,13 @@ bool TIA::save(Serializer& out)
|
|||
// Save the sample stuff ...
|
||||
string soundDevice = "TIASound";
|
||||
out.putString(soundDevice);
|
||||
out.putLong(mySampleRate);
|
||||
|
||||
uInt8 reg1, reg2, reg3, reg4, reg5, reg6;
|
||||
Tia_get_registers(®1, ®2, ®3, ®4, ®5, ®6);
|
||||
uInt8 reg1 = 0, reg2 = 0, reg3 = 0, reg4 = 0, reg5 = 0, reg6 = 0;
|
||||
|
||||
// Only get the TIA sound registers if sound is enabled
|
||||
if(mySampleRate != 0)
|
||||
Tia_get_registers(®1, ®2, ®3, ®4, ®5, ®6);
|
||||
|
||||
out.putLong(reg1);
|
||||
out.putLong(reg2);
|
||||
out.putLong(reg3);
|
||||
|
@ -480,8 +483,6 @@ bool TIA::load(Deserializer& in)
|
|||
if(in.getString() != soundDevice)
|
||||
return false;
|
||||
|
||||
mySampleRate = (uInt32) in.getLong();
|
||||
|
||||
uInt8 reg1 = 0, reg2 = 0, reg3 = 0, reg4 = 0, reg5 = 0, reg6 = 0;
|
||||
reg1 = (uInt8) in.getLong();
|
||||
reg1 = (uInt8) in.getLong();
|
||||
|
@ -489,7 +490,10 @@ bool TIA::load(Deserializer& in)
|
|||
reg1 = (uInt8) in.getLong();
|
||||
reg1 = (uInt8) in.getLong();
|
||||
reg1 = (uInt8) in.getLong();
|
||||
Tia_set_registers(reg1, reg2, reg3, reg4, reg5, reg6);
|
||||
|
||||
// Only update the TIA sound registers if sound is enabled
|
||||
if(mySampleRate != 0)
|
||||
Tia_set_registers(reg1, reg2, reg3, reg4, reg5, reg6);
|
||||
}
|
||||
catch(char *msg)
|
||||
{
|
||||
|
|
|
@ -31,4 +31,5 @@
|
|||
;ssname = <romname|md5sum>
|
||||
;sssingle = <0|1>
|
||||
;accurate = <0|1>
|
||||
;sound = <0|oss|sdl>
|
||||
;Dmerge = <0|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: Settings.cxx,v 1.6 2002-11-11 22:14:56 stephena Exp $
|
||||
// $Id: Settings.cxx,v 1.7 2002-11-13 16:19:20 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifdef DEVELOPER_SUPPORT
|
||||
|
@ -43,6 +43,7 @@ Settings::Settings()
|
|||
theMaxWindowSize = 0;
|
||||
theHeight = 0;
|
||||
theWidth = 0;
|
||||
theSoundDriver = "oss";
|
||||
|
||||
#ifdef DEVELOPER_SUPPORT
|
||||
userDefinedProperties.set("Display.Format", "-1");
|
||||
|
@ -189,6 +190,14 @@ bool Settings::handleCommandLineArgs(int argc, char* argv[])
|
|||
{
|
||||
theAlternateProFile = argv[++i];
|
||||
}
|
||||
else if(string(argv[i]) == "-sound")
|
||||
{
|
||||
string option = argv[++i];
|
||||
if((option != "oss") && (option != "sdl") && (option != "alsa"))
|
||||
option = "0";
|
||||
|
||||
theSoundDriver = option;
|
||||
}
|
||||
#ifdef DEVELOPER_SUPPORT
|
||||
else if(string(argv[i]) == "-Dformat")
|
||||
{
|
||||
|
@ -388,6 +397,13 @@ void Settings::handleRCFile(istream& in)
|
|||
else if(option == 0)
|
||||
theMultipleSnapShotFlag = true;
|
||||
}
|
||||
else if(key == "sound")
|
||||
{
|
||||
if((value != "oss") && (value != "sdl") && (value != "alsa"))
|
||||
value = "0";
|
||||
|
||||
theSoundDriver = value;
|
||||
}
|
||||
#ifdef DEVELOPER_SUPPORT
|
||||
else if(key == "Dmerge")
|
||||
{
|
||||
|
|
|
@ -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: Settings.hxx,v 1.5 2002-11-11 02:55:16 stephena Exp $
|
||||
// $Id: Settings.hxx,v 1.6 2002-11-13 16:19:20 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef SETTINGS_HXX
|
||||
|
@ -94,6 +94,9 @@ class Settings
|
|||
uInt32 theHeight;
|
||||
uInt32 theWidth;
|
||||
|
||||
// Indicates which sound driver to use at run-time
|
||||
string theSoundDriver;
|
||||
|
||||
#ifdef DEVELOPER_SUPPORT
|
||||
// User-modified properties
|
||||
Properties userDefinedProperties;
|
||||
|
|
|
@ -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.37 2002-11-12 01:50:06 stephena Exp $
|
||||
// $Id: mainSDL.cxx,v 1.38 2002-11-13 16:19:21 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <fstream>
|
||||
|
@ -36,13 +36,16 @@
|
|||
#include "Event.hxx"
|
||||
#include "MediaSrc.hxx"
|
||||
#include "PropsSet.hxx"
|
||||
#include "Sound.hxx"
|
||||
#include "System.hxx"
|
||||
#include "RectList.hxx"
|
||||
#include "Settings.hxx"
|
||||
|
||||
#ifdef USE_OSS_SOUND
|
||||
#include "SoundX11.hxx"
|
||||
#else
|
||||
#ifdef SOUND_OSS
|
||||
#include "SoundOSS.hxx"
|
||||
#endif
|
||||
|
||||
#ifdef SOUND_SDL
|
||||
#include "SoundSDL.hxx"
|
||||
#endif
|
||||
|
||||
|
@ -193,6 +196,9 @@ static Console* theConsole = (Console*) NULL;
|
|||
// Pointer to the settings object or the null pointer
|
||||
static Settings* settings = (Settings*) NULL;
|
||||
|
||||
// Pointer to the sound object or the null pointer
|
||||
static Sound* sound = (Sound*) NULL;
|
||||
|
||||
// Indicates if the user wants to quit
|
||||
static bool theQuitIndicator = false;
|
||||
|
||||
|
@ -1438,6 +1444,18 @@ void usage()
|
|||
" -pro <props file> Use the given properties file instead of stella.pro",
|
||||
" -accurate <0|1> Accurate game timing (uses more CPU)",
|
||||
"",
|
||||
" -sound <type> Type is one of the following:",
|
||||
" 0 Disables all sound generation",
|
||||
#ifdef SOUND_ALSA
|
||||
" alsa ALSA version 0.9 driver",
|
||||
#endif
|
||||
#ifdef SOUND_OSS
|
||||
" oss Open Sound System driver (most compatible)",
|
||||
#endif
|
||||
#ifdef SOUND_SDL
|
||||
" sdl Native SDL driver",
|
||||
#endif
|
||||
"",
|
||||
#ifdef DEVELOPER_SUPPORT
|
||||
" DEVELOPER options (see Stella manual for details)",
|
||||
" -Dformat Sets \"Display.Format\"",
|
||||
|
@ -1554,6 +1572,9 @@ void cleanup()
|
|||
if(rectList)
|
||||
delete rectList;
|
||||
|
||||
if(sound)
|
||||
delete sound;
|
||||
|
||||
if(SDL_WasInit(SDL_INIT_EVERYTHING))
|
||||
{
|
||||
#ifdef HAVE_JOYSTICK
|
||||
|
@ -1678,13 +1699,27 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
// Create a sound object for playing audio
|
||||
#ifdef USE_OSS_SOUND
|
||||
SoundX11 sound;
|
||||
#else
|
||||
SoundSDL sound;
|
||||
if(settings->theSoundDriver == "0")
|
||||
{
|
||||
// if sound has been disabled, we still need a sound object
|
||||
sound = new Sound();
|
||||
}
|
||||
#ifdef SOUND_OSS
|
||||
else if(settings->theSoundDriver == "oss")
|
||||
sound = new SoundOSS();
|
||||
#endif
|
||||
#ifdef SOUND_SDL
|
||||
else if(settings->theSoundDriver == "sdl")
|
||||
sound = new SoundSDL();
|
||||
#endif
|
||||
else // a driver that doesn't exist was requested, so disable sound
|
||||
{
|
||||
cerr << "ERROR: Sound support for "
|
||||
<< settings->theSoundDriver << " disabled.\n";
|
||||
sound = new Sound();
|
||||
}
|
||||
|
||||
sound.setSoundVolume(settings->theDesiredVolume);
|
||||
sound->setSoundVolume(settings->theDesiredVolume);
|
||||
|
||||
// Get just the filename of the file containing the ROM image
|
||||
const char* filename = (!strrchr(file, '/')) ? file : strrchr(file, '/') + 1;
|
||||
|
@ -1692,11 +1727,11 @@ int main(int argc, char* argv[])
|
|||
// Create the 2600 game console for users or developers
|
||||
#ifdef DEVELOPER_SUPPORT
|
||||
theConsole = new Console(image, size, filename,
|
||||
theEvent, propertiesSet, sound.getSampleRate(),
|
||||
theEvent, propertiesSet, sound->getSampleRate(),
|
||||
&settings->userDefinedProperties);
|
||||
#else
|
||||
theConsole = new Console(image, size, filename,
|
||||
theEvent, propertiesSet, sound.getSampleRate());
|
||||
theEvent, propertiesSet, sound->getSampleRate());
|
||||
#endif
|
||||
|
||||
// Free the image since we don't need it any longer
|
||||
|
@ -1706,14 +1741,14 @@ int main(int argc, char* argv[])
|
|||
if(!setupDisplay())
|
||||
{
|
||||
cerr << "ERROR: Couldn't set up display.\n";
|
||||
sound.closeDevice();
|
||||
sound->closeDevice();
|
||||
cleanup();
|
||||
return 0;
|
||||
}
|
||||
if(!setupJoystick())
|
||||
{
|
||||
cerr << "ERROR: Couldn't set up joysticks.\n";
|
||||
sound.closeDevice();
|
||||
sound->closeDevice();
|
||||
cleanup();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1752,7 +1787,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
theConsole->mediaSource().update();
|
||||
updateDisplay(theConsole->mediaSource());
|
||||
sound.updateSound(theConsole->mediaSource());
|
||||
sound->updateSound(theConsole->mediaSource());
|
||||
|
||||
// Now, waste time if we need to so that we are at the desired frame rate
|
||||
for(;;)
|
||||
|
@ -1791,7 +1826,7 @@ int main(int argc, char* argv[])
|
|||
if(!thePauseIndicator)
|
||||
{
|
||||
theConsole->mediaSource().update();
|
||||
sound.updateSound(theConsole->mediaSource());
|
||||
sound->updateSound(theConsole->mediaSource());
|
||||
}
|
||||
updateDisplay(theConsole->mediaSource());
|
||||
|
||||
|
@ -1824,7 +1859,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
// Cleanup time ...
|
||||
sound.closeDevice();
|
||||
sound->closeDevice();
|
||||
cleanup();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -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: SoundX11.cxx,v 1.2 2002-11-11 22:02:59 stephena Exp $
|
||||
// $Id: SoundOSS.cxx,v 1.1 2002-11-13 16:19:21 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <fcntl.h>
|
||||
|
@ -31,10 +31,10 @@
|
|||
#define DSP_DEVICE "/dev/dsp"
|
||||
#define MIXER_DEVICE "/dev/mixer"
|
||||
|
||||
#include "SoundX11.hxx"
|
||||
#include "SoundOSS.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
SoundX11::SoundX11()
|
||||
SoundOSS::SoundOSS()
|
||||
: myIsInitializedFlag(false),
|
||||
myDspFd(-1),
|
||||
myMixerFd(-1),
|
||||
|
@ -125,13 +125,13 @@ SoundX11::SoundX11()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
SoundX11::~SoundX11()
|
||||
SoundOSS::~SoundOSS()
|
||||
{
|
||||
closeDevice();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void SoundX11::closeDevice()
|
||||
void SoundOSS::closeDevice()
|
||||
{
|
||||
if(myIsInitializedFlag)
|
||||
{
|
||||
|
@ -159,19 +159,19 @@ void SoundX11::closeDevice()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 SoundX11::getSampleRate() const
|
||||
uInt32 SoundOSS::getSampleRate() const
|
||||
{
|
||||
return myIsInitializedFlag ? mySampleRate : 0;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool SoundX11::isSuccessfullyInitialized() const
|
||||
bool SoundOSS::isSuccessfullyInitialized() const
|
||||
{
|
||||
return myIsInitializedFlag;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void SoundX11::setSoundVolume(uInt32 volume)
|
||||
void SoundOSS::setSoundVolume(uInt32 volume)
|
||||
{
|
||||
if(myIsInitializedFlag && (myMixerFd != -1))
|
||||
{
|
||||
|
@ -195,7 +195,7 @@ void SoundX11::setSoundVolume(uInt32 volume)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void SoundX11::updateSound(MediaSource& mediaSource)
|
||||
void SoundOSS::updateSound(MediaSource& mediaSource)
|
||||
{
|
||||
if(myIsInitializedFlag)
|
||||
{
|
|
@ -13,34 +13,35 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: SoundX11.hxx,v 1.2 2002-11-11 22:03:00 stephena Exp $
|
||||
// $Id: SoundOSS.hxx,v 1.1 2002-11-13 16:19:21 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef SOUNDX11_HXX
|
||||
#define SOUNDX11_HXX
|
||||
#ifndef SOUNDOSS_HXX
|
||||
#define SOUNDOSS_HXX
|
||||
|
||||
#include "Sound.hxx"
|
||||
#include "bspf.hxx"
|
||||
#include "MediaSrc.hxx"
|
||||
|
||||
/**
|
||||
This class implements a sound class for the X11 front-end. The
|
||||
Open Sound System (OSS) API is currently supported.
|
||||
This class implements a sound class using the
|
||||
Open Sound System (OSS) API.
|
||||
|
||||
@author Bradford W. Mott
|
||||
@version $Id: SoundX11.hxx,v 1.2 2002-11-11 22:03:00 stephena Exp $
|
||||
@version $Id: SoundOSS.hxx,v 1.1 2002-11-13 16:19:21 stephena Exp $
|
||||
*/
|
||||
class SoundX11
|
||||
class SoundOSS : public Sound
|
||||
{
|
||||
public:
|
||||
/**
|
||||
Create a new sound object
|
||||
*/
|
||||
SoundX11();
|
||||
SoundOSS();
|
||||
|
||||
/**
|
||||
Destructor
|
||||
*/
|
||||
virtual ~SoundX11();
|
||||
virtual ~SoundOSS();
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@ -95,4 +96,3 @@ class SoundX11
|
|||
uInt32 mySampleRate;
|
||||
};
|
||||
#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.5 2002-11-13 05:01:31 bwmott Exp $
|
||||
// $Id: SoundSDL.cxx,v 1.1 2002-11-13 16:19:21 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <SDL.h>
|
|
@ -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.4 2002-11-11 22:07:35 stephena Exp $
|
||||
// $Id: SoundSDL.hxx,v 1.1 2002-11-13 16:19:21 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef SOUNDSDL_HXX
|
||||
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <SDL.h>
|
||||
|
||||
#include "Sound.hxx"
|
||||
#include "bspf.hxx"
|
||||
#include "MediaSrc.hxx"
|
||||
|
||||
|
@ -28,9 +29,9 @@
|
|||
This class implements the sound API for SDL.
|
||||
|
||||
@author Stephen Anthony and Bradford W. Mott
|
||||
@version $Id: SoundSDL.hxx,v 1.4 2002-11-11 22:07:35 stephena Exp $
|
||||
@version $Id: SoundSDL.hxx,v 1.1 2002-11-13 16:19:21 stephena Exp $
|
||||
*/
|
||||
class SoundSDL
|
||||
class SoundSDL : public Sound
|
||||
{
|
||||
public:
|
||||
/**
|
|
@ -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: mainX11.cxx,v 1.32 2002-11-12 01:50:06 stephena Exp $
|
||||
// $Id: mainX11.cxx,v 1.33 2002-11-13 16:19:21 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <fstream>
|
||||
|
@ -40,9 +40,13 @@
|
|||
#include "Event.hxx"
|
||||
#include "MediaSrc.hxx"
|
||||
#include "PropsSet.hxx"
|
||||
#include "Sound.hxx"
|
||||
#include "System.hxx"
|
||||
#include "Settings.hxx"
|
||||
#include "SoundX11.hxx"
|
||||
|
||||
#ifdef SOUND_OSS
|
||||
#include "SoundOSS.hxx"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PNG
|
||||
#include "Snapshot.hxx"
|
||||
|
@ -192,6 +196,9 @@ static Console* theConsole = (Console*) NULL;
|
|||
// Pointer to the settings object or the null pointer
|
||||
static Settings* settings = (Settings*) NULL;
|
||||
|
||||
// Pointer to the sound object or the null pointer
|
||||
static Sound* sound = (Sound*) NULL;
|
||||
|
||||
// Indicates if the user wants to quit
|
||||
static bool theQuitIndicator = false;
|
||||
|
||||
|
@ -1333,6 +1340,15 @@ void usage()
|
|||
" -pro <props file> Use the given properties file instead of stella.pro",
|
||||
" -accurate <0|1> Accurate game timing (uses more CPU)",
|
||||
"",
|
||||
" -sound <type> Type is one of the following:",
|
||||
" 0 Disables all sound generation",
|
||||
#ifdef SOUND_ALSA
|
||||
" alsa ALSA version 0.9 driver",
|
||||
#endif
|
||||
#ifdef SOUND_OSS
|
||||
" oss Open Sound System driver (most compatible)",
|
||||
#endif
|
||||
"",
|
||||
#ifdef DEVELOPER_SUPPORT
|
||||
" DEVELOPER options (see Stella manual for details)",
|
||||
" -Dformat Sets \"Display.Format\"",
|
||||
|
@ -1443,6 +1459,9 @@ void cleanup()
|
|||
delete snapshot;
|
||||
#endif
|
||||
|
||||
if(sound)
|
||||
delete sound;
|
||||
|
||||
if(normalCursor)
|
||||
XFreeCursor(theDisplay, normalCursor);
|
||||
if(blankCursor)
|
||||
|
@ -1553,8 +1572,23 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
// Create a sound object for playing audio
|
||||
SoundX11 sound;
|
||||
sound.setSoundVolume(settings->theDesiredVolume);
|
||||
if(settings->theSoundDriver == "0")
|
||||
{
|
||||
// if sound has been disabled, we still need a sound object
|
||||
sound = new Sound();
|
||||
}
|
||||
#ifdef SOUND_OSS
|
||||
else if(settings->theSoundDriver == "oss")
|
||||
sound = new SoundOSS();
|
||||
#endif
|
||||
else // a driver that doesn't exist was requested, so disable sound
|
||||
{
|
||||
cerr << "ERROR: Sound support for "
|
||||
<< settings->theSoundDriver << " disabled.\n";
|
||||
sound = new Sound();
|
||||
}
|
||||
|
||||
sound->setSoundVolume(settings->theDesiredVolume);
|
||||
|
||||
// Get just the filename of the file containing the ROM image
|
||||
const char* filename = (!strrchr(file, '/')) ? file : strrchr(file, '/') + 1;
|
||||
|
@ -1562,11 +1596,11 @@ int main(int argc, char* argv[])
|
|||
// Create the 2600 game console for users or developers
|
||||
#ifdef DEVELOPER_SUPPORT
|
||||
theConsole = new Console(image, size, filename,
|
||||
theEvent, propertiesSet, sound.getSampleRate(),
|
||||
theEvent, propertiesSet, sound->getSampleRate(),
|
||||
&settings->userDefinedProperties);
|
||||
#else
|
||||
theConsole = new Console(image, size, filename,
|
||||
theEvent, propertiesSet, sound.getSampleRate());
|
||||
theEvent, propertiesSet, sound->getSampleRate());
|
||||
#endif
|
||||
|
||||
// Free the image since we don't need it any longer
|
||||
|
@ -1620,7 +1654,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
theConsole->mediaSource().update();
|
||||
sound.updateSound(theConsole->mediaSource());
|
||||
sound->updateSound(theConsole->mediaSource());
|
||||
updateDisplay(theConsole->mediaSource());
|
||||
|
||||
// Now, waste time if we need to so that we are at the desired frame rate
|
||||
|
@ -1661,7 +1695,7 @@ int main(int argc, char* argv[])
|
|||
if(!thePauseIndicator)
|
||||
{
|
||||
theConsole->mediaSource().update();
|
||||
sound.updateSound(theConsole->mediaSource());
|
||||
sound->updateSound(theConsole->mediaSource());
|
||||
}
|
||||
updateDisplay(theConsole->mediaSource());
|
||||
|
||||
|
|
Loading…
Reference in New Issue