[Scummvm-cvs-logs] CVS: scummvm/sound fmopl.cpp,1.7,1.8 fmopl.h,1.2,1.3 mididrv.cpp,1.40,1.41 mididrv.h,1.15,1.16 midistreamer.cpp,1.6,1.7 midistreamer.h,1.5,1.6 mixer.cpp,1.30,1.31 mixer.h,1.15,1.16 mpu401.cpp,1.3,1.4 mpu401.h,1.4,1.5

Pawel Kolodziejski aquadran at users.sourceforge.net
Thu Mar 6 10:31:31 CET 2003


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

Modified Files:
	fmopl.cpp fmopl.h mididrv.cpp mididrv.h midistreamer.cpp 
	midistreamer.h mixer.cpp mixer.h mpu401.cpp mpu401.h 
Log Message:
and more cleanup ....

Index: fmopl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/fmopl.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- fmopl.cpp	13 Feb 2003 23:59:41 -0000	1.7
+++ fmopl.cpp	6 Mar 2003 18:30:38 -0000	1.8
@@ -154,11 +154,11 @@
 
 static int SL_TABLE[16];
 
-static const uint SL_TABLE_SEED[16]={
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 31
+static const uint SL_TABLE_SEED[16] = {
+	0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 31
 };
 
-#define TL_MAX (EG_ENT*2) /* limit(tl + ksr + envelope) + sinwave */
+#define TL_MAX (EG_ENT * 2) /* limit(tl + ksr + envelope) + sinwave */
[...1259 lines suppressed...]
-		if( OPL->mode & 0x80 )
-		{	/* CSM mode total level latch and auto key on */
+		if(OPL->mode & 0x80) {	/* CSM mode total level latch and auto key on */
 			int ch;
-			if(OPL->UpdateHandler) OPL->UpdateHandler(OPL->UpdateParam,0);
-			for(ch=0;ch<9;ch++)
-				CSMKeyControll( &OPL->P_CH[ch] );
+			if(OPL->UpdateHandler)
+				OPL->UpdateHandler(OPL->UpdateParam,0);
+			for(ch = 0; ch < 9; ch++)
+				CSMKeyControll(&OPL->P_CH[ch]);
 		}
 	}
 	/* reload timer */
-	if (OPL->TimerHandler) (OPL->TimerHandler)(OPL->TimerParam+c,(double)OPL->T[c]*OPL->TimerBase);
-	return OPL->status>>7;
+	if (OPL->TimerHandler)
+		(OPL->TimerHandler)(OPL->TimerParam + c, (double)OPL->T[c] * OPL->TimerBase);
+	return OPL->status >> 7;
 }

Index: fmopl.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/fmopl.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- fmopl.h	29 Jan 2003 21:28:37 -0000	1.2
+++ fmopl.h	6 Mar 2003 18:30:39 -0000	1.3
@@ -76,10 +76,10 @@
 	int op1_out[2];		/* slot1 output for selfeedback		*/
 
 	/* phase generator state */
-	uint  block_fnum;	/* block+fnum						*/
+	uint block_fnum;	/* block+fnum						*/
 	uint8 kcode;		/* key code        : KeyScaleCode	*/
-	uint  fc;			/* Freq. Increment base				*/
-	uint  ksl_base;		/* KeyScaleLevel Base step			*/
+	uint fc;			/* Freq. Increment base				*/
+	uint ksl_base;		/* KeyScaleLevel Base step			*/
 	uint8 keyon;		/* key on/off flag					*/
 } OPL_CH;
 
@@ -139,14 +139,14 @@
 
 FM_OPL *OPLCreate(int type, int clock, int rate);
 void OPLDestroy(FM_OPL *OPL);
-void OPLSetTimerHandler(FM_OPL *OPL,OPL_TIMERHANDLER TimerHandler,int channelOffset);
-void OPLSetIRQHandler(FM_OPL *OPL,OPL_IRQHANDLER IRQHandler,int param);
-void OPLSetUpdateHandler(FM_OPL *OPL,OPL_UPDATEHANDLER UpdateHandler,int param);
+void OPLSetTimerHandler(FM_OPL *OPL, OPL_TIMERHANDLER TimerHandler, int channelOffset);
+void OPLSetIRQHandler(FM_OPL *OPL, OPL_IRQHANDLER IRQHandler, int param);
+void OPLSetUpdateHandler(FM_OPL *OPL, OPL_UPDATEHANDLER UpdateHandler, int param);
 
 void OPLResetChip(FM_OPL *OPL);
-int OPLWrite(FM_OPL *OPL,int a,int v);
-unsigned char OPLRead(FM_OPL *OPL,int a);
-int OPLTimerOver(FM_OPL *OPL,int c);
+int OPLWrite(FM_OPL *OPL, int a, int v);
+unsigned char OPLRead(FM_OPL *OPL, int a);
+int OPLTimerOver(FM_OPL *OPL, int c);
 void OPLWriteReg(FM_OPL *OPL, int r, int v);
 void YM3812UpdateOne(FM_OPL *OPL, int16 *buffer, int length);
 #endif

Index: mididrv.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mididrv.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- mididrv.cpp	25 Dec 2002 12:01:37 -0000	1.40
+++ mididrv.cpp	6 Mar 2003 18:30:39 -0000	1.41
@@ -31,18 +31,13 @@
 #include "common/engine.h"	// for warning/error/debug
 #include "common/util.h"	// for ARRAYSIZE
 
-
-
 /* Default (empty) property method */
-uint32 MidiDriver::property(int prop, uint32 param)
-{
+uint32 MidiDriver::property(int prop, uint32 param) {
 	return 0;
 }
 
-
 /* retrieve a string representation of an error code */
-const char *MidiDriver::getErrorName(int error_code)
-{
+const char *MidiDriver::getErrorName(int error_code) {
 	static const char *const midi_errors[] = {
 		"No error",
 		"Cannot connect",
@@ -66,22 +61,20 @@
 	int open();
 	void close();
 	void send(uint32 b);
-	void sysEx (byte *msg, uint16 length);
+	void sysEx(byte *msg, uint16 length);
 
 private:
 	bool _isOpen;
 	int device, _device_num;
 };
 
-MidiDriver_SEQ::MidiDriver_SEQ()
-{
+MidiDriver_SEQ::MidiDriver_SEQ() {
 	_isOpen = false;
 	device = 0;
 	_device_num = 0;
 }
 
-int MidiDriver_SEQ::open()
-{
+int MidiDriver_SEQ::open() {
 	if (_isOpen)
 		return MERR_ALREADY_OPEN;
 	_isOpen = true;
@@ -109,15 +102,12 @@
 	return 0;
 }
 
-void MidiDriver_SEQ::close()
-{
+void MidiDriver_SEQ::close() {
 	::close(device);
 	_isOpen = false;
 }
 
-
-void MidiDriver_SEQ::send(uint32 b)
-{
+void MidiDriver_SEQ::send(uint32 b) {
 	unsigned char buf[256];
 	int position = 0;
 
@@ -158,8 +148,7 @@
 	write(device, buf, position);
 }
 
-void MidiDriver_SEQ::sysEx (byte *msg, uint16 length)
-{
+void MidiDriver_SEQ::sysEx (byte *msg, uint16 length) {
 	if (length > 254) {
 		warning ("Cannot send SysEx block - data too large");
 		return;
@@ -188,8 +177,7 @@
 	write (device, buf, position);
 }
 
-MidiDriver *MidiDriver_SEQ_create()
-{
+MidiDriver *MidiDriver_SEQ_create() {
 	return new MidiDriver_SEQ();
 }
 

Index: mididrv.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mididrv.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- mididrv.h	25 Dec 2002 00:36:04 -0000	1.15
+++ mididrv.h	6 Mar 2003 18:30:40 -0000	1.16
@@ -45,7 +45,6 @@
 		PROP_SMALLHEADER = 2
 	};
 
-
 	// Open the midi driver.
 	// Returns 0 if successful, otherwise an error code.
 	virtual int open() = 0;
@@ -83,8 +82,6 @@
 	virtual MidiChannel *getPercussionChannel() = 0;
 };
 
-
-
 class MidiChannel {
 public:
 	virtual MidiDriver *device() = 0;
@@ -114,8 +111,6 @@
 	virtual void sysEx_customInstrument (uint32 type, byte *instr) = 0;
 };
 
-
-
 // MIDI Driver Types
 enum {
 	MD_AUTO = 0,
@@ -130,7 +125,6 @@
 	MD_ALSA = 9,
 	MD_ADLIB = 10
 };
-
 
 // Factory functions, for faster compile
 extern MidiDriver *MidiDriver_NULL_create();

Index: midistreamer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/midistreamer.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- midistreamer.cpp	21 Dec 2002 21:32:45 -0000	1.6
+++ midistreamer.cpp	6 Mar 2003 18:30:40 -0000	1.7
@@ -24,20 +24,19 @@
 #include "common/util.h"
 
 MidiStreamer::MidiStreamer (MidiDriver *target) :
-_target (target),
-_stream_proc (0),
-_stream_param (0),
-_isOpen (false),
-_paused (false),
-_event_count (0),
-_event_index (0),
-_tempo (500000), // 120 BPM = 500,000 microseconds between each beat
-_ticks_per_beat (96),
-_delay (0)
+	_target (target),
+	_stream_proc (0),
+	_stream_param (0),
+	_isOpen (false),
+	_paused (false),
+	_event_count (0),
+	_event_index (0),
+	_tempo (500000), // 120 BPM = 500,000 microseconds between each beat
+	_ticks_per_beat (96),
+	_delay (0)
 { }
 
-void MidiStreamer::set_stream_callback (void *param, StreamCallback *sc)
-{
+void MidiStreamer::set_stream_callback (void *param, StreamCallback *sc) {
 	_stream_param = param;
 	_stream_proc = sc;
 
@@ -51,8 +50,7 @@
 	((MidiStreamer *) param)->on_timer();
 }
 
-void MidiStreamer::on_timer()
-{
+void MidiStreamer::on_timer() {
 	if (_paused || !_stream_proc)
 		return;
 
@@ -80,8 +78,7 @@
 	} // end while
 }
 
-int MidiStreamer::open()
-{
+int MidiStreamer::open() {
 	if (_isOpen)
 		close();
 
@@ -99,8 +96,7 @@
 	return 0;
 }
 
-void MidiStreamer::close()
-{
+void MidiStreamer::close() {
 	if (!_isOpen)
 		return;
 
@@ -116,8 +112,7 @@
 	_paused = true;
 }
 
-uint32 MidiStreamer::property (int prop, uint32 param)
-{
+uint32 MidiStreamer::property (int prop, uint32 param) {
 	switch (prop) {
 
 	// 16-bit time division according to standard midi specification

Index: midistreamer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/midistreamer.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- midistreamer.h	25 Dec 2002 00:48:13 -0000	1.5
+++ midistreamer.h	6 Mar 2003 18:30:41 -0000	1.6
@@ -35,7 +35,7 @@
 public:
 	// Called whenever more MIDI commands need to be generated.
 	// Return 0 to tell MidiStreamer that end of stream was reached.
-	typedef int StreamCallback (void *param, MidiEvent * ev, int num);
+	typedef int StreamCallback (void *param, MidiEvent *ev, int num);
 
 	// Special events that can be inserted in a MidiEvent.
 	// event = (ME_xxx<<24) | <24-bit data associated with event>
@@ -51,7 +51,7 @@
 	bool _isOpen;
 	bool _paused;
 
-	MidiEvent _events [64];
+	MidiEvent _events[64];
 	int _event_count;
 	int _event_index;
 

Index: mixer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- mixer.cpp	8 Dec 2002 14:18:41 -0000	1.30
+++ mixer.cpp	6 Mar 2003 18:30:43 -0000	1.31
@@ -37,7 +37,7 @@
 	free(_volumeTable);
 }
 
-void SoundMixer::unInsert(Channel * chan) {
+void SoundMixer::unInsert(Channel *chan) {
 	for (int i = 0; i != NUM_CHANNELS; i++) {
 		if (_channels[i] == chan) {
 			if (_handles[i]) {
@@ -51,10 +51,10 @@
 	error("SoundMixer::channel_deleted chan not found");
 }
 
-int SoundMixer::append(int index, void * sound, uint32 size, uint rate, byte flags) {
+int SoundMixer::append(int index, void *sound, uint32 size, uint rate, byte flags) {
 	_syst->lock_mutex(_mutex);
 
-	Channel * chan = _channels[index];
+	Channel *chan = _channels[index];
 	if (!chan) {
 		debug(2, "Trying to stream to an unexistant streamer : %d", index);
 		playStream(NULL, index, sound, size, rate, flags);
@@ -69,7 +69,7 @@
 	return 1;
 }
 
-int SoundMixer::insertAt(PlayingSoundHandle * handle, int index, Channel * chan) {
+int SoundMixer::insertAt(PlayingSoundHandle *handle, int index, Channel *chan) {
 	if(index == -1) {
 		for (int i = _beginSlots; i != NUM_CHANNELS; i++)
 			if (_channels[i] == NULL) { index = i; break; }
@@ -88,7 +88,7 @@
 	return index;
 }
 
-int SoundMixer::playRaw(PlayingSoundHandle * handle, void * sound, uint32 size, uint rate, byte flags) {
+int SoundMixer::playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags) {
 	for (int i = _beginSlots; i != NUM_CHANNELS; i++) {
 		if (_channels[i] == NULL) {
 			return insertAt(handle, i, new ChannelRaw(this, sound, size, rate, flags, -1));
@@ -99,7 +99,7 @@
 	return -1;
 }
 
-int SoundMixer::playRaw(PlayingSoundHandle * handle, void * sound, uint32 size, uint rate, byte flags, int id) {
+int SoundMixer::playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, int id) {
 	for (int i = _beginSlots; i != NUM_CHANNELS; i++) {
 		if (_channels[i] == NULL) {
 			return insertAt(handle, i, new ChannelRaw(this, sound, size, rate, flags, id));
@@ -110,8 +110,8 @@
 	return -1;
 }
 
-int SoundMixer::playStream(PlayingSoundHandle * handle, int idx, void * sound, uint32 size,
-														uint rate, byte flags, int32 timeout, int32 buffer_size) {
+int SoundMixer::playStream(PlayingSoundHandle *handle, int idx, void *sound, uint32 size,
+													uint rate, byte flags, int32 timeout, int32 buffer_size) {
 	return insertAt(handle, idx, new ChannelStream(this, sound, size, rate, flags, timeout, buffer_size));
 }
 
@@ -124,7 +124,7 @@
 }
 
 #ifdef USE_MAD
-int SoundMixer::playMP3(PlayingSoundHandle * handle, void *sound, uint32 size, byte flags) {
+int SoundMixer::playMP3(PlayingSoundHandle *handle, void *sound, uint32 size, byte flags) {
 	for (int i = _beginSlots; i != NUM_CHANNELS; i++) {
 		if (_channels[i] == NULL) {
 			return insertAt(handle, i, new ChannelMP3(this, sound, size, flags));
@@ -134,7 +134,7 @@
 	warning("SoundMixer::out of mixer slots");
 	return -1;
 }
-int SoundMixer::playMP3CDTrack(PlayingSoundHandle * handle, File * file, mad_timer_t duration) {
+int SoundMixer::playMP3CDTrack(PlayingSoundHandle *handle, File *file, mad_timer_t duration) {
 	/* Stop the previously playing CD track (if any) */
 	for (int i = _beginSlots; i != NUM_CHANNELS; i++) {
 		if (_channels[i] == NULL) {
@@ -148,7 +148,7 @@
 #endif
 
 #ifdef USE_VORBIS
-int SoundMixer::playVorbis(PlayingSoundHandle * handle, OggVorbis_File * ov_file, int duration, bool is_cd_track) {
+int SoundMixer::playVorbis(PlayingSoundHandle *handle, OggVorbis_File *ov_file, int duration, bool is_cd_track) {
 	for (int i = _beginSlots; i != NUM_CHANNELS; i++) {
 		if (_channels[i] == NULL) {
 			return insertAt(handle, i, new ChannelVorbis(this, ov_file, duration, is_cd_track));
@@ -185,15 +185,13 @@
 	_syst->unlock_mutex(_mutex);
 }
 
-void SoundMixer::onGenerateSamples(void * s, byte * samples, int len) {
+void SoundMixer::onGenerateSamples(void *s, byte *samples, int len) {
 	((SoundMixer *)s)->mix((int16 *)samples, len >> 2);
 }
 
-bool SoundMixer::bindToSystem(OSystem * syst) {
+bool SoundMixer::bindToSystem(OSystem *syst) {
 	uint rate = (uint) syst->property(OSystem::PROP_GET_SAMPLE_RATE, 0);
-
 	_outputRate = rate;
-
 	_syst = syst;
 	_mutex = _syst->create_mutex();
 
@@ -230,7 +228,7 @@
 	return false;
 }
 
-void SoundMixer::setupPremix(void * param, PremixProc * proc) {
+void SoundMixer::setupPremix(void *param, PremixProc *proc) {
 	_premixParam = param;
 	_premixProc = proc;
 }
@@ -267,12 +265,12 @@
 	return false;
 }
 
-void SoundMixer::Channel::append(void * sound, uint32 size) {
+void SoundMixer::Channel::append(void *sound, uint32 size) {
 	error("append method should never be called on something else than a _STREAM mixer ");
 }
 
 /* RAW mixer */
-SoundMixer::ChannelRaw::ChannelRaw(SoundMixer * mixer, void * sound, uint32 size, uint rate, byte flags, int id) {
+SoundMixer::ChannelRaw::ChannelRaw(SoundMixer *mixer, void *sound, uint32 size, uint rate, byte flags, int id) {
 	_id = id;
 	_mixer = mixer;
 	_flags = flags;
@@ -300,7 +298,6 @@
 	}
 }
 
-
 /*
  * Class that performs cubic interpolation on integer data.
  * It is expected that the data is equidistant, i.e. all have the same
@@ -312,14 +309,12 @@
 	int a, b, c, d;
 	
 public:
-	CubicInterpolator(int a0, int b0, int c0) : x0(2 * a0 - b0), x1(a0), x2(b0), x3(c0)
-	{
+	CubicInterpolator(int a0, int b0, int c0) : x0(2 * a0 - b0), x1(a0), x2(b0), x3(c0) {
 		// We use a simple linear interpolation for x0
 		updateCoefficients();
 	}
 	
-	inline void feedData()
-	{
+	inline void feedData() {
 		x0 = x1;
 		x1 = x2;
 		x2 = x3;
@@ -327,8 +322,7 @@
 		updateCoefficients();
 	}
 
-	inline void feedData(int xNew)
-	{
+	inline void feedData(int xNew) {
 		x0 = x1;
 		x1 = x2;
 		x2 = x3;
@@ -337,8 +331,7 @@
 	}
 	
 	/* t must be a 16.16 fixed point number between 0 and 1 */
-	inline int interpolate(uint32 fpPos)
-	{
+	inline int interpolate(uint32 fpPos) {
 		int result = 0;
 		int t = fpPos >> 8;
 		result = (a * t + b) >> 8;
@@ -350,8 +343,7 @@
 	}
 		
 protected:
-	inline void updateCoefficients()
-	{
+	inline void updateCoefficients() {
 		a = ((-x0 * 2) + (x1 * 5) - (x2 * 4) + x3);
 		b = ((x0 + x2 - (2 * x1)) * 6) << 8;
 		c = ((-4 * x0) + x1 + (x2 * 4) - x3) << 8;
@@ -370,12 +362,12 @@
 		return val;
 }
 
-static int16 * mix_signed_mono_8(int16 * data, uint * len_ptr, byte ** s_ptr, uint32 * fp_pos_ptr,
-								int fp_speed, const int16 * vol_tab, byte * s_end, bool reverse_stereo) {
+static int16 *mix_signed_mono_8(int16 *data, uint *len_ptr, byte **s_ptr, uint32 *fp_pos_ptr,
+								int fp_speed, const int16 *vol_tab, byte *s_end, bool reverse_stereo) {
 	uint32 fp_pos = *fp_pos_ptr;
 	byte *s = *s_ptr;
 	uint len = *len_ptr;
-	
+
 	int inc = 1, result;
 	CubicInterpolator interp(vol_tab[*s], vol_tab[*(s + 1)], vol_tab[*(s + 2)]);
 
@@ -409,12 +401,12 @@
 	return data;
 }
 
-static int16 * mix_unsigned_mono_8(int16 * data, uint * len_ptr, byte ** s_ptr, uint32 * fp_pos_ptr,
-											int fp_speed, const int16 * vol_tab, byte * s_end, bool reverse_stereo) {
+static int16 *mix_unsigned_mono_8(int16 *data, uint *len_ptr, byte **s_ptr, uint32 *fp_pos_ptr,
+											int fp_speed, const int16 *vol_tab, byte *s_end, bool reverse_stereo) {
 	uint32 fp_pos = *fp_pos_ptr;
 	byte *s = *s_ptr;
 	uint len = *len_ptr;
-	
+
 	int inc = 1, result;
 	CubicInterpolator interp(vol_tab[*s ^ 0x80], vol_tab[*(s + 1) ^ 0x80], vol_tab[*(s + 2) ^ 0x80]);
 
@@ -448,18 +440,18 @@
 	return data;
 }
 
-static int16 * mix_signed_stereo_8(int16 * data, uint * len_ptr, byte ** s_ptr, uint32 * fp_pos_ptr,
-										int fp_speed, const int16 * vol_tab, byte *s_end, bool reverse_stereo) {
+static int16 *mix_signed_stereo_8(int16 *data, uint *len_ptr, byte **s_ptr, uint32 *fp_pos_ptr,
+										int fp_speed, const int16 *vol_tab, byte *s_end, bool reverse_stereo) {
 	warning("Mixing stereo signed 8 bit is not supported yet ");
 
 	return data;
 }
-static int16 * mix_unsigned_stereo_8(int16 * data, uint * len_ptr, byte ** s_ptr, uint32 * fp_pos_ptr,
-										int fp_speed, const int16 * vol_tab, byte * s_end, bool reverse_stereo) {
+static int16 *mix_unsigned_stereo_8(int16 *data, uint *len_ptr, byte **s_ptr, uint32 *fp_pos_ptr,
+										int fp_speed, const int16 *vol_tab, byte *s_end, bool reverse_stereo) {
 	uint32 fp_pos = *fp_pos_ptr;
 	byte *s = *s_ptr;
 	uint len = *len_ptr;
-	
+
 	int inc = 1;
 	CubicInterpolator	left(vol_tab[*s ^ 0x80], vol_tab[*(s + 2) ^ 0x80], vol_tab[*(s + 4) ^ 0x80]);
 	CubicInterpolator	right(vol_tab[*(s + 1) ^ 0x80], vol_tab[*(s + 3) ^ 0x80], vol_tab[*(s + 5) ^ 0x80]);
@@ -501,8 +493,8 @@
 
 	return data;
 }
-static int16 * mix_signed_mono_16(int16 * data, uint * len_ptr, byte ** s_ptr, uint32 * fp_pos_ptr,
-										 int fp_speed, const int16 * vol_tab, byte * s_end, bool reverse_stereo) {
+static int16 *mix_signed_mono_16(int16 *data, uint *len_ptr, byte **s_ptr, uint32 *fp_pos_ptr,
+										 int fp_speed, const int16 *vol_tab, byte *s_end, bool reverse_stereo) {
 	uint32 fp_pos = *fp_pos_ptr;
 	unsigned char volume = ((int)vol_tab[1]) / 8;
 	byte *s = *s_ptr;
@@ -526,14 +518,14 @@
 
 	return data;
 }
-static int16 *mix_unsigned_mono_16(int16 *data, uint * len_ptr, byte ** s_ptr, uint32 * fp_pos_ptr,
-										 int fp_speed, const int16 * vol_tab, byte * s_end, bool reverse_stereo) {
+static int16 *mix_unsigned_mono_16(int16 *data, uint *len_ptr, byte **s_ptr, uint32 *fp_pos_ptr,
+										 int fp_speed, const int16 *vol_tab, byte *s_end, bool reverse_stereo) {
 	warning("Mixing mono unsigned 16 bit is not supported yet ");
 
 	return data;
 }
-static int16 *mix_signed_stereo_16(int16 * data, uint * len_ptr, byte ** s_ptr, uint32 * fp_pos_ptr,
-										 int fp_speed, const int16 * vol_tab, byte * s_end, bool reverse_stereo) {
+static int16 *mix_signed_stereo_16(int16 *data, uint *len_ptr, byte **s_ptr, uint32 *fp_pos_ptr,
+										 int fp_speed, const int16 *vol_tab, byte *s_end, bool reverse_stereo) {
 	uint32 fp_pos = *fp_pos_ptr;
 	unsigned char volume = ((int)vol_tab[1]) / 8;
 	byte *s = *s_ptr;
@@ -562,16 +554,16 @@
 
 	return data;
 }
-static int16 * mix_unsigned_stereo_16(int16 * data, uint * len_ptr, byte ** s_ptr, uint32 * fp_pos_ptr,
-											 int fp_speed, const int16 * vol_tab, byte * s_end, bool reverse_stereo) {
+static int16 *mix_unsigned_stereo_16(int16 *data, uint *len_ptr, byte **s_ptr, uint32 *fp_pos_ptr,
+											 int fp_speed, const int16 *vol_tab, byte *s_end, bool reverse_stereo) {
 	warning("Mixing stereo unsigned 16 bit is not supported yet ");
 
 	return data;
 }
 
-static int16 * (*mixer_helper_table[8]) (int16 * data, uint * len_ptr, byte ** s_ptr,
-										 uint32 * fp_pos_ptr, int fp_speed, const int16 * vol_tab,
-										 byte * s_end, bool reverse_stereo) = { 
+static int16 *(*mixer_helper_table[8]) (int16 *data, uint *len_ptr, byte **s_ptr,
+										 uint32 *fp_pos_ptr, int fp_speed, const int16 *vol_tab,
+										 byte *s_end, bool reverse_stereo) = { 
 	mix_signed_mono_8, mix_unsigned_mono_8, 
 	mix_signed_stereo_8, mix_unsigned_stereo_8,
 	mix_signed_mono_16, mix_unsigned_mono_16, 
@@ -585,7 +577,7 @@
 	4, 4
 };
 
-void SoundMixer::ChannelRaw::mix(int16 * data, uint len) {
+void SoundMixer::ChannelRaw::mix(int16 *data, uint len) {
 	byte *s, *s_org = NULL;
 	uint32 fp_pos;
 	byte *end;
@@ -657,7 +649,7 @@
 
 #define WARP_WORKAROUND 50000
 
-SoundMixer::ChannelStream::ChannelStream(SoundMixer * mixer, void * sound, uint32 size, uint rate,
+SoundMixer::ChannelStream::ChannelStream(SoundMixer *mixer, void *sound, uint32 size, uint rate,
 										 byte flags, int32 timeout, int32 buffer_size) {
 	_mixer = mixer;
 	_flags = flags;
@@ -681,7 +673,7 @@
 	_rate = rate;
 }
 
-void SoundMixer::ChannelStream::append(void * data, uint32 len) {
+void SoundMixer::ChannelStream::append(void *data, uint32 len) {
 	byte *new_end = _endOfData + len;
 	byte *cur_pos = _pos;					/* This is just to prevent the variable to move during the tests :-) */
 	if (new_end > (_ptr + _bufferSize)) {
@@ -705,11 +697,11 @@
 	_endOfData = new_end;
 }
 
-void SoundMixer::ChannelStream::mix(int16 * data, uint len) {
+void SoundMixer::ChannelStream::mix(int16 *data, uint len) {
 	uint32 fp_pos;
 	const uint32 fp_speed = _fpSpeed;
-	const int16 * vol_tab = _mixer->_volumeTable;
-	byte * end_of_data = _endOfData;
+	const int16 *vol_tab = _mixer->_volumeTable;
+	byte *end_of_data = _endOfData;
 
 	if (_toBeDestroyed) {
 		realDestroy();
@@ -734,7 +726,7 @@
 		int wrap_offset = 0;
 
 		// see if we will wrap
-		if (_pos + (mixer_element_size[_flags & 0x07] * len) > _endOfBuffer) {			
+		if (_pos + (mixer_element_size[_flags & 0x07] * len) > _endOfBuffer) {
 			wrap_offset = _pos + (mixer_element_size[_flags & 0x07] * len) - _endOfBuffer;
 			debug(9, "using wrap workaround for %d bytes", wrap_offset);
 			memcpy(_endOfBuffer, _ptr, wrap_offset);
@@ -766,7 +758,7 @@
 }
 
 #ifdef USE_MAD
-SoundMixer::ChannelMP3::ChannelMP3(SoundMixer * mixer, void * sound, uint size, byte flags) {
+SoundMixer::ChannelMP3::ChannelMP3(SoundMixer *mixer, void *sound, uint size, byte flags) {
 	_mixer = mixer;
 	_flags = flags;
 	_posInFrame = 0xFFFFFFFF;
@@ -812,7 +804,7 @@
 	return sample >> (MAD_F_FRACBITS + 1 - 16);
 }
 
-void SoundMixer::ChannelMP3::mix(int16 * data, uint len) {
+void SoundMixer::ChannelMP3::mix(int16 *data, uint len) {
 	mad_fixed_t const * ch;
 	const int16 * vol_tab = _mixer->_volumeTable;
 	unsigned char volume = ((int)vol_tab[1]) / 8;
@@ -885,7 +877,7 @@
 
 #define MP3CD_BUFFERING_SIZE 131072
 
-SoundMixer::ChannelMP3CDMusic::ChannelMP3CDMusic(SoundMixer * mixer, File * file,
+SoundMixer::ChannelMP3CDMusic::ChannelMP3CDMusic(SoundMixer *mixer, File *file,
 														 mad_timer_t duration){
 	_mixer = mixer;
 	_file = file;
@@ -905,7 +897,7 @@
 	mad_synth_init(&_synth);
 }
 
-void SoundMixer::ChannelMP3CDMusic::mix(int16 * data, uint len) {
+void SoundMixer::ChannelMP3CDMusic::mix(int16 *data, uint len) {
 	mad_fixed_t const *ch;
 	mad_timer_t frame_duration;
 	unsigned char volume = _mixer->_musicVolume / 8;
@@ -1022,7 +1014,7 @@
 #endif
 
 #ifdef USE_VORBIS
-SoundMixer::ChannelVorbis::ChannelVorbis(SoundMixer * mixer, OggVorbis_File * ov_file, int duration, bool is_cd_track) {
+SoundMixer::ChannelVorbis::ChannelVorbis(SoundMixer *mixer, OggVorbis_File *ov_file, int duration, bool is_cd_track) {
 	_mixer = mixer;
 	_ov_file = ov_file;
 
@@ -1036,7 +1028,7 @@
 	_toBeDestroyed = false;
 }
 
-void SoundMixer::ChannelVorbis::mix(int16 * data, uint len) {
+void SoundMixer::ChannelVorbis::mix(int16 *data, uint len) {
 	if (_toBeDestroyed) {
 		realDestroy();
 		return;
@@ -1109,8 +1101,7 @@
 }
 
 bool SoundMixer::ChannelVorbis::soundFinished() {
-	return _eof_flag || (_end_pos > 0 &&
-			     ov_pcm_tell(_ov_file) >= _end_pos);
+	return _eof_flag || (_end_pos > 0 && ov_pcm_tell(_ov_file) >= _end_pos);
 }
 
 #endif

Index: mixer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- mixer.h	25 Dec 2002 00:36:04 -0000	1.15
+++ mixer.h	6 Mar 2003 18:30:43 -0000	1.16
@@ -56,8 +56,8 @@
 	};
 
 	class ChannelRaw : public Channel {
-		SoundMixer * _mixer;
-		void * _ptr;
+		SoundMixer *_mixer;
+		void *_ptr;
 		uint32 _pos;
 		uint32 _size;
 		uint32 _fpSpeed;
@@ -68,18 +68,18 @@
 		uint32 _loop_size;
 
 	public:
-		ChannelRaw(SoundMixer * mixer, void * sound, uint32 size, uint rate, byte flags, int id);
+		ChannelRaw(SoundMixer *mixer, void *sound, uint32 size, uint rate, byte flags, int id);
 
-		void mix(int16 * data, uint len);
+		void mix(int16 *data, uint len);
 		void realDestroy();
 	};
 
 	class ChannelStream : public Channel {
-		SoundMixer * _mixer;
-		byte * _ptr;
-		byte * _endOfData;
-		byte * _endOfBuffer;
-		byte * _pos;
+		SoundMixer *_mixer;
+		byte *_ptr;
+		byte *_endOfData;
+		byte *_endOfBuffer;
+		byte *_pos;
 		uint32 _fpSpeed;
 		uint32 _fpPos;
 		uint32 _bufferSize;
@@ -89,17 +89,17 @@
 		byte _flags;
 
 	public:
-		ChannelStream(SoundMixer * mixer, void * sound, uint32 size, uint rate, byte flags, int32 timout, int32 buffer_size);
+		ChannelStream(SoundMixer *mixer, void *sound, uint32 size, uint rate, byte flags, int32 timout, int32 buffer_size);
 
-		void append(void * sound, uint32 size);
-		void mix(int16 * data, uint len);
+		void append(void *sound, uint32 size);
+		void mix(int16 *data, uint len);
 		void realDestroy();
 	};
 
 #ifdef USE_MAD
 
 	class ChannelMP3 : public Channel {
-		SoundMixer * _mixer;
+		SoundMixer *_mixer;
 		void *_ptr;
 		struct mad_stream _stream;
 		struct mad_frame _frame;
@@ -111,16 +111,16 @@
 		byte _flags;
 
 	public:
-		ChannelMP3(SoundMixer * mixer, void *sound, uint size, byte flags);
+		ChannelMP3(SoundMixer *mixer, void *sound, uint size, byte flags);
 
-		void mix(int16 * data, uint len);
+		void mix(int16 *data, uint len);
 		void realDestroy();
 
 	};
 
 	class ChannelMP3CDMusic:public Channel {
-		SoundMixer * _mixer;
-		void * _ptr;
+		SoundMixer *_mixer;
+		void *_ptr;
 		struct mad_stream _stream;
 		struct mad_frame _frame;
 		struct mad_synth _synth;
@@ -128,14 +128,14 @@
 		uint32 _size;
 		uint32 _bufferSize;
 		mad_timer_t _duration;
-		File * _file;
+		File *_file;
 		bool _initialized;
 
 
 	public:
-		ChannelMP3CDMusic(SoundMixer * mixer, File * file, mad_timer_t duration);
+		ChannelMP3CDMusic(SoundMixer *mixer, File *file, mad_timer_t duration);
 
-		void mix(int16 * data, uint len);
+		void mix(int16 *data, uint len);
 		void realDestroy();
 		bool soundFinished();
 	};
@@ -144,31 +144,31 @@
 
 #ifdef USE_VORBIS
 	class ChannelVorbis : public Channel {
-		SoundMixer * _mixer;
-		OggVorbis_File * _ov_file;
+		SoundMixer *_mixer;
+		OggVorbis_File *_ov_file;
 		int _end_pos;
 		bool _eof_flag, _is_cd_track;
 
 	public:
-		ChannelVorbis(SoundMixer * mixer, OggVorbis_File * ov_file, int duration, bool is_cd_track);
+		ChannelVorbis(SoundMixer *mixer, OggVorbis_File *ov_file, int duration, bool is_cd_track);
 
-		void mix(int16 * data, uint len);
+		void mix(int16 *data, uint len);
 		void realDestroy();
 		bool soundFinished();
 	};
 #endif
 
-	static void onGenerateSamples(void * s, byte * samples, int len);
+	static void onGenerateSamples(void *s, byte *samples, int len);
 
 public:
-	typedef void PremixProc (void * param, int16 * data, uint len);
+	typedef void PremixProc (void *param, int16 *data, uint len);
 
-	OSystem * _syst;
-	void * _mutex;
+	OSystem *_syst;
+	void *_mutex;
 
 	uint _outputRate;
 
-	int16 * _volumeTable;
+	int16 *_volumeTable;
 	int _musicVolume;
 
 	bool _paused;
@@ -177,20 +177,20 @@
 		NUM_CHANNELS = 16
 	};
 
-	void * _premixParam;
-	PremixProc * _premixProc;
+	void *_premixParam;
+	PremixProc *_premixProc;
 
-	Channel * _channels[NUM_CHANNELS];
-	PlayingSoundHandle * _handles[NUM_CHANNELS];
+	Channel *_channels[NUM_CHANNELS];
+	PlayingSoundHandle *_handles[NUM_CHANNELS];
 
 	int _beginSlots;
 
 	SoundMixer();
 	~SoundMixer();
 
-	int insertAt(PlayingSoundHandle * handle, int index, Channel * chan);
-	void append(void * data, uint32 len);
-	void unInsert(Channel * chan);
+	int insertAt(PlayingSoundHandle *handle, int index, Channel *chan);
+	void append(void *data, uint32 len);
+	void unInsert(Channel *chan);
 	void beginSlots(int index);
 
 	// start playing a raw sound
@@ -204,16 +204,16 @@
 		FLAG_REVERSE_STEREO = 32,   // sound should be reverse stereo
 		FLAG_LOOP = 64              // loop the audio
 	};
-	int playRaw(PlayingSoundHandle * handle, void * sound, uint32 size, uint rate, byte flags);
-	int playRaw(PlayingSoundHandle * handle, void * sound, uint32 size, uint rate, byte flags, int id);
-	int playStream(PlayingSoundHandle * handle, int index, void * sound, uint32 size, uint rate,
+	int playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags);
+	int playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, int id);
+	int playStream(PlayingSoundHandle *handle, int index, void *sound, uint32 size, uint rate,
 									byte flags, int32 timeout = 3, int32 buffer_size = 2000000);
 #ifdef USE_MAD
-	int playMP3(PlayingSoundHandle * handle, void * sound, uint32 size, byte flags);
-	int playMP3CDTrack(PlayingSoundHandle * handle, File * file, mad_timer_t duration);
+	int playMP3(PlayingSoundHandle *handle, void *sound, uint32 size, byte flags);
+	int playMP3CDTrack(PlayingSoundHandle *handle, File *file, mad_timer_t duration);
 #endif
 #ifdef USE_VORBIS
-	int playVorbis(PlayingSoundHandle * handle, OggVorbis_File * ov_file, int duration, bool is_cd_track);
+	int playVorbis(PlayingSoundHandle *handle, OggVorbis_File *ov_file, int duration, bool is_cd_track);
 #endif
 
 	/* Premix procedure, useful when using fmopl adlib */

Index: mpu401.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mpu401.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- mpu401.cpp	25 Dec 2002 12:35:56 -0000	1.3
+++ mpu401.cpp	6 Mar 2003 18:30:44 -0000	1.4
@@ -24,40 +24,58 @@
 #include "common/util.h"	// for ARRAYSIZE
 
 
-void MidiChannel_MPU401::init (MidiDriver_MPU401 *owner, byte channel)
-{
+void MidiChannel_MPU401::init(MidiDriver_MPU401 *owner, byte channel) {
 	_owner = owner;
 	_channel = channel;
 	_allocated = false;
 }
 
-MidiDriver *MidiChannel_MPU401::device() { return _owner; }
-void MidiChannel_MPU401::noteOff (byte note) { _owner->send(note << 8 | 0x80 | _channel); }
-void MidiChannel_MPU401::noteOn (byte note, byte velocity) { _owner->send (velocity << 16 | note << 8 | 0x90 | _channel); }
-void MidiChannel_MPU401::programChange (byte program) { _owner->send(program << 8 | 0xC0 | _channel); }
-void MidiChannel_MPU401::pitchBend (int16 bend) { _owner->send((((bend + 0x2000) >> 7) & 0x7F) << 16 | ((bend + 0x2000) & 0x7F) << 8 | 0xE0 | _channel); }
-void MidiChannel_MPU401::controlChange (byte control, byte value) { _owner->send(value << 16 | control << 8 | 0xB0 | _channel); }
-void MidiChannel_MPU401::pitchBendFactor (byte value) { _owner->setPitchBendRange (_channel, value); }
-void MidiChannel_MPU401::sysEx_customInstrument (uint32 type, byte *instr) { _owner->sysEx_customInstrument (_channel, type, instr); }
+MidiDriver *MidiChannel_MPU401::device() {
+	return _owner;
+}
 
+void MidiChannel_MPU401::noteOff (byte note) {
+	_owner->send(note << 8 | 0x80 | _channel);
+}
 
-MidiDriver_MPU401::MidiDriver_MPU401() : MidiDriver()
-{
+void MidiChannel_MPU401::noteOn(byte note, byte velocity) {
+	_owner->send (velocity << 16 | note << 8 | 0x90 | _channel);
+}
+
+void MidiChannel_MPU401::programChange(byte program) {
+	_owner->send(program << 8 | 0xC0 | _channel);
+}
+
+void MidiChannel_MPU401::pitchBend(int16 bend) {
+	_owner->send((((bend + 0x2000) >> 7) & 0x7F) << 16 | ((bend + 0x2000) & 0x7F) << 8 | 0xE0 | _channel);
+}
+
+void MidiChannel_MPU401::controlChange(byte control, byte value) {
+	_owner->send(value << 16 | control << 8 | 0xB0 | _channel);
+}
+
+void MidiChannel_MPU401::pitchBendFactor(byte value) {
+	_owner->setPitchBendRange (_channel, value);
+}
+
+void MidiChannel_MPU401::sysEx_customInstrument(uint32 type, byte *instr) {
+	_owner->sysEx_customInstrument (_channel, type, instr);
+}
+
+MidiDriver_MPU401::MidiDriver_MPU401() : MidiDriver() {
 	uint i;
 	for (i = 0; i < ARRAYSIZE(_midi_channels); ++i) {
 		_midi_channels [i].init (this, i);
 	}
 }
 
-
-
-MidiChannel *MidiDriver_MPU401::allocateChannel()
-{
+MidiChannel *MidiDriver_MPU401::allocateChannel() {
 	MidiChannel_MPU401 *chan;
 	uint i;
-	
+
 	for (i = 0; i < ARRAYSIZE(_midi_channels); ++i) {
-		if (i == 9) continue;
+		if (i == 9)
+			continue;
 		chan = &_midi_channels[i];
 		if (!chan->_allocated) {
 			chan->allocate();
@@ -67,24 +85,21 @@
 	return NULL;
 }
 
-
-void MidiDriver_MPU401::setTimerCallback (void *timer_param, void (*timer_proc) (void *))
-{
+void MidiDriver_MPU401::setTimerCallback (void *timer_param, void (*timer_proc) (void *)) {
 	if (!_timer_proc || !timer_proc) {
 		_timer_proc = (TimerCallback *) timer_proc;
 		_timer_param = timer_param;
 		if (!_started_thread && timer_proc)
-			g_system->create_thread (midi_driver_thread, this);
+			g_system->create_thread(midi_driver_thread, this);
 		_started_thread = true;
 	}
 }
 
 #if !defined(__MORPHOS__)
-int MidiDriver_MPU401::midi_driver_thread(void *param)
-{
+int MidiDriver_MPU401::midi_driver_thread(void *param) {
 	MidiDriver_MPU401 *mid = (MidiDriver_MPU401 *)param;
 	int old_time, cur_time;
-	
+
 	old_time = g_system->get_msecs();
 
 	for (;;) {

Index: mpu401.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mpu401.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- mpu401.h	18 Dec 2002 17:14:05 -0000	1.4
+++ mpu401.h	6 Mar 2003 18:30:44 -0000	1.5
@@ -87,8 +87,8 @@
 public:
 	MidiDriver_MPU401();
 
-	void setTimerCallback (void *timer_param, void (*timer_proc) (void *));
-	uint32 getBaseTempo (void) { return 0x4A0000; }
+	void setTimerCallback(void *timer_param, void (*timer_proc) (void *));
+	uint32 getBaseTempo(void) { return 0x4A0000; }
 
 	MidiChannel *allocateChannel();
 	MidiChannel *getPercussionChannel() { return &_midi_channels [9]; }





More information about the Scummvm-git-logs mailing list