Broke the dependency between the FrameBuffer and Sound classes

wrt to the MediaSource.

Previously, in the main run loop for a port, you had to call
FrameBuffer::update and then
Sound::updateSound(FrameBuffer::MediaSource).  Now, you can call
FrameBuffer::update() and then Sound::update().  But since the
ordering here is important, I've introduced a Console::update()
that does it all.  So the main run loop for each port just
got a bit simpler.

Also changed around the Snapshot class a bit.  All this is to
reinforce the fact that the MediaSource is owned by the core,
and the FrameBuffer, Sound, and Snapshot classes make use of
it.  Previously, it seemed as if the FrameBuffer owned the
MediaSource.

I'm finding all these little inconsistencies because of
writing the Porting.txt document, and trying to explain
why something is being done a certain way (and if I
can't explain it, I rewrite it).  So if for no other
reason, the Porting.txt document has already been
valuable.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@214 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2003-11-19 15:57:11 +00:00
parent e123a4f22f
commit b15698ff2e
16 changed files with 168 additions and 115 deletions

View File

@ -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: Console.cxx,v 1.20 2003-11-06 22:22:32 stephena Exp $
// $Id: Console.cxx,v 1.21 2003-11-19 15:57:10 stephena Exp $
//============================================================================
#include <assert.h>
@ -72,11 +72,6 @@ Console::Console(const uInt8* image, uInt32 size, const char* filename,
myEventHandler = new EventHandler(this);
myEvent = myEventHandler->event();
#ifdef SNAPSHOT_SUPPORT
// Create a snapshot object which will handle taking snapshots
mySnapshot = new Snapshot();
#endif
// Get the MD5 message-digest for the ROM image
string md5 = MD5(image, size);
@ -177,6 +172,14 @@ Console::Console(const uInt8* image, uInt32 size, const char* filename,
// Initialize the framebuffer interface.
// This must be done *after* a reset, since it needs updated values.
myFrameBuffer.initDisplay(this, myMediaSource);
// Initialize the sound interface.
mySound.init(this, myMediaSource);
#ifdef SNAPSHOT_SUPPORT
// Create a snapshot object which will handle taking snapshots
mySnapshot = new Snapshot(this, myMediaSource);
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -200,6 +203,13 @@ Console::~Console()
delete myEventHandler;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::update()
{
myFrameBuffer.update();
mySound.update();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Properties& Console::properties() const
{

View File

@ -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: Console.hxx,v 1.15 2003-11-06 22:22:32 stephena Exp $
// $Id: Console.hxx,v 1.16 2003-11-19 15:57:10 stephena Exp $
//============================================================================
#ifndef CONSOLE_HXX
@ -41,7 +41,7 @@ class FrameBuffer;
This class represents the entire game console.
@author Bradford W. Mott
@version $Id: Console.hxx,v 1.15 2003-11-06 22:22:32 stephena Exp $
@version $Id: Console.hxx,v 1.16 2003-11-19 15:57:10 stephena Exp $
*/
class Console
{
@ -75,6 +75,12 @@ class Console
virtual ~Console();
public:
/**
Updates the console by one frame. Each frontend should
call this method 'framerate' times per second.
*/
void update();
/**
Get the controller plugged into the specified jack

View File

@ -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: EventHandler.cxx,v 1.21 2003-11-13 12:50:11 stephena Exp $
// $Id: EventHandler.cxx,v 1.22 2003-11-19 15:57:10 stephena Exp $
//============================================================================
#include <algorithm>
@ -421,10 +421,10 @@ void EventHandler::takeSnapshot()
{
#ifdef SNAPSHOT_SUPPORT
// Now save the snapshot file
string filename = myConsole->settings().snapshotFilename();
myConsole->snapshot().savePNG(filename, myConsole->frameBuffer(),
myConsole->settings().getInt("zoom"));
string filename = myConsole->settings().snapshotFilename();
uInt32 multiplier = myConsole->settings().getInt("zoom");
myConsole->snapshot().savePNG(filename, multiplier);
myConsole->frameBuffer().showMessage("Snapshot saved");
#else
myConsole->frameBuffer().showMessage("Snapshots unsupported");

View File

@ -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: FrameBuffer.cxx,v 1.5 2003-11-12 19:36:25 stephena Exp $
// $Id: FrameBuffer.cxx,v 1.6 2003-11-19 15:57:10 stephena Exp $
//============================================================================
#include <sstream>
@ -47,8 +47,8 @@
FrameBuffer::FrameBuffer()
: myConsole(0),
myMediaSource(0),
myWidth(160),
myHeight(300),
myWidth(0),
myHeight(0),
theRedrawEntireFrameIndicator(true),
myFGColor(10),
myBGColor(0),
@ -440,15 +440,6 @@ void FrameBuffer::sendJoyEvent(StellaEvent::JoyStick stick,
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MediaSource* FrameBuffer::mediaSource() const
{
if(myMediaSource)
return myMediaSource;
else
return (MediaSource*) NULL;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::pause(bool status)
{
@ -489,10 +480,10 @@ void FrameBuffer::moveCursorUp(uInt32 amt)
break;
case REMAP_MENU:
// First move cursor down by the given amt
// First move cursor up by the given amt
myRemapMenuIndex -= amt;
// Move down the boundaries
// Move up the boundaries
if(myRemapMenuIndex < myRemapMenuLowIndex)
{
Int32 x = myRemapMenuLowIndex - myRemapMenuIndex;
@ -500,7 +491,7 @@ void FrameBuffer::moveCursorUp(uInt32 amt)
myRemapMenuHighIndex -= x;
}
// Then scale back up, if necessary
// Then scale back down, if necessary
if(myRemapMenuLowIndex < 0)
{
Int32 x = 0 - myRemapMenuLowIndex;
@ -528,10 +519,10 @@ void FrameBuffer::moveCursorDown(uInt32 amt)
break;
case REMAP_MENU:
// First move cursor up by the given amount
// First move cursor down by the given amount
myRemapMenuIndex += amt;
// Move up the boundaries
// Move down the boundaries
if(myRemapMenuIndex >= myRemapMenuHighIndex)
{
Int32 x = myRemapMenuIndex - myRemapMenuHighIndex + 1;
@ -540,11 +531,10 @@ void FrameBuffer::moveCursorDown(uInt32 amt)
myRemapMenuHighIndex += x;
}
// Then scale back down, if necessary
// Then scale back up, if necessary
if(myRemapMenuHighIndex >= myRemapMenuItems)
{
Int32 x = myRemapMenuHighIndex - myRemapMenuItems;
myRemapMenuIndex -= x;
myRemapMenuLowIndex -= x;
myRemapMenuHighIndex -= x;
@ -674,7 +664,7 @@ const uInt8 FrameBuffer::ourFontData[2048] = {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FrameBuffer::MainMenuItem FrameBuffer::ourMainMenu[2] = {
{ REMAP_MENU, "Event Remapping" },
{ REMAP_MENU, "Event Remapping" },
{ INFO_MENU, "Game Information" }
};

View File

@ -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: FrameBuffer.hxx,v 1.5 2003-11-12 19:36:25 stephena Exp $
// $Id: FrameBuffer.hxx,v 1.6 2003-11-19 15:57:10 stephena Exp $
//============================================================================
#ifndef FRAMEBUFFER_HXX
@ -35,7 +35,7 @@ class Console;
can be changed.
@author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.5 2003-11-12 19:36:25 stephena Exp $
@version $Id: FrameBuffer.hxx,v 1.6 2003-11-19 15:57:10 stephena Exp $
*/
class FrameBuffer
{
@ -55,7 +55,7 @@ class FrameBuffer
calls are made to derived methods.
@param console The console
@param mediasrc The console
@param mediasrc The mediasource
*/
void initDisplay(Console* console, MediaSource* mediasrc);
@ -113,13 +113,6 @@ class FrameBuffer
void sendJoyEvent(StellaEvent::JoyStick stick, StellaEvent::JoyCode code,
Int32 state);
/**
Returns the mediasource used in the framebuffer.
@result The mediasource for this framebuffer
*/
MediaSource* mediaSource() const;
/**
Sets the pause status. While pause is selected, the
MediaSource will not be updated.

View File

@ -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.cxx,v 1.7 2003-11-18 21:39:02 stephena Exp $
// $Id: Sound.cxx,v 1.8 2003-11-19 15:57:10 stephena Exp $
//============================================================================
#include "Sound.hxx"
@ -29,6 +29,13 @@ Sound::~Sound()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Sound::init(Console* console, MediaSource* mediasrc)
{
myConsole = console;
myMediaSource = mediasrc;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Sound::closeDevice()
{
@ -52,6 +59,6 @@ void Sound::setVolume(Int32 volume)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Sound::updateSound(MediaSource& mediaSource)
void Sound::update()
{
}

View File

@ -13,14 +13,16 @@
// 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.7 2003-11-18 21:39:02 stephena Exp $
// $Id: Sound.hxx,v 1.8 2003-11-19 15:57:10 stephena Exp $
//============================================================================
#ifndef SOUND_HXX
#define SOUND_HXX
class Console;
class MediaSource;
#include "bspf.hxx"
#include "MediaSrc.hxx"
/**
This class is a base class for the various sound objects.
@ -28,7 +30,7 @@
to compile Stella with no sound support whatsoever.
@author Stephen Anthony
@version $Id: Sound.hxx,v 1.7 2003-11-18 21:39:02 stephena Exp $
@version $Id: Sound.hxx,v 1.8 2003-11-19 15:57:10 stephena Exp $
*/
class Sound
{
@ -44,6 +46,15 @@ class Sound
virtual ~Sound();
public:
/**
Initializes the sound device. This must be called before any
calls are made to derived methods.
@param console The console
@param mediasrc The mediasource
*/
void init(Console* console, MediaSource* mediasrc);
/**
Closes the sound device
*/
@ -73,12 +84,10 @@ class Sound
virtual void setVolume(Int32 percent);
/**
Update the sound device using the audio sample from the specified
Update the sound device using the audio sample from the
media source.
@param mediaSource The media source to get audio samples from.
*/
virtual void updateSound(MediaSource& mediaSource);
virtual void update();
/**
Sets the pause status. While pause is selected, update()
@ -89,7 +98,14 @@ class Sound
void pause(bool status) { myPauseStatus = status; }
protected:
// The Console for the system
Console* myConsole;
// The Mediasource for the system
MediaSource* myMediaSource;
// The pause status
bool myPauseStatus;
};
#endif

View File

@ -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: Snapshot.cxx,v 1.7 2003-11-06 22:22:32 stephena Exp $
// $Id: Snapshot.cxx,v 1.8 2003-11-19 15:57:10 stephena Exp $
//============================================================================
#include <png.h>
@ -22,60 +22,71 @@
#include "bspf.hxx"
#include "FrameBuffer.hxx"
#include "Console.hxx"
#include "MediaSrc.hxx"
#include "Snapshot.hxx"
Snapshot::Snapshot()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Snapshot::Snapshot(Console* console, MediaSource* mediasrc)
: myConsole(console),
myMediaSource(mediasrc),
palette((png_colorp) NULL)
{
palette = (png_colorp) NULL;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Snapshot::~Snapshot()
{
if(palette)
delete[] palette;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Snapshot::png_write_data(png_structp ctx, png_bytep area, png_size_t size)
{
ofstream* out = (ofstream *) png_get_io_ptr(ctx);
out->write((const char *)area, size);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Snapshot::png_io_flush(png_structp ctx)
{
ofstream* out = (ofstream *) png_get_io_ptr(ctx);
out->flush();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Snapshot::png_user_warn(png_structp ctx, png_const_charp str)
{
cerr << "Snapshot: libpng warning: " << str << endl;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Snapshot::png_user_error(png_structp ctx, png_const_charp str)
{
cerr << "Snapshot: libpng error: " << str << endl;
}
/**
This routine saves the current frame buffer to a 256 color PNG file,
appropriately scaled by the amount specified in 'multiplier'.
*/
int Snapshot::savePNG(string filename, FrameBuffer& framebuffer, uInt32 multiplier)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 Snapshot::savePNG(string filename, uInt32 multiplier)
{
// FIXME - we shouldn't use the mediasource, but should instead use
// the framebuffer.
// Right now, the snapshot doesn't take into account any special effects
// that the framebuffer may be performing (aspect correction, OpenGL, etc)
// This will require framebuffer support for exporting its actual pixels,
// so it will have to wait ...
png_structp png_ptr = 0;
png_infop info_ptr = 0;
MediaSource* source = framebuffer.mediaSource();
uInt8* pixels = source->currentFrameBuffer();
uInt8* pixels = myMediaSource->currentFrameBuffer();
// PNG and window dimensions will be different because of scaling
int picWidth = framebuffer.width() * multiplier;
int picHeight = framebuffer.height() * multiplier;
int width = source->width();
int height = source->height();
uInt32 picWidth = myMediaSource->width() * multiplier << 1;
uInt32 picHeight = myMediaSource->height() * multiplier;
uInt32 width = myMediaSource->width();
uInt32 height = myMediaSource->height();
ofstream* out = new ofstream(filename.c_str());
if(!out)
@ -93,7 +104,7 @@ int Snapshot::savePNG(string filename, FrameBuffer& framebuffer, uInt32 multipli
return 0;
}
const uInt32* gamePalette = source->palette();
const uInt32* gamePalette = myMediaSource->palette();
for(uInt32 i = 0; i < 256; ++i)
{
palette[i].red = (uInt8) ((gamePalette[i] & 0x00ff0000) >> 16);
@ -138,26 +149,26 @@ int Snapshot::savePNG(string filename, FrameBuffer& framebuffer, uInt32 multipli
// The width has to be scaled by 2 * multiplier. Each pixel must be
// present scaleX times. Each scanline must be present scaleY times.
int scaleX = multiplier << 1;
int scaleY = multiplier;
uInt32 scaleX = multiplier << 1;
uInt32 scaleY = multiplier;
// Create a buffer to hold the new scanline.
uInt8* newScanline = new uInt8[width * scaleX];
uInt8* oldScanline;
// Look at each original scanline
for(int y = 0; y < height; y++)
for(uInt32 y = 0; y < height; y++)
{
// First construct a new scanline that is scaled
oldScanline = (uInt8*) pixels + y*width;
int px = 0;
for(int x = 0; x < width; x++)
for(int offx = 0; offx < scaleX; offx++)
uInt32 px = 0;
for(uInt32 x = 0; x < width; x++)
for(uInt32 offx = 0; offx < scaleX; offx++)
newScanline[px++] = oldScanline[x];
// Now output the new scanline 'scaleY' times
for(int offy = 0; offy < scaleY; offy++)
for(uInt32 offy = 0; offy < scaleY; offy++)
{
png_bytep row_pointer = (uInt8*) newScanline;
png_write_row(png_ptr, row_pointer);

View File

@ -13,25 +13,44 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Snapshot.hxx,v 1.4 2003-11-06 22:22:32 stephena Exp $
// $Id: Snapshot.hxx,v 1.5 2003-11-19 15:57:10 stephena Exp $
//============================================================================
#ifndef SNAPSHOT_HXX
#define SNAPSHOT_HXX
class Console;
class MediaSource;
#include <png.h>
#include "bspf.hxx"
class FrameBuffer;
class Snapshot
{
public:
Snapshot();
/**
Create a new shapshot class for taking snapshots in PNG format.
@param console The console
@param mediasrc The mediasource
*/
Snapshot(Console* console, MediaSource* mediasrc);
/**
The destructor.
*/
~Snapshot();
int savePNG(string filename, FrameBuffer& framebuffer, uInt32 multiplier = 1);
/**
This routine saves the current frame buffer to a PNG file,
appropriately scaled by the amount specified in 'multiplier'.
@param filename The filename of the PNG file
@param multiplier The amount that multiplication (zoom level)
@return The resulting error code
*/
uInt32 savePNG(string filename, uInt32 multiplier = 1);
private:
static void png_write_data(png_structp ctx, png_bytep area, png_size_t size);
@ -42,6 +61,13 @@ class Snapshot
static void png_user_error(png_structp ctx, png_const_charp str);
private:
// The Console for the system
Console* myConsole;
// The Mediasource for the system
MediaSource* myMediaSource;
// The PNG palette
png_colorp palette;
};

View File

@ -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.59 2003-11-18 21:39:02 stephena Exp $
// $Id: mainSDL.cxx,v 1.60 2003-11-19 15:57:10 stephena Exp $
//============================================================================
#include <fstream>
@ -816,8 +816,7 @@ int main(int argc, char* argv[])
startTime = getTicks();
handleEvents();
theDisplay->update();
theSound->updateSound(*theDisplay->mediaSource());
theConsole->update();
// Now, waste time if we need to so that we are at the desired frame rate
for(;;)
@ -853,8 +852,7 @@ int main(int argc, char* argv[])
startTime = getTicks();
handleEvents();
theDisplay->update();
theSound->updateSound(*theDisplay->mediaSource());
theConsole->update();
currentTime = getTicks();
virtualTime += timePerFrame;

View File

@ -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.5 2003-11-18 21:39:02 stephena Exp $
// $Id: SoundALSA.cxx,v 1.6 2003-11-19 15:57:10 stephena Exp $
//============================================================================
#include <alsa/asoundlib.h>
@ -238,7 +238,7 @@ void SoundALSA::setVolume(Int32 percent)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundALSA::updateSound(MediaSource& mediaSource)
void SoundALSA::update()
{
if(myIsInitializedFlag)
{
@ -249,10 +249,10 @@ void SoundALSA::updateSound(MediaSource& mediaSource)
uInt8 periodCount = 0;
// Dequeue samples as long as full fragments are available
while(mediaSource.numberOfAudioSamples() >= myBufferSize)
while(myMediaSource->numberOfAudioSamples() >= myBufferSize)
{
uInt8 buffer[myBufferSize];
mediaSource.dequeueAudioSamples(buffer, myBufferSize);
myMediaSource->dequeueAudioSamples(buffer, myBufferSize);
if((frames = snd_pcm_writei(myPcmHandle, buffer, myBufferSize)) == -EPIPE)
{

View File

@ -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.5 2003-11-18 21:39:02 stephena Exp $
// $Id: SoundALSA.hxx,v 1.6 2003-11-19 15:57:11 stephena Exp $
//============================================================================
#ifndef SOUNDALSA_HXX
@ -23,6 +23,7 @@
#include "Sound.hxx"
#include "bspf.hxx"
#include "Console.hxx"
#include "MediaSrc.hxx"
/**
@ -30,7 +31,7 @@
Advanced Linux Sound Architecture (ALSA) version 0.9.x API.
@author Stephen Anthony
@version $Id: SoundALSA.hxx,v 1.5 2003-11-18 21:39:02 stephena Exp $
@version $Id: SoundALSA.hxx,v 1.6 2003-11-19 15:57:11 stephena Exp $
*/
class SoundALSA : public Sound
{
@ -75,12 +76,10 @@ class SoundALSA : public Sound
void setVolume(Int32 percent);
/**
Update the sound device using the audio sample from the specified
Update the sound device using the audio sample from the
media source.
@param mediaSource The media source to get audio samples from.
*/
void updateSound(MediaSource& mediaSource);
void update();
private:
/**
@ -111,4 +110,5 @@ class SoundALSA : public Sound
// PCM sample rate
uInt32 mySampleRate;
};
#endif

View File

@ -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.4 2003-11-18 21:39:02 stephena Exp $
// $Id: SoundOSS.cxx,v 1.5 2003-11-19 15:57:11 stephena Exp $
//============================================================================
#include <fcntl.h>
@ -193,7 +193,7 @@ void SoundOSS::setVolume(Int32 percent)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundOSS::updateSound(MediaSource& mediaSource)
void SoundOSS::update()
{
if(myIsInitializedFlag)
{
@ -208,10 +208,10 @@ void SoundOSS::updateSound(MediaSource& mediaSource)
}
// Dequeue samples as long as full fragments are available
while(mediaSource.numberOfAudioSamples() >= (uInt32)info.fragsize)
while(myMediaSource->numberOfAudioSamples() >= (uInt32)info.fragsize)
{
uInt8 buffer[info.fragsize];
mediaSource.dequeueAudioSamples(buffer, (uInt32)info.fragsize);
myMediaSource->dequeueAudioSamples(buffer, (uInt32)info.fragsize);
write(myDspFd, buffer, info.fragsize);
}

View File

@ -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.4 2003-11-18 21:39:02 stephena Exp $
// $Id: SoundOSS.hxx,v 1.5 2003-11-19 15:57:11 stephena Exp $
//============================================================================
#ifndef SOUNDOSS_HXX
@ -28,7 +28,7 @@
Open Sound System (OSS) API.
@author Bradford W. Mott
@version $Id: SoundOSS.hxx,v 1.4 2003-11-18 21:39:02 stephena Exp $
@version $Id: SoundOSS.hxx,v 1.5 2003-11-19 15:57:11 stephena Exp $
*/
class SoundOSS : public Sound
{
@ -73,12 +73,10 @@ class SoundOSS : public Sound
void setVolume(Int32 percent);
/**
Update the sound device using the audio sample from the specified
Update the sound device using the audio sample from the
media source.
@param mediaSource The media source to get audio samples from.
*/
void updateSound(MediaSource& mediaSource);
void update();
private:
// Indicates if the sound device was successfully initialized

View File

@ -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.4 2003-11-18 21:39:02 stephena Exp $
// $Id: SoundSDL.cxx,v 1.5 2003-11-19 15:57:11 stephena Exp $
//============================================================================
#include <SDL.h>
@ -161,7 +161,7 @@ void SoundSDL::setVolume(Int32 percent)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundSDL::updateSound(MediaSource& mediaSource)
void SoundSDL::update()
{
if(myIsInitializedFlag)
{
@ -173,9 +173,9 @@ void SoundSDL::updateSound(MediaSource& mediaSource)
// Move all of the generated samples into the our private sample queue
uInt8 buffer[4096];
while(mediaSource.numberOfAudioSamples() > 0)
while(myMediaSource->numberOfAudioSamples() > 0)
{
uInt32 size = mediaSource.dequeueAudioSamples(buffer, 4096);
uInt32 size = myMediaSource->dequeueAudioSamples(buffer, 4096);
mySampleQueue.enqueue(buffer, size);
}

View File

@ -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 2003-11-18 21:39:02 stephena Exp $
// $Id: SoundSDL.hxx,v 1.5 2003-11-19 15:57:11 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.4 2003-11-18 21:39:02 stephena Exp $
@version $Id: SoundSDL.hxx,v 1.5 2003-11-19 15:57:11 stephena Exp $
*/
class SoundSDL : public Sound
{
@ -81,12 +81,10 @@ class SoundSDL : public Sound
void setVolume(Int32 percent);
/**
Update the sound device using the audio sample from the specified
Update the sound device using the audio sample from the
media source.
@param mediaSource The media source to get audio samples from.
*/
void updateSound(MediaSource& mediaSource);
void update();
private:
/**