mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-11 19:54:03 +00:00
cleaned up sound/mixer.h a bit; renamed some mixer methods for consistency
svn-id: r10018
This commit is contained in:
parent
5f2b0b6977
commit
11193b0746
@ -878,7 +878,7 @@ void Sound::pauseSounds(bool pause) {
|
||||
return;
|
||||
|
||||
_soundsPaused = pause;
|
||||
_scumm->_mixer->pause(pause);
|
||||
_scumm->_mixer->pauseMixer(pause);
|
||||
|
||||
_scumm->_sound->pauseBundleMusic(pause);
|
||||
|
||||
|
@ -68,8 +68,8 @@ public:
|
||||
void fnStartFx(uint32 sound, uint8 channel);
|
||||
bool startSpeech(uint16 textNum);
|
||||
bool speechFinished(void) { return _ingameSpeech == 0; };
|
||||
void fnPauseFx(void) { _mixer->pauseChannels(true); };
|
||||
void fnUnPauseFx(void) { _mixer->pauseChannels(false); };
|
||||
void fnPauseFx(void) { _mixer->pauseAll(true); };
|
||||
void fnUnPauseFx(void) { _mixer->pauseAll(false); };
|
||||
void fnStopFx(void);
|
||||
void stopSpeech(void);
|
||||
void checkFxQueue(void);
|
||||
|
@ -68,6 +68,8 @@ public:
|
||||
_volume = volume;
|
||||
}
|
||||
virtual void setChannelPan(const int8 pan) {
|
||||
if (pan != 0)
|
||||
printf("Pan set to %d\n", pan);
|
||||
_pan = pan;
|
||||
}
|
||||
virtual int getVolume() const {
|
||||
@ -151,6 +153,23 @@ SoundMixer::~SoundMixer() {
|
||||
_syst->delete_mutex(_mutex);
|
||||
}
|
||||
|
||||
bool SoundMixer::bindToSystem(OSystem *syst) {
|
||||
_syst = syst;
|
||||
_mutex = _syst->create_mutex();
|
||||
_outputRate = (uint) syst->property(OSystem::PROP_GET_SAMPLE_RATE, 0);
|
||||
|
||||
if (_outputRate == 0)
|
||||
error("OSystem returned invalid sample rate");
|
||||
|
||||
return syst->set_sound_proc(mixCallback, this, OSystem::SOUND_16BIT);
|
||||
}
|
||||
|
||||
void SoundMixer::setupPremix(void *param, PremixProc *proc) {
|
||||
StackLock lock(_mutex);
|
||||
_premixParam = param;
|
||||
_premixProc = proc;
|
||||
}
|
||||
|
||||
int SoundMixer::newStream(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, uint32 buffer_size, byte volume, int8 pan) {
|
||||
StackLock lock(_mutex);
|
||||
return insertChannel(handle, new ChannelStream(this, handle, sound, size, rate, flags, buffer_size, volume, pan));
|
||||
@ -291,17 +310,6 @@ void SoundMixer::mixCallback(void *s, byte *samples, int len) {
|
||||
((SoundMixer *)s)->mix((int16 *)samples, len >> 2);
|
||||
}
|
||||
|
||||
bool SoundMixer::bindToSystem(OSystem *syst) {
|
||||
_syst = syst;
|
||||
_mutex = _syst->create_mutex();
|
||||
_outputRate = (uint) syst->property(OSystem::PROP_GET_SAMPLE_RATE, 0);
|
||||
|
||||
if (_outputRate == 0)
|
||||
error("OSystem returned invalid sample rate");
|
||||
|
||||
return syst->set_sound_proc(mixCallback, this, OSystem::SOUND_16BIT);
|
||||
}
|
||||
|
||||
void SoundMixer::stopAll() {
|
||||
StackLock lock(_mutex);
|
||||
for (int i = 0; i != NUM_CHANNELS; i++)
|
||||
@ -382,11 +390,14 @@ void SoundMixer::setChannelPan(PlayingSoundHandle handle, int8 pan) {
|
||||
_channels[index]->setChannelPan(pan);
|
||||
}
|
||||
|
||||
void SoundMixer::pause(bool paused) {
|
||||
void SoundMixer::pauseMixer(bool paused) {
|
||||
// TODO/FIXME: This is only used by scumm/sound.cpp, and
|
||||
// even there it can probably be replaced by a call to pauseAll.
|
||||
// Research that, and if possible remove this method.
|
||||
_paused = paused;
|
||||
}
|
||||
|
||||
void SoundMixer::pauseChannels(bool paused) {
|
||||
void SoundMixer::pauseAll(bool paused) {
|
||||
_channelsPaused = paused;
|
||||
}
|
||||
|
||||
@ -441,12 +452,6 @@ bool SoundMixer::hasActiveSFXChannel() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void SoundMixer::setupPremix(void *param, PremixProc *proc) {
|
||||
StackLock lock(_mutex);
|
||||
_premixParam = param;
|
||||
_premixProc = proc;
|
||||
}
|
||||
|
||||
void SoundMixer::setVolume(int volume) {
|
||||
// Check range
|
||||
if (volume > 256)
|
||||
|
@ -52,7 +52,6 @@ public:
|
||||
};
|
||||
|
||||
enum {
|
||||
// Do *NOT* change any of these flags without looking at the code in mixer.cpp
|
||||
FLAG_UNSIGNED = 1 << 0, // unsigned samples (default: signed)
|
||||
FLAG_STEREO = 1 << 1, // sound is in stereo (default: mono)
|
||||
FLAG_16BITS = 1 << 2, // sound is 16 bits wide (default: 8bit)
|
||||
@ -81,6 +80,14 @@ public:
|
||||
SoundMixer();
|
||||
~SoundMixer();
|
||||
|
||||
/** bind to the OSystem object => mixer will be
|
||||
* invoked automatically when samples need
|
||||
* to be generated */
|
||||
bool bindToSystem(OSystem *syst);
|
||||
|
||||
/** Premix procedure, useful when using fmopl adlib */
|
||||
void setupPremix(void * param, PremixProc * proc);
|
||||
|
||||
// start playing a raw sound
|
||||
int playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags,
|
||||
byte volume, int8 pan, int id = -1, uint32 loopStart = 0, uint32 loopEnd = 0);
|
||||
@ -92,8 +99,14 @@ public:
|
||||
int playVorbis(PlayingSoundHandle *handle, OggVorbis_File *ov_file, int duration, bool is_cd_track, byte volume, int8 pan);
|
||||
#endif
|
||||
|
||||
/** Premix procedure, useful when using fmopl adlib */
|
||||
void setupPremix(void * param, PremixProc * proc);
|
||||
/** Start a new stream. */
|
||||
int newStream(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, uint32 buffer_size, byte volume, int8 pan);
|
||||
|
||||
/** Append to an existing stream. */
|
||||
void appendStream(PlayingSoundHandle handle, void *sound, uint32 size);
|
||||
|
||||
/** Mark a stream as finished - it will play all its remaining data, then stop. */
|
||||
void endStream(PlayingSoundHandle handle);
|
||||
|
||||
/** stop all currently playing sounds */
|
||||
void stopAll();
|
||||
@ -107,6 +120,12 @@ public:
|
||||
/** stop playing the channel for the given handle */
|
||||
void stopHandle(PlayingSoundHandle handle);
|
||||
|
||||
/** pause/unpause all mixing (including adlib) */
|
||||
void pauseMixer(bool paused);
|
||||
|
||||
/** pause/unpause all channels */
|
||||
void pauseAll(bool paused);
|
||||
|
||||
/** pause/unpause the given channel */
|
||||
void pauseChannel(int index, bool paused);
|
||||
|
||||
@ -116,35 +135,15 @@ public:
|
||||
/** pause/unpause the channel for the given handle */
|
||||
void pauseHandle(PlayingSoundHandle handle, bool paused);
|
||||
|
||||
/** changing the channel volume for the given handle (0 - 255) */
|
||||
/** set the channel volume for the given handle (0 - 255) */
|
||||
void setChannelVolume(PlayingSoundHandle handle, byte volume);
|
||||
|
||||
/** changing the channel pan for the given handle (-127 ... 0 ... 127) (left ... center ... right)*/
|
||||
/** set the channel pan for the given handle (-127 ... 0 ... 127) (left ... center ... right)*/
|
||||
void setChannelPan(PlayingSoundHandle handle, int8 pan);
|
||||
|
||||
/** Start a new stream. */
|
||||
int newStream(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, uint32 buffer_size, byte volume, int8 pan);
|
||||
|
||||
/** Append to an existing stream. */
|
||||
void appendStream(PlayingSoundHandle handle, void *sound, uint32 size);
|
||||
|
||||
/** Mark a stream as finished - it will play all its remaining data, then stop. */
|
||||
void endStream(PlayingSoundHandle handle);
|
||||
|
||||
/** Check whether any SFX channel is active.*/
|
||||
bool hasActiveSFXChannel();
|
||||
|
||||
/** bind to the OSystem object => mixer will be
|
||||
* invoked automatically when samples need
|
||||
* to be generated */
|
||||
bool bindToSystem(OSystem *syst);
|
||||
|
||||
/** pause - unpause */
|
||||
void pause(bool paused);
|
||||
|
||||
/** pause - unpause channels, keep adlib music running */
|
||||
void pauseChannels(bool paused);
|
||||
|
||||
/** set the global volume, 0-256 */
|
||||
void setVolume(int volume);
|
||||
|
||||
@ -163,7 +162,7 @@ public:
|
||||
private:
|
||||
int insertChannel(PlayingSoundHandle *handle, Channel *chan);
|
||||
|
||||
/** mix */
|
||||
/** main mixer method */
|
||||
void mix(int16 * buf, uint len);
|
||||
|
||||
static void mixCallback(void *s, byte *samples, int len);
|
||||
|
Loading…
Reference in New Issue
Block a user