[Scummvm-cvs-logs] CVS: scummvm sdl.cpp,1.17,1.18 windows.cpp,1.14,1.15

Ludvig Strigeus strigeus at users.sourceforge.net
Fri Nov 9 11:09:02 CET 2001


Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv8584

Modified Files:
	sdl.cpp windows.cpp 
Log Message:
warning message if no sfx channel available

Index: sdl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sdl.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** sdl.cpp	2001/11/09 18:54:15	1.17
--- sdl.cpp	2001/11/09 19:08:47	1.18
***************
*** 500,504 ****
  			return mc;
  	}
! 	return mc;
  }
  
--- 500,504 ----
  			return mc;
  	}
! 	return NULL;
  }
  
***************
*** 514,517 ****
--- 514,522 ----
  void playSfxSound(void *sound, uint32 size, uint rate) {
  	MixerChannel *mc = find_channel();
+ 
+ 	if (!mc) {
+ 		warning("No mixer channel available");
+ 		return;
+ 	}
  
  	mc->_sfx_sound = sound;

Index: windows.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/windows.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** windows.cpp	2001/11/09 18:54:15	1.14
--- windows.cpp	2001/11/09 19:08:47	1.15
***************
*** 819,851 ****
  #define BITS_PER_SAMPLE 16
  
! static void *_sfx_sound;
! static uint32 _sfx_pos;
! static uint32 _sfx_size;
  
! static uint32 _sfx_fp_speed;
! static uint32 _sfx_fp_pos;
  
  bool isSfxFinished() {
! 	return _sfx_size == 0;
  }
  
  void playSfxSound(void *sound, uint32 size, uint rate) {
! 	if (_sfx_sound) {
! 		free(_sfx_sound);
  	}
! 	_sfx_sound = sound;
! 	_sfx_pos = 0;
! 	_sfx_fp_speed = (1<<16) * rate / 22050;
! 	_sfx_fp_pos = 0;
  	while (size&0xFFFF0000) size>>=1, rate>>=1;
! 	_sfx_size = size * 22050 / rate;
  }
  
! void mix_sound(int16 *data, uint32 len) {
  	int8 *s;
  	int i;
  	uint32 fp_pos, fp_speed;
  
! 	if (!_sfx_size)
  		return;
  	if (len > _sfx_size)
--- 819,879 ----
  #define BITS_PER_SAMPLE 16
  
! struct MixerChannel {
! 	void *_sfx_sound;
! 	uint32 _sfx_pos;
! 	uint32 _sfx_size;
! 	uint32 _sfx_fp_speed;
! 	uint32 _sfx_fp_pos;
  
! 	void mix(int16 *data, uint32 len);
! 	void clear();
! };
  
+ #define NUM_MIXER 4
+ 
+ static MixerChannel mixer_channel[NUM_MIXER];
+ 
+ MixerChannel *find_channel() {
+ 	int i;
+ 	MixerChannel *mc = mixer_channel;
+ 	for(i=0; i<NUM_MIXER; i++,mc++) {
+ 		if (!mc->_sfx_sound)
+ 			return mc;
+ 	}
+ 	return NULL;
+ }
+ 
+ 
  bool isSfxFinished() {
! 	int i;
! 	for(i=0; i<NUM_MIXER; i++)
! 		if (mixer_channel[i]._sfx_sound)
! 			return false;
! 	return true;
  }
  
  void playSfxSound(void *sound, uint32 size, uint rate) {
! 	MixerChannel *mc = find_channel();
! 
! 	if (!mc) {
! 		warning("No mixer channel available");
! 		return;
  	}
! 
! 	mc->_sfx_sound = sound;
! 	mc->_sfx_pos = 0;
! 	mc->_sfx_fp_speed = (1<<16) * rate / 22050;
! 	mc->_sfx_fp_pos = 0;
! 
  	while (size&0xFFFF0000) size>>=1, rate>>=1;
! 	mc->_sfx_size = size * 22050 / rate;
  }
  
! void MixerChannel::mix(int16 *data, uint32 len) {
  	int8 *s;
  	int i;
  	uint32 fp_pos, fp_speed;
  
! 	if (!_sfx_sound)
  		return;
  	if (len > _sfx_size)
***************
*** 867,870 ****
--- 895,906 ----
  	_sfx_fp_speed = fp_speed;
  	_sfx_fp_pos = fp_pos;
+ 
+ 	if (!_sfx_size)
+ 		clear();
+ }
+ 
+ void MixerChannel::clear() {
+ 	free(_sfx_sound);
+ 	_sfx_sound = NULL;
  }
  
***************
*** 899,902 ****
--- 935,939 ----
  
  void fill_buffer(int16 *buf, int len) {
+ 	int i;
  #if defined(USE_IMUSE)
  	sound.generate_samples(buf,len);
***************
*** 904,908 ****
  	memset(buf, 0, len*2);
  #endif
! 	mix_sound(buf,len);
  }
  
--- 941,948 ----
  	memset(buf, 0, len*2);
  #endif
! 	for(i=NUM_MIXER-1; i>=0;i--) {
! 		mixer_channel[i].mix((int16*)buf, len);
! 	}
! 
  }
  
***************
*** 984,987 ****
--- 1024,1028 ----
  		} else {
  			tmp = delta = scumm.scummLoop(delta);
+ 
  			tmp += tmp>>1;
  			





More information about the Scummvm-git-logs mailing list