[Scummvm-cvs-logs] CVS: scummvm/sound mixer.cpp,1.21,1.22 mixer.h,1.11,1.12

Travis Howell kirben at users.sourceforge.net
Sun Oct 27 03:42:02 CET 2002


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

Modified Files:
	mixer.cpp mixer.h 
Log Message:

Add monster.sog support, patch #629362 
Enable ogg support by default in mingw builds and link in ogg lib


Index: mixer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- mixer.cpp	27 Oct 2002 01:12:10 -0000	1.21
+++ mixer.cpp	27 Oct 2002 11:41:07 -0000	1.22
@@ -145,10 +145,10 @@
 #endif
 
 #ifdef USE_VORBIS
-int SoundMixer::playVorbisCDTrack(PlayingSoundHandle * handle, OggVorbis_File * ov_file, double duration) {
+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));
+			return insertAt(handle, i, new ChannelVorbis(this, ov_file, duration, is_cd_track));
 		}
 	}
 
@@ -977,16 +977,17 @@
 #endif
 
 #ifdef USE_VORBIS
-SoundMixer::ChannelVorbis::ChannelVorbis(SoundMixer * mixer, OggVorbis_File * ov_file, double duration) {
+SoundMixer::ChannelVorbis::ChannelVorbis(SoundMixer * mixer, OggVorbis_File * ov_file, int duration, bool is_cd_track) {
 	_mixer = mixer;
 	_ov_file = ov_file;
 
 	if (duration)
-		_end_pos = ov_time_tell(ov_file) + duration;
+		_end_pos = ov_pcm_tell(ov_file) + duration;
 	else
 		_end_pos = 0;
 
 	_eof_flag = false;
+	_is_cd_track = is_cd_track;
 	_toBeDestroyed = false;
 }
 
@@ -1005,7 +1006,8 @@
 	uint len_left = len * channels * 2;
 	int16 *samples = new int16[len_left / 2];
 	char *read_pos = (char *) samples;
-	int volume = _mixer->_musicVolume;
+	int volume = _is_cd_track ? _mixer->_musicVolume :
+		_mixer->_volumeTable[1];
 
 	// Read the samples
 	while (len_left > 0) {
@@ -1021,6 +1023,10 @@
 			memset(read_pos, 0, len_left);
 			break;
 		}
+		else if (result == OV_HOLE) {
+			// Possibly recoverable, just warn about it
+			warning("Corrupted data in Vorbis file");
+		}
 		else if (result < 0) {
 			debug(1, "Decode error %d in Vorbis file", result);
 			// Don't delete it yet, that causes problems in
@@ -1045,6 +1051,9 @@
 	}
 
 	delete [] samples;
+
+	if (_eof_flag && ! _is_cd_track)
+		realDestroy();
 }
 
 void SoundMixer::ChannelVorbis::realDestroy() {
@@ -1054,7 +1063,7 @@
 
 bool SoundMixer::ChannelVorbis::soundFinished() {
 	return _eof_flag || (_end_pos > 0 &&
-			     ov_time_tell(_ov_file) >= _end_pos);
+			     ov_pcm_tell(_ov_file) >= _end_pos);
 }
 
 #endif

Index: mixer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- mixer.h	27 Oct 2002 01:12:10 -0000	1.11
+++ mixer.h	27 Oct 2002 11:41:08 -0000	1.12
@@ -146,11 +146,11 @@
 	class ChannelVorbis : public Channel {
 		SoundMixer * _mixer;
 		OggVorbis_File * _ov_file;
-		double _end_pos;
-		bool _eof_flag;
+		int _end_pos;
+		bool _eof_flag, _is_cd_track;
 
 	public:
-		ChannelVorbis(SoundMixer * mixer, OggVorbis_File * ov_file, double duration);
+		ChannelVorbis(SoundMixer * mixer, OggVorbis_File * ov_file, int duration, bool is_cd_track);
 
 		void mix(int16 * data, uint len);
 		void realDestroy();
@@ -212,7 +212,7 @@
 	int playMP3CDTrack(PlayingSoundHandle * handle, File * file, mad_timer_t duration);
 #endif
 #ifdef USE_VORBIS
-	int playVorbisCDTrack(PlayingSoundHandle * handle, OggVorbis_File * ov_file, double duration);
+	int playVorbis(PlayingSoundHandle * handle, OggVorbis_File * ov_file, int duration, bool is_cd_track);
 #endif
 
 	/* Premix procedure, useful when using fmopl adlib */





More information about the Scummvm-git-logs mailing list