[Scummvm-cvs-logs] SF.net SVN: scummvm: [25752] scummvm/trunk
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Tue Feb 20 19:50:18 CET 2007
Revision: 25752
http://scummvm.svn.sourceforge.net/scummvm/?rev=25752&view=rev
Author: fingolfin
Date: 2007-02-20 10:50:17 -0800 (Tue, 20 Feb 2007)
Log Message:
-----------
Patch #1663933 (Kill premix channel) with a few tiny additional tweaks by me
Modified Paths:
--------------
scummvm/trunk/engines/agi/sound.cpp
scummvm/trunk/engines/agi/sound.h
scummvm/trunk/engines/cine/sound_driver.cpp
scummvm/trunk/engines/cine/sound_driver.h
scummvm/trunk/engines/engine.cpp
scummvm/trunk/engines/kyra/sound.h
scummvm/trunk/engines/kyra/sound_adlib.cpp
scummvm/trunk/engines/scumm/player_mod.cpp
scummvm/trunk/engines/scumm/player_mod.h
scummvm/trunk/engines/scumm/player_nes.cpp
scummvm/trunk/engines/scumm/player_nes.h
scummvm/trunk/engines/scumm/player_v2.cpp
scummvm/trunk/engines/scumm/player_v2.h
scummvm/trunk/engines/sky/music/adlibmusic.cpp
scummvm/trunk/engines/sky/music/adlibmusic.h
scummvm/trunk/engines/sword1/music.cpp
scummvm/trunk/engines/sword1/music.h
scummvm/trunk/engines/sword2/sound.cpp
scummvm/trunk/engines/sword2/sound.h
scummvm/trunk/sound/mixer.cpp
scummvm/trunk/sound/mixer.h
scummvm/trunk/sound/softsynth/adlib.cpp
scummvm/trunk/sound/softsynth/emumidi.h
scummvm/trunk/sound/softsynth/ym2612.cpp
Modified: scummvm/trunk/engines/agi/sound.cpp
===================================================================
--- scummvm/trunk/engines/agi/sound.cpp 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/engines/agi/sound.cpp 2007-02-20 18:50:17 UTC (rev 25752)
@@ -324,14 +324,14 @@
/*loadInstruments("demo.sys"); */
#endif
- _mixer->setupPremix(this);
+ _mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, false, true);
return r;
}
void SoundMgr::deinitSound() {
debugC(3, kDebugLevelSound, "()");
- _mixer->setupPremix(NULL);
+ _mixer->stopHandle(_soundHandle);
free(sndBuffer);
}
Modified: scummvm/trunk/engines/agi/sound.h
===================================================================
--- scummvm/trunk/engines/agi/sound.h 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/engines/agi/sound.h 2007-02-20 18:50:17 UTC (rev 25752)
@@ -26,11 +26,8 @@
#define AGI_SOUND_H
#include "sound/audiostream.h"
+#include "sound/mixer.h"
-namespace Audio {
-class Mixer;
-} // End of namespace Audio
-
namespace Agi {
#define BUFFER_SIZE 410
@@ -128,6 +125,7 @@
private:
Audio::Mixer *_mixer;
+ Audio::SoundHandle _soundHandle;
uint32 _sampleRate;
void premixerCall(int16 *buf, uint len);
Modified: scummvm/trunk/engines/cine/sound_driver.cpp
===================================================================
--- scummvm/trunk/engines/cine/sound_driver.cpp 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/engines/cine/sound_driver.cpp 2007-02-20 18:50:17 UTC (rev 25752)
@@ -60,11 +60,11 @@
memset(_channelsVolumeTable, 0, sizeof(_channelsVolumeTable));
memset(_instrumentsTable, 0, sizeof(_instrumentsTable));
initCard();
- _mixer->setupPremix(this);
+ _mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, false, true);
}
AdlibSoundDriver::~AdlibSoundDriver() {
- _mixer->setupPremix(NULL);
+ _mixer->stopHandle(_soundHandle);
}
void AdlibSoundDriver::setupChannel(int channel, const byte *data, int instrument, int volume) {
Modified: scummvm/trunk/engines/cine/sound_driver.h
===================================================================
--- scummvm/trunk/engines/cine/sound_driver.h 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/engines/cine/sound_driver.h 2007-02-20 18:50:17 UTC (rev 25752)
@@ -27,11 +27,8 @@
#include "sound/audiostream.h"
#include "sound/fmopl.h"
+#include "sound/mixer.h"
-namespace Audio {
- class Mixer;
-}
-
namespace Cine {
class SoundDriver {
@@ -105,6 +102,7 @@
FM_OPL *_opl;
int _sampleRate;
Audio::Mixer *_mixer;
+ Audio::SoundHandle _soundHandle;
byte _vibrato;
int _channelsVolumeTable[4];
Modified: scummvm/trunk/engines/engine.cpp
===================================================================
--- scummvm/trunk/engines/engine.cpp 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/engines/engine.cpp 2007-02-20 18:50:17 UTC (rev 25752)
@@ -50,7 +50,7 @@
}
Engine::~Engine() {
- _mixer->stopAll(true);
+ _mixer->stopAll();
g_engine = NULL;
}
Modified: scummvm/trunk/engines/kyra/sound.h
===================================================================
--- scummvm/trunk/engines/kyra/sound.h 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/engines/kyra/sound.h 2007-02-20 18:50:17 UTC (rev 25752)
@@ -57,8 +57,6 @@
namespace Audio {
class AudioStream;
-class Mixer;
-class SoundHandle;
} // end of namespace Audio
namespace Kyra {
Modified: scummvm/trunk/engines/kyra/sound_adlib.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_adlib.cpp 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/engines/kyra/sound_adlib.cpp 2007-02-20 18:50:17 UTC (rev 25752)
@@ -406,6 +406,7 @@
Common::Mutex _mutex;
Audio::Mixer *_mixer;
+ Audio::SoundHandle _soundHandle;
bool _v2;
@@ -445,7 +446,7 @@
_tablePtr1 = _tablePtr2 = 0;
- _mixer->setupPremix(this);
+ _mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, false, true);
_samplesPerCallback = getRate() / CALLBACKS_PER_SECOND;
_samplesPerCallbackRemainder = getRate() % CALLBACKS_PER_SECOND;
@@ -456,7 +457,7 @@
}
AdlibDriver::~AdlibDriver() {
- _mixer->setupPremix(0);
+ _mixer->stopHandle(_soundHandle);
OPLDestroy(_adlib);
_adlib = 0;
}
Modified: scummvm/trunk/engines/scumm/player_mod.cpp
===================================================================
--- scummvm/trunk/engines/scumm/player_mod.cpp 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/engines/scumm/player_mod.cpp 2007-02-20 18:50:17 UTC (rev 25752)
@@ -46,12 +46,11 @@
_playproc = NULL;
_playparam = NULL;
- _mixer->setupPremix(this);
+ _mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, false, true);
}
Player_MOD::~Player_MOD() {
- // Detach the premix callback handler
- _mixer->setupPremix(0);
+ _mixer->stopHandle(_soundHandle);
for (int i = 0; i < MOD_MAXCHANS; i++) {
if (!_channels[i].id)
continue;
Modified: scummvm/trunk/engines/scumm/player_mod.h
===================================================================
--- scummvm/trunk/engines/scumm/player_mod.h 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/engines/scumm/player_mod.h 2007-02-20 18:50:17 UTC (rev 25752)
@@ -26,6 +26,7 @@
#include "scumm/scumm.h"
#include "sound/audiostream.h"
+#include "sound/mixer.h"
namespace Audio {
class RateConverter;
@@ -77,6 +78,7 @@
};
Audio::Mixer *_mixer;
+ Audio::SoundHandle _soundHandle;
uint32 _mixamt;
uint32 _mixpos;
Modified: scummvm/trunk/engines/scumm/player_nes.cpp
===================================================================
--- scummvm/trunk/engines/scumm/player_nes.cpp 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/engines/scumm/player_nes.cpp 2007-02-20 18:50:17 UTC (rev 25752)
@@ -620,11 +620,11 @@
APU_writeControl(0);
- _mixer->setupPremix(this);
+ _mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, false, true);
}
Player_NES::~Player_NES() {
- _mixer->setupPremix(0);
+ _mixer->stopHandle(_soundHandle);
delete _apu;
}
Modified: scummvm/trunk/engines/scumm/player_nes.h
===================================================================
--- scummvm/trunk/engines/scumm/player_nes.h 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/engines/scumm/player_nes.h 2007-02-20 18:50:17 UTC (rev 25752)
@@ -27,11 +27,8 @@
#include "common/scummsys.h"
#include "scumm/music.h"
#include "sound/audiostream.h"
+#include "sound/mixer.h"
-namespace Audio {
- class Mixer;
-}
-
namespace Scumm {
class ScummEngine;
@@ -80,6 +77,7 @@
ScummEngine *_vm;
Audio::Mixer *_mixer;
+ Audio::SoundHandle _soundHandle;
APUe::APU *_apu;
int _sample_rate;
int _samples_per_frame;
Modified: scummvm/trunk/engines/scumm/player_v2.cpp
===================================================================
--- scummvm/trunk/engines/scumm/player_v2.cpp 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/engines/scumm/player_v2.cpp 2007-02-20 18:50:17 UTC (rev 25752)
@@ -375,13 +375,12 @@
set_pcjr(pcjr);
setMusicVolume(255);
- _mixer->setupPremix(this);
+ _mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, false, true);
}
Player_V2::~Player_V2() {
mutex_up();
- // Detach the premix callback handler
- _mixer->setupPremix(0);
+ _mixer->stopHandle(_soundHandle);
mutex_down();
}
Modified: scummvm/trunk/engines/scumm/player_v2.h
===================================================================
--- scummvm/trunk/engines/scumm/player_v2.h 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/engines/scumm/player_v2.h 2007-02-20 18:50:17 UTC (rev 25752)
@@ -28,11 +28,8 @@
#include "common/mutex.h"
#include "scumm/music.h"
#include "sound/audiostream.h"
+#include "sound/mixer.h"
-namespace Audio {
- class Mixer;
-}
-
namespace Scumm {
class ScummEngine;
@@ -96,6 +93,7 @@
protected:
bool _isV3Game;
Audio::Mixer *_mixer;
+ Audio::SoundHandle _soundHandle;
ScummEngine *_vm;
bool _pcjr;
Modified: scummvm/trunk/engines/sky/music/adlibmusic.cpp
===================================================================
--- scummvm/trunk/engines/sky/music/adlibmusic.cpp 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/engines/sky/music/adlibmusic.cpp 2007-02-20 18:50:17 UTC (rev 25752)
@@ -39,12 +39,12 @@
_opl = makeAdlibOPL(_sampleRate);
- _mixer->setupPremix(this);
+ _mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, false, true);
}
AdlibMusic::~AdlibMusic(void) {
- _mixer->setupPremix(0);
+ _mixer->stopHandle(_soundHandle);
}
void AdlibMusic::premixerCall(int16 *data, uint len) {
Modified: scummvm/trunk/engines/sky/music/adlibmusic.h
===================================================================
--- scummvm/trunk/engines/sky/music/adlibmusic.h 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/engines/sky/music/adlibmusic.h 2007-02-20 18:50:17 UTC (rev 25752)
@@ -26,11 +26,8 @@
#include "sky/music/musicbase.h"
#include "sound/audiostream.h"
#include "sound/fmopl.h"
+#include "sound/mixer.h"
-namespace Audio {
- class Mixer;
-}
-
namespace Sky {
class AdlibMusic : public Audio::AudioStream, public MusicBase {
@@ -50,6 +47,7 @@
private:
FM_OPL *_opl;
Audio::Mixer *_mixer;
+ Audio::SoundHandle _soundHandle;
uint8 *_initSequence;
uint32 _sampleRate, _nextMusicPoll;
virtual void setupPointers(void);
Modified: scummvm/trunk/engines/sword1/music.cpp
===================================================================
--- scummvm/trunk/engines/sword1/music.cpp 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/engines/sword1/music.cpp 2007-02-20 18:50:17 UTC (rev 25752)
@@ -255,11 +255,11 @@
_converter[0] = NULL;
_converter[1] = NULL;
_volumeL = _volumeR = 192;
- _mixer->setupPremix(this);
+ _mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, false, true);
}
Music::~Music() {
- _mixer->setupPremix(0);
+ _mixer->stopHandle(_soundHandle);
delete _converter[0];
delete _converter[1];
}
Modified: scummvm/trunk/engines/sword1/music.h
===================================================================
--- scummvm/trunk/engines/sword1/music.h 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/engines/sword1/music.h 2007-02-20 18:50:17 UTC (rev 25752)
@@ -27,12 +27,9 @@
#include "common/mutex.h"
#include "common/file.h"
#include "sound/audiostream.h"
+#include "sound/mixer.h"
#include "sound/rate.h"
-namespace Audio {
- class Mixer;
-}
-
namespace Sword1 {
#define TOTAL_TUNES 270
@@ -108,6 +105,7 @@
MusicHandle _handles[2];
Audio::RateConverter *_converter[2];
Audio::Mixer *_mixer;
+ Audio::SoundHandle _soundHandle;
uint32 _sampleRate;
Common::Mutex _mutex;
Modified: scummvm/trunk/engines/sword2/sound.cpp
===================================================================
--- scummvm/trunk/engines/sword2/sound.cpp 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/engines/sword2/sound.cpp 2007-02-20 18:50:17 UTC (rev 25752)
@@ -83,11 +83,11 @@
_mixBuffer = NULL;
_mixBufferLen = 0;
- _vm->_mixer->setupPremix(this, Audio::Mixer::kMusicSoundType);
+ _vm->_mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_mixerSoundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, false, true);
}
Sound::~Sound() {
- _vm->_mixer->setupPremix(0);
+ _vm->_mixer->stopHandle(_mixerSoundHandle);
clearFxQueue(true);
stopMusic(true);
Modified: scummvm/trunk/engines/sword2/sound.h
===================================================================
--- scummvm/trunk/engines/sword2/sound.h 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/engines/sword2/sound.h 2007-02-20 18:50:17 UTC (rev 25752)
@@ -176,6 +176,7 @@
Common::Mutex _mutex;
+ Audio::SoundHandle _mixerSoundHandle;
Audio::SoundHandle _leadInHandle;
Audio::SoundHandle _leadOutHandle;
Modified: scummvm/trunk/sound/mixer.cpp
===================================================================
--- scummvm/trunk/sound/mixer.cpp 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/sound/mixer.cpp 2007-02-20 18:50:17 UTC (rev 25752)
@@ -108,7 +108,6 @@
_handleSeed = 0;
- _premixChannel = 0;
int i = 0;
for (i = 0; i < ARRAYSIZE(_volumeForSoundType); i++)
@@ -121,29 +120,14 @@
}
Mixer::~Mixer() {
- stopAll(true);
-
- delete _premixChannel;
- _premixChannel = 0;
+ for (int i = 0; i != NUM_CHANNELS; i++)
+ delete _channels[i];
}
uint Mixer::getOutputRate() const {
return (uint)_syst->getOutputSampleRate();
}
-void Mixer::setupPremix(AudioStream *stream, SoundType type) {
- Common::StackLock lock(_mutex);
-
- delete _premixChannel;
- _premixChannel = 0;
-
- if (stream == 0)
- return;
-
- // Create the channel
- _premixChannel = new Channel(this, type, stream, false);
-}
-
void Mixer::insertChannel(SoundHandle *handle, Channel *chan) {
int index = -1;
@@ -246,10 +230,7 @@
// zero the buf
memset(buf, 0, 2 * len * sizeof(int16));
- if (_premixChannel && !_premixChannel->isPaused())
- _premixChannel->mix(buf, len);
-
- // now mix all channels
+ // mix all channels
for (int i = 0; i != NUM_CHANNELS; i++)
if (_channels[i]) {
if (_channels[i]->isFinished()) {
@@ -268,18 +249,14 @@
((Mixer *)s)->mix((int16 *)samples, len >> 2);
}
-void Mixer::stopAll(bool force) {
+void Mixer::stopAll() {
Common::StackLock lock(_mutex);
for (int i = 0; i != NUM_CHANNELS; i++) {
- if (_channels[i] != 0) {
- if (force || !_channels[i]->isPermanent()) {
- delete _channels[i];
- _channels[i] = 0;
- }
+ if (_channels[i] != 0 && !_channels[i]->isPermanent()) {
+ delete _channels[i];
+ _channels[i] = 0;
}
}
-
- // Note: the _premixChannel is *not* affected by stopAll!
}
void Mixer::stopID(int id) {
@@ -341,10 +318,6 @@
_channels[i]->pause(paused);
}
}
-
- // Unlike stopAll, we also pause the premix channel, if present.
- if (_premixChannel)
- _premixChannel->pause(paused);
}
void Mixer::pauseID(int id, bool paused) {
Modified: scummvm/trunk/sound/mixer.h
===================================================================
--- scummvm/trunk/sound/mixer.h 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/sound/mixer.h 2007-02-20 18:50:17 UTC (rev 25752)
@@ -102,8 +102,6 @@
OSystem *_syst;
Common::Mutex _mutex;
- Channel *_premixChannel;
-
int _volumeForSoundType[4];
uint32 _handleSeed;
@@ -120,8 +118,8 @@
/**
* Is the mixer ready and setup? This may not be the case on systems which
* don't support digital sound output. In that case, the mixer proc may
- * never be called. That in turn can cause breakage in games which use the
- * premix callback for syncing. In particular, the Adlib MIDI emulation...
+ * never be called. That in turn can cause breakage in games which try to
+ * sync with an audio stream. In particular, the Adlib MIDI emulation...
*
* @return whether the mixer is ready and setup
*/
@@ -130,15 +128,6 @@
/**
- * Set the premix stream. This is mainly used for the adlib music, but
- * is not limited to it. The premix stream is invoked by the mixer whenever
- * it needs to generate any data, before any other mixing takes place.
- */
- void setupPremix(AudioStream *stream, SoundType type = kPlainSoundType);
-
-
-
- /**
* Start playing the given raw sound data.
* Internally, this simply creates an audio input stream wrapping the data
* (using the makeLinearInputStream factory function), which is then
@@ -182,7 +171,7 @@
/**
* Stop all currently playing sounds.
*/
- void stopAll(bool force = false);
+ void stopAll();
/**
* Stop playing the sound with given ID.
@@ -201,8 +190,8 @@
/**
- * Pause/unpause all sounds, including all regular channels and the
- * premix channel.
+ * Pause/unpause all sounds, including all regular and permanent
+ * channels
*
* @param paused true to pause everything, false to unpause
*/
Modified: scummvm/trunk/sound/softsynth/adlib.cpp
===================================================================
--- scummvm/trunk/sound/softsynth/adlib.cpp 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/sound/softsynth/adlib.cpp 2007-02-20 18:50:17 UTC (rev 25752)
@@ -847,7 +847,7 @@
adlib_write(0xBD, 0x00);
create_lookup_table();
- _mixer->setupPremix(this);
+ _mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_mixerSoundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, false, true);
return 0;
}
@@ -857,8 +857,7 @@
return;
_isOpen = false;
- // Detach the premix callback handler
- _mixer->setupPremix(0);
+ _mixer->stopHandle(_mixerSoundHandle);
uint i;
for (i = 0; i < ARRAYSIZE(_voices); ++i) {
Modified: scummvm/trunk/sound/softsynth/emumidi.h
===================================================================
--- scummvm/trunk/sound/softsynth/emumidi.h 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/sound/softsynth/emumidi.h 2007-02-20 18:50:17 UTC (rev 25752)
@@ -30,6 +30,7 @@
protected:
bool _isOpen;
Audio::Mixer *_mixer;
+ Audio::SoundHandle _mixerSoundHandle;
private:
Common::TimerManager::TimerProc _timerProc;
Modified: scummvm/trunk/sound/softsynth/ym2612.cpp
===================================================================
--- scummvm/trunk/sound/softsynth/ym2612.cpp 2007-02-20 18:04:13 UTC (rev 25751)
+++ scummvm/trunk/sound/softsynth/ym2612.cpp 2007-02-20 18:50:17 UTC (rev 25752)
@@ -741,7 +741,7 @@
MidiDriver_Emulated::open();
- _mixer->setupPremix(this);
+ _mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_mixerSoundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, false, true);
return 0;
}
@@ -750,8 +750,7 @@
return;
_isOpen = false;
- // Detach the premix callback handler
- _mixer->setupPremix(0);
+ _mixer->stopHandle(_mixerSoundHandle);
}
void MidiDriver_YM2612::send(uint32 b) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list