[Scummvm-cvs-logs] CVS: scummvm/sound mixer.cpp,1.15,1.16 mixer.h,1.9,1.10

Lionel Ulmer bbrox at users.sourceforge.net
Sat Apr 27 01:34:10 CEST 2002


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

Modified Files:
	mixer.cpp mixer.h 
Log Message:
MP3 CD tracks should now be working properly.

Ludde, maybe you should check if Simon is still working OK as now the
change of the sound playing handle is 'asynchronous' (ie if you call
'stop' on a sound, the handle will NOT be put to NULL right away, but
at the next 'mix' thread call). Maybe we should completely remove this
handle stuff and always use instead the index returned by the
'play_XXX' functions.



Index: mixer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** mixer.cpp	27 Apr 2002 04:33:24 -0000	1.15
--- mixer.cpp	27 Apr 2002 07:42:14 -0000	1.16
***************
*** 65,72 ****
  	return insert(handle, new Channel_MP3(this, sound, size, flags));
  }
! void SoundMixer::play_mp3_cdtrack(PlayingSoundHandle *handle, FILE* file, void *buffer, uint32 buffer_size, mad_timer_t duration) {
! 	if (*handle)
! 		stop(*handle);
! 	insert(handle, new Channel_MP3_CDMUSIC(this, file, buffer, buffer_size, duration));
  }
  #endif
--- 65,72 ----
  	return insert(handle, new Channel_MP3(this, sound, size, flags));
  }
! int SoundMixer::play_mp3_cdtrack(PlayingSoundHandle *handle, int index, FILE* file, mad_timer_t duration) {
! 	/* Stop the previously playing CD track (if any) */
! 	stop(index);
! 	return insert(handle, new Channel_MP3_CDMUSIC(this, file, duration));
  }
  #endif
***************
*** 114,117 ****
--- 114,121 ----
  }
  
+ void SoundMixer::stop(int index) {
+ 	if (_channels[index])
+ 		_channels[index]->destroy();
+ }
  
  bool SoundMixer::has_active_channel() {
***************
*** 328,340 ****
  
  /* MP3 CD music */
  
! SoundMixer::Channel_MP3_CDMUSIC::Channel_MP3_CDMUSIC(SoundMixer *mixer, FILE* file, void *buffer, uint32 buffer_size, mad_timer_t duration) {
  	_mixer = mixer;
  	_file = file;
  	_duration = duration;
  	_initialized = false;
! 	_buffer_size = buffer_size;
! 	_ptr = buffer;
! 	_flags = 0;
  	_to_be_destroyed = false;
  
--- 332,344 ----
  
  /* MP3 CD music */
+ #define MP3CD_BUFFERING_SIZE 131072
  
! SoundMixer::Channel_MP3_CDMUSIC::Channel_MP3_CDMUSIC(SoundMixer *mixer, FILE* file, mad_timer_t duration) {
  	_mixer = mixer;
  	_file = file;
  	_duration = duration;
  	_initialized = false;
! 	_buffer_size = MP3CD_BUFFERING_SIZE;
! 	_ptr = malloc(MP3CD_BUFFERING_SIZE);
  	_to_be_destroyed = false;
  
***************
*** 346,351 ****
  	mad_frame_init(&_frame);
  	mad_synth_init(&_synth);
- 
- 	//debug(1, "CRE %d", getpid());
  }
  
--- 350,353 ----
***************
*** 359,364 ****
  	}
  
- 	//debug(1, "MIX %d", getpid());
- 
  	if (!_initialized) {
  		int skip_loop;
--- 361,364 ----
***************
*** 452,463 ****
  
  void SoundMixer::Channel_MP3_CDMUSIC::real_destroy() {
! 	if (_flags & FLAG_AUTOFREE)
! 		free(_ptr);
  	_mixer->uninsert(this);
  	mad_synth_finish(&_synth);
  	mad_frame_finish(&_frame);
  	mad_stream_finish(&_stream);
- 
- 	//debug(1, "DES %d", getpid());
  
  	delete this;
--- 452,460 ----
  
  void SoundMixer::Channel_MP3_CDMUSIC::real_destroy() {
! 	free(_ptr);
  	_mixer->uninsert(this);
  	mad_synth_finish(&_synth);
  	mad_frame_finish(&_frame);
  	mad_stream_finish(&_stream);
  
  	delete this;

Index: mixer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** mixer.h	26 Apr 2002 20:53:48 -0000	1.9
--- mixer.h	27 Apr 2002 07:42:14 -0000	1.10
***************
*** 79,98 ****
  		SoundMixer *_mixer;
  		void *_ptr;
!         struct mad_stream _stream;
!         struct mad_frame _frame;
!         struct mad_synth _synth;
!         uint32 _pos_in_frame;
!         uint32 _size;
!         uint32 _buffer_size;
!         mad_timer_t _duration;
!         FILE   *_file;
  		bool _initialized;
- 		byte _flags;
  	public:
  		void mix(int16 *data, uint len);
! 		Channel_MP3_CDMUSIC(SoundMixer *mixer, FILE* file, void *buffer, uint32 buffer_size, mad_timer_t duration);
  		void real_destroy();		
- 
- 
  	};
  
--- 79,95 ----
  		SoundMixer *_mixer;
  		void *_ptr;
! 		struct mad_stream _stream;
! 		struct mad_frame _frame;
! 		struct mad_synth _synth;
! 		uint32 _pos_in_frame;
! 		uint32 _size;
! 		uint32 _buffer_size;
! 		mad_timer_t _duration;
! 		FILE   *_file;
  		bool _initialized;
  	public:
  		void mix(int16 *data, uint len);
! 		Channel_MP3_CDMUSIC(SoundMixer *mixer, FILE* file, mad_timer_t duration);
  		void real_destroy();		
  	};
  
***************
*** 130,134 ****
  #ifdef COMPRESSED_SOUND_FILE
  	int play_mp3(PlayingSoundHandle *handle, void *sound, uint32 size, byte flags);
! 	void play_mp3_cdtrack(PlayingSoundHandle *handle, FILE* file, void *buffer, uint32 buffer_size, mad_timer_t duration);
  #endif
  
--- 127,131 ----
  #ifdef COMPRESSED_SOUND_FILE
  	int play_mp3(PlayingSoundHandle *handle, void *sound, uint32 size, byte flags);
! 	int play_mp3_cdtrack(PlayingSoundHandle *handle, int index, FILE* file, mad_timer_t duration);
  #endif
  
***************
*** 144,147 ****
--- 141,145 ----
  	/* stop playing a specific sound */
  	void stop(PlayingSoundHandle psh);
+ 	void stop(int index);
  
  	/* is any channel active? */





More information about the Scummvm-git-logs mailing list