[Scummvm-cvs-logs] CVS: scummvm/sound mixer.cpp,1.119,1.120 mixer.h,1.48,1.49

Max Horn fingolfin at users.sourceforge.net
Fri Sep 5 13:50:08 CEST 2003


Update of /cvsroot/scummvm/scummvm/sound
In directory sc8-pr-cvs1:/tmp/cvs-serv31019/sound

Modified Files:
	mixer.cpp mixer.h 
Log Message:
cleaned up sound/mixer.h a bit; renamed some mixer methods for consistency

Index: mixer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.cpp,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -d -r1.119 -r1.120
--- mixer.cpp	5 Sep 2003 06:22:10 -0000	1.119
+++ mixer.cpp	5 Sep 2003 20:48:31 -0000	1.120
@@ -68,6 +68,8 @@
 		_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 @@
 	_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 @@
 	((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 @@
 		_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;
 }
 
@@ -439,12 +450,6 @@
 		if (_channels[i] && !_channels[i]->isMusicChannel())
 			return true;
 	return false;
-}
-
-void SoundMixer::setupPremix(void *param, PremixProc *proc) {
-	StackLock lock(_mutex);
-	_premixParam = param;
-	_premixProc = proc;
 }
 
 void SoundMixer::setVolume(int volume) {

Index: mixer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.h,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- mixer.h	5 Sep 2003 06:22:10 -0000	1.48
+++ mixer.h	5 Sep 2003 20:48:32 -0000	1.49
@@ -52,7 +52,6 @@
 	};
 
 	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 @@
 	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 @@
 	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 @@
 	/** 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 @@
 	/** 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 @@
 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);





More information about the Scummvm-git-logs mailing list