aboutsummaryrefslogtreecommitdiff
path: root/sound/mixer.h
diff options
context:
space:
mode:
authorMax Horn2008-06-28 15:28:29 +0000
committerMax Horn2008-06-28 15:28:29 +0000
commitc45d632f3b8c2d8c8aa46b05db758898de863e97 (patch)
tree7b8fee1589eb6a733aea389b305752ee7d63562b /sound/mixer.h
parente68efca5a19fd738a78a61ea21efd19280521f31 (diff)
downloadscummvm-rg350-c45d632f3b8c2d8c8aa46b05db758898de863e97.tar.gz
scummvm-rg350-c45d632f3b8c2d8c8aa46b05db758898de863e97.tar.bz2
scummvm-rg350-c45d632f3b8c2d8c8aa46b05db758898de863e97.zip
Patch ##1956946 (Audio::Mixer internal API revision) with some tweaks
svn-id: r32828
Diffstat (limited to 'sound/mixer.h')
-rw-r--r--sound/mixer.h85
1 files changed, 27 insertions, 58 deletions
diff --git a/sound/mixer.h b/sound/mixer.h
index 26ae0898fd..28988256b3 100644
--- a/sound/mixer.h
+++ b/sound/mixer.h
@@ -38,6 +38,7 @@ namespace Audio {
class AudioStream;
class Channel;
class Mixer;
+class MixerImpl;
/**
* A SoundHandle instances corresponds to a specific sound
@@ -47,7 +48,7 @@ class Mixer;
*/
class SoundHandle {
friend class Channel;
- friend class Mixer;
+ friend class MixerImpl;
uint32 _val;
public:
inline SoundHandle() : _val(0xFFFFFFFF) {}
@@ -104,24 +105,9 @@ public:
kMaxMixerVolume = 256
};
-private:
- enum {
- NUM_CHANNELS = 16
- };
-
- OSystem *_syst;
- Common::Mutex _mutex;
-
- int _volumeForSoundType[4];
-
- uint32 _handleSeed;
- Channel *_channels[NUM_CHANNELS];
-
- bool _mixerReady;
-
public:
- Mixer();
- ~Mixer();
+ Mixer() {}
+ virtual ~Mixer() {}
@@ -132,8 +118,10 @@ public:
* sync with an audio stream. In particular, the Adlib MIDI emulation...
*
* @return whether the mixer is ready and setup
+ *
+ * @todo get rid of this?
*/
- bool isReady() const { return _mixerReady; }
+ virtual bool isReady() const = 0;
@@ -143,12 +131,12 @@ public:
* (using the makeLinearInputStream factory function), which is then
* passed on to playInputStream.
*/
- void playRaw(
+ virtual void playRaw(
SoundType type,
SoundHandle *handle,
void *sound, uint32 size, uint rate, byte flags,
int id = -1, byte volume = kMaxChannelVolume, int8 balance = 0,
- uint32 loopStart = 0, uint32 loopEnd = 0);
+ uint32 loopStart = 0, uint32 loopEnd = 0) = 0;
/**
* Start playing the given audio input stream.
@@ -170,35 +158,35 @@ public:
* not stop this particular stream
* @param reverseStereo a flag indicating whether left and right channels shall be swapped
*/
- void playInputStream(
+ virtual void playInputStream(
SoundType type,
SoundHandle *handle,
AudioStream *input,
int id = -1, byte volume = kMaxChannelVolume, int8 balance = 0,
bool autofreeStream = true,
bool permanent = false,
- bool reverseStereo = false);
+ bool reverseStereo = false) = 0;
/**
* Stop all currently playing sounds.
*/
- void stopAll();
+ virtual void stopAll() = 0;
/**
* Stop playing the sound with given ID.
*
* @param id the ID of the sound to affect
*/
- void stopID(int id);
+ virtual void stopID(int id) = 0;
/**
* Stop playing the sound corresponding to the given handle.
*
* @param handle the sound to affect
*/
- void stopHandle(SoundHandle handle);
+ virtual void stopHandle(SoundHandle handle) = 0;
@@ -208,7 +196,7 @@ public:
*
* @param paused true to pause everything, false to unpause
*/
- void pauseAll(bool paused);
+ virtual void pauseAll(bool paused) = 0;
/**
* Pause/unpause the sound with the given ID.
@@ -216,7 +204,7 @@ public:
* @param id the ID of the sound to affect
* @param paused true to pause the sound, false to unpause it
*/
- void pauseID(int id, bool paused);
+ virtual void pauseID(int id, bool paused) = 0;
/**
* Pause/unpause the sound corresponding to the given handle.
@@ -224,7 +212,7 @@ public:
* @param handle the sound to affect
* @param paused true to pause the sound, false to unpause it
*/
- void pauseHandle(SoundHandle handle, bool paused);
+ virtual void pauseHandle(SoundHandle handle, bool paused) = 0;
@@ -234,7 +222,7 @@ public:
* @param id the ID of the sound to query
* @return true if the sound is active
*/
- bool isSoundIDActive(int id);
+ virtual bool isSoundIDActive(int id) = 0;
/**
* Get the sound ID of handle sound
@@ -242,7 +230,7 @@ public:
* @param handle sound to query
* @return sound ID if active
*/
- int getSoundID(SoundHandle handle);
+ virtual int getSoundID(SoundHandle handle) = 0;
/**
* Check if a sound with the given handle is active.
@@ -250,7 +238,7 @@ public:
* @param handle sound to query
* @return true if the sound is active
*/
- bool isSoundHandleActive(SoundHandle handle);
+ virtual bool isSoundHandleActive(SoundHandle handle) = 0;
@@ -260,7 +248,7 @@ public:
* @param handle the sound to affect
* @param volume the new channel volume (0 - kMaxChannelVolume)
*/
- void setChannelVolume(SoundHandle handle, byte volume);
+ virtual void setChannelVolume(SoundHandle handle, byte volume) = 0;
/**
* Set the channel balance for the given handle.
@@ -269,12 +257,12 @@ public:
* @param balance the new channel balance:
* (-127 ... 0 ... 127) corresponds to (left ... center ... right)
*/
- void setChannelBalance(SoundHandle handle, int8 balance);
+ virtual void setChannelBalance(SoundHandle handle, int8 balance) = 0;
/**
* Get approximation of for how long the channel has been playing.
*/
- uint32 getSoundElapsedTime(SoundHandle handle);
+ virtual uint32 getSoundElapsedTime(SoundHandle handle) = 0;
/**
* Check whether any channel of the given sound type is active.
@@ -284,7 +272,7 @@ public:
* @param type the sound type to look for
* @return true if any channels of the specified type are active.
*/
- bool hasActiveChannelOfType(SoundType type);
+ virtual bool hasActiveChannelOfType(SoundType type) = 0;
/**
* Set the volume for the given sound type.
@@ -292,7 +280,7 @@ public:
* @param type the sound type
* @param volume the new global volume, 0 - kMaxMixerVolume
*/
- void setVolumeForSoundType(SoundType type, int volume);
+ virtual void setVolumeForSoundType(SoundType type, int volume) = 0;
/**
* Query the global volume.
@@ -300,7 +288,7 @@ public:
* @param type the sound type
* @return the global music volume, 0 - kMaxMixerVolume
*/
- int getVolumeForSoundType(SoundType type) const;
+ virtual int getVolumeForSoundType(SoundType type) const = 0;
/**
* Query the system's audio output sample rate. This returns
@@ -308,26 +296,7 @@ public:
*
* @return the output sample rate in Hz
*/
- uint getOutputRate() const;
-
-protected:
- void insertChannel(SoundHandle *handle, Channel *chan);
-
- /**
- * Internal main method -- all the actual mixing work is done from here.
- */
- void mix(int16 * buf, uint len);
-
- // FIXME: temporary "public" to allow access to mixCallback
- // from within OSystem::makeMixer()
-public:
- /**
- * The mixer callback function, passed on to OSystem::setSoundCallback().
- * This simply calls the mix() method.
- */
- static void mixCallback(void *s, byte *samples, int len);
-
- void setReady(bool ready) { _mixerReady = ready; }
+ virtual uint getOutputRate() const = 0;
};