[Scummvm-cvs-logs] CVS: scummvm/scumm imuse_digi.cpp,1.17,1.18 saveload.cpp,1.89,1.90 script_v6.cpp,1.163,1.164 script_v8.cpp,2.180,2.181 scummvm.cpp,2.245,2.246 sound.cpp,1.135,1.136 sound.h,1.30,1.31

Max Horn fingolfin at users.sourceforge.net
Sat Jun 14 17:55:11 CEST 2003


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv21843

Modified Files:
	imuse_digi.cpp saveload.cpp script_v6.cpp script_v8.cpp 
	scummvm.cpp sound.cpp sound.h 
Log Message:
made stuff in class Sound protected where possible; moved readCreativeVocFile to imuse_digi.cpp and turned it into a static function; put the DigitalTrackInfo stuff into sound.cpp (keeping it private); removed #includes from sound.h (this cuts down interdependencies a little)

Index: imuse_digi.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_digi.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- imuse_digi.cpp	14 Jun 2003 18:52:29 -0000	1.17
+++ imuse_digi.cpp	15 Jun 2003 00:54:13 -0000	1.18
@@ -23,6 +23,7 @@
 #include "scumm/scumm.h"
 #include "scumm/imuse_digi.h"
 #include "scumm/sound.h"
+#include "sound/mixer.h"
 
 ////////////////////////////////////////
 //
@@ -31,6 +32,57 @@
 //
 ////////////////////////////////////////
 
+static byte *readCreativeVocFile(byte *ptr, uint32 &size, uint32 &rate, uint32 &loops) {
+	assert(strncmp((char *)ptr, "Creative Voice File\x1A", 20) == 0);
+	int32 offset = READ_LE_UINT16(ptr + 20);
+	int16 version = READ_LE_UINT16(ptr + 22);
+	int16 code = READ_LE_UINT16(ptr + 24);
+	assert(version == 0x010A || version == 0x0114);
+	assert(code == ~version + 0x1234);
+	bool quit = 0;
+	byte *ret_sound = 0; size = 0, loops = 0;
+	while (!quit) {
+		int len = READ_LE_UINT32(ptr + offset);
+		offset += 4;
+		code = len & 0xFF;
+		len >>= 8;
+		switch(code) {
+			case 0: quit = 1; break;
+			case 1: {
+				int time_constant = ptr[offset++];
+				int packing = ptr[offset++];
+				len -= 2;
+				rate = 1000000L / (256L - time_constant);
+				debug(9, "VOC Data Bloc : %d, %d, %d", rate, packing, len);
+				if (packing == 0) {
+					if (size) {
+						ret_sound = (byte *)realloc(ret_sound, size + len);
+					} else {
+						ret_sound = (byte *)malloc(len);
+					}
+					memcpy(ret_sound + size, ptr + offset, len);
+					size += len;
+				} else {
+					warning("VOC file packing %d unsupported", packing);
+				}
+				} break;
+			case 6:	// begin of loop
+				loops = len + 1;
+				break;
+			case 7:	// end of loop
+				break;
+			default:
+				warning("Invalid code in VOC file : %d", code);
+				quit = 1;
+				break;
+		}
+		// FIXME some FT samples (ex. 362) has bad length, 2 bytes too short
+		offset += len;
+	}
+	debug(9, "VOC Data Size : %d", size);
+	return ret_sound;
+}
+
 static void imus_digital_handler(void *engine) {
 	// Avoid race condition
 	if (engine && ((Scumm *)engine)->_imuseDigital)
@@ -808,7 +860,7 @@
 				_channel[l]._channels = 2;
 				_channel[l]._mixerSize = (22050 / 5) * 2;
 				_channel[l]._mixerFlags = SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_STEREO | SoundMixer::FLAG_REVERSE_STEREO | SoundMixer::FLAG_UNSIGNED;
-				byte * t_ptr= _scumm->_sound->readCreativeVocFile(ptr, size, _channel[l]._freq, _channel[l]._numLoops);
+				byte * t_ptr= readCreativeVocFile(ptr, size, _channel[l]._freq, _channel[l]._numLoops);
 
 				if (_channel[l]._freq == 22222) {
 					_channel[l]._freq = 22050;
@@ -1187,7 +1239,6 @@
 
 	return 0;
 }
-
 
 
 #ifdef __PALM_OS__

Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.cpp,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -d -r1.89 -r1.90
--- saveload.cpp	14 Jun 2003 18:52:29 -0000	1.89
+++ saveload.cpp	15 Jun 2003 00:54:13 -0000	1.90
@@ -31,6 +31,7 @@
 #include "sound.h"
 #include "verbs.h"
 #include "common/config-file.h"
+#include "sound/mixer.h"
 
 struct SaveGameHeader {
 	uint32 type;

Index: script_v6.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v6.cpp,v
retrieving revision 1.163
retrieving revision 1.164
diff -u -d -r1.163 -r1.164
--- script_v6.cpp	14 Jun 2003 16:59:20 -0000	1.163
+++ script_v6.cpp	15 Jun 2003 00:54:13 -0000	1.164
@@ -22,17 +22,18 @@
 
 
 #include "stdafx.h"
-#include "scumm.h"
+#include <time.h>
+
 #include "actor.h"
 #include "charset.h"
 #include "imuse.h"
 #include "intern.h"
+#include "scumm.h"
 #include "sound.h"
 #include "verbs.h"
-#include <time.h>
 #include "smush/smush_player.h"
-
 #include "sound/mididrv.h"
+#include "sound/mixer.h"
 
 #include "dialogs.h"		// FIXME: This is just for the FT-INSANE warning. 
 				// Remove when INSANE is implemented

Index: script_v8.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v8.cpp,v
retrieving revision 2.180
retrieving revision 2.181
diff -u -d -r2.180 -r2.181
--- script_v8.cpp	9 Jun 2003 00:46:32 -0000	2.180
+++ script_v8.cpp	15 Jun 2003 00:54:13 -0000	2.181
@@ -26,8 +26,9 @@
 #include "intern.h"
 #include "sound.h"
 #include "verbs.h"
-
 #include "smush/smush_player.h"
+
+#include "sound/mixer.h"
 
 #include <time.h>
 

Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 2.245
retrieving revision 2.246
diff -u -d -r2.245 -r2.246
--- scummvm.cpp	15 Jun 2003 00:33:16 -0000	2.245
+++ scummvm.cpp	15 Jun 2003 00:54:13 -0000	2.246
@@ -903,8 +903,6 @@
 	// FIXME: disabled, why we need this, it's looks completly dummy and slow down startup
 	//	getGraphicsPerformance();
 
-	_sound->_current_cache = 0;
-
 	_lastSaveTime = _system->get_msecs();
 }
 

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.135
retrieving revision 1.136
diff -u -d -r1.135 -r1.136
--- sound.cpp	14 Jun 2003 18:52:29 -0000	1.135
+++ sound.cpp	15 Jun 2003 00:54:13 -0000	1.136
@@ -24,6 +24,7 @@
 #include "scumm.h"
 #include "sound.h"
 #include "sound/mididrv.h"
+#include "sound/mixer.h"
 #include "imuse.h"
 #include "imuse_digi.h"
 #include "player_v2.h"
@@ -34,6 +35,53 @@
 
 #include "sound/midiparser.h"
 
+
+enum {
+	SOUND_HEADER_SIZE = 26,
+	SOUND_HEADER_BIG_SIZE = 26 + 8
+};
+
+
+class DigitalTrackInfo {
+public:
+	virtual bool error() = 0;
+	virtual int play(SoundMixer *mixer, int start, int delay) = 0;
+	virtual ~DigitalTrackInfo() { }
+};
+
+#ifdef USE_MAD
+class MP3TrackInfo : public DigitalTrackInfo {
+private:
+	struct mad_header _mad_header;
+	long _size;
+	File *_file;
+	bool _error_flag;
+
+public:
+	MP3TrackInfo(File *file);
+	~MP3TrackInfo();
+	bool error() { return _error_flag; }
+	int play(SoundMixer *mixer, int start, int delay);
+};
+#endif
+
+#ifdef USE_VORBIS
+class VorbisTrackInfo : public DigitalTrackInfo {
+private:
+	File *_file;
+	OggVorbis_File _ov_file;
+	bool _error_flag;
+
+public:
+	VorbisTrackInfo(File *file);
+	~VorbisTrackInfo();
+	bool error() { return _error_flag; }
+	int play(SoundMixer *mixer, int start, int delay);
+};
+#endif
+
+
+
 Sound::Sound(Scumm *parent) {
 	memset(this,0,sizeof(Sound));	// palmos
 	
@@ -43,6 +91,7 @@
 	_musicBundleBufOutput = NULL;
 	_musicDisk = 0;
 	_talkChannel = -1;
+	_current_cache = 0;
 }
 
 Sound::~Sound() {
@@ -119,57 +168,6 @@
 	_soundQuePos = 0;
 }
 
-byte *Sound::readCreativeVocFile(byte *ptr, uint32 &size, uint32 &rate, uint32 &loops) {
-	assert(strncmp((char *)ptr, "Creative Voice File\x1A", 20) == 0);
-	int32 offset = READ_LE_UINT16(ptr + 20);
-	int16 version = READ_LE_UINT16(ptr + 22);
-	int16 code = READ_LE_UINT16(ptr + 24);
-	assert(version == 0x010A || version == 0x0114);
-	assert(code == ~version + 0x1234);
-	bool quit = 0;
-	byte *ret_sound = 0; size = 0, loops = 0;
-	while (!quit) {
-		int len = READ_LE_UINT32(ptr + offset);
-		offset += 4;
-		code = len & 0xFF;
-		len >>= 8;
-		switch(code) {
-			case 0: quit = 1; break;
-			case 1: {
-				int time_constant = ptr[offset++];
-				int packing = ptr[offset++];
-				len -= 2;
-				rate = 1000000L / (256L - time_constant);
-				debug(9, "VOC Data Bloc : %d, %d, %d", rate, packing, len);
-				if (packing == 0) {
-					if (size) {
-						ret_sound = (byte *)realloc(ret_sound, size + len);
-					} else {
-						ret_sound = (byte *)malloc(len);
-					}
-					memcpy(ret_sound + size, ptr + offset, len);
-					size += len;
-				} else {
-					warning("VOC file packing %d unsupported", packing);
-				}
-				} break;
-			case 6:	// begin of loop
-				loops = len + 1;
-				break;
-			case 7:	// end of loop
-				break;
-			default:
-				warning("Invalid code in VOC file : %d", code);
-				quit = 1;
-				break;
-		}
-		// FIXME some FT samples (ex. 362) has bad length, 2 bytes too short
-		offset += len;
-	}
-	debug(9, "VOC Data Size : %d", size);
-	return ret_sound;
-}
-
 void Sound::playSound(int soundID) {
 	byte *ptr;
 	char *sound;
@@ -1582,7 +1580,7 @@
 }
 
 #ifdef USE_MAD
-Sound::MP3TrackInfo::MP3TrackInfo(File *file) {
+MP3TrackInfo::MP3TrackInfo(File *file) {
 	struct mad_stream stream;
 	struct mad_frame frame;
 	unsigned char buffer[8192];
@@ -1653,7 +1651,7 @@
 	delete file;
 }
 
-int Sound::MP3TrackInfo::play(SoundMixer *mixer, int start, int delay) {
+int MP3TrackInfo::play(SoundMixer *mixer, int start, int delay) {
 	unsigned int offset;
 	mad_timer_t duration;
 
@@ -1674,7 +1672,7 @@
 	return mixer->playMP3CDTrack(NULL, _file, duration);
 }
 
-Sound::MP3TrackInfo::~MP3TrackInfo() {
+MP3TrackInfo::~MP3TrackInfo() {
 	if (! _error_flag)
 		_file->close();
 }
@@ -1744,7 +1742,7 @@
 	read_wrap, seek_wrap, close_wrap, tell_wrap
 };
 
-Sound::VorbisTrackInfo::VorbisTrackInfo(File *file) {
+VorbisTrackInfo::VorbisTrackInfo(File *file) {
 	file_info *f = new file_info;
 
 	f->file = file;
@@ -1772,7 +1770,7 @@
 #define VORBIS_TREMOR
 #endif
 
-int Sound::VorbisTrackInfo::play(SoundMixer *mixer, int start, int delay) {
+int VorbisTrackInfo::play(SoundMixer *mixer, int start, int delay) {
 #ifdef VORBIS_TREMOR
 	ov_time_seek(&_ov_file, (ogg_int64_t)(start / 75.0 * 1000));
 #else
@@ -1783,7 +1781,7 @@
 				 true);
 }
 
-Sound::VorbisTrackInfo::~VorbisTrackInfo() {
+VorbisTrackInfo::~VorbisTrackInfo() {
 	if (! _error_flag) {
 		ov_clear(&_ov_file);
 		delete _file;

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- sound.h	21 May 2003 18:09:48 -0000	1.30
+++ sound.h	15 Jun 2003 00:54:13 -0000	1.31
@@ -22,21 +22,14 @@
 #define SOUND_H
 
 #include "scummsys.h"
-#include "sound/mixer.h"
-#include "common/timer.h"
 
-class Scumm;
+class DigitalTrackInfo;
 class File;
+class Scumm;
+struct MP3OffsetTable;
 
 class Sound {
-
-private:
-
-enum {
-	SOUND_HEADER_SIZE = 26,
-	SOUND_HEADER_BIG_SIZE = 26 + 8
-};
-
+protected:
 	int16 _soundQuePos, _soundQue[0x100];
 	int16 _soundQue2Pos, _soundQue2[10];
 	bool _soundsPaused2;
@@ -85,50 +78,11 @@
 	int _dig_cd_num_loops;
 	bool _dig_cd_playing;
 
-	class DigitalTrackInfo {
-	public:
-		virtual bool error() = 0;
-		virtual int play(SoundMixer *mixer, int start, int delay) = 0;
-		virtual ~DigitalTrackInfo() { }
-	};
-
 	DigitalTrackInfo *_track_info[CACHE_TRACKS];
 
-#ifdef USE_MAD
-	class MP3TrackInfo : public DigitalTrackInfo {
-	private:
-		struct mad_header _mad_header;
-		long _size;
-		File *_file;
-		bool _error_flag;
-
-	public:
-		MP3TrackInfo(File *file);
-		~MP3TrackInfo();
-		bool error() { return _error_flag; }
-		int play(SoundMixer *mixer, int start, int delay);
-	};
-#endif
-
-#ifdef USE_VORBIS
-	class VorbisTrackInfo : public DigitalTrackInfo {
-	private:
-		File *_file;
-		OggVorbis_File _ov_file;
-		bool _error_flag;
-
-	public:
-		VorbisTrackInfo(File *file);
-		~VorbisTrackInfo();
-		bool error() { return _error_flag; }
-		int play(SoundMixer *mixer, int start, int delay);
-	};
-#endif
-
 	Scumm *_scumm;
 
 public:
-
 	int _current_cache;
 	int32 _bundleMusicPosition;
 
@@ -137,6 +91,7 @@
 	int16 _sound_volume_master, _sound_volume_music, _sound_volume_sfx;
 	byte _sfxMode;
 
+public:
 	Sound(Scumm *parent);
 	~Sound();
 	void addSoundToQueue(int sound);
@@ -152,25 +107,18 @@
 	bool isSoundInQueue(int sound);
 	void stopSound(int a);
 	void stopAllSounds();
-	void clearSoundQue();
 	void soundKludge(int *list, int num);
 	void talkSound(uint32 a, uint32 b, int mode, int frame);
 	void setupSound();
 	void pauseSounds(bool pause);
-	int startSfxSound(File *file, int file_size);
-	File *openSfxFile();
-	void stopSfxSound();
-	bool isSfxFinished();
-	uint32 decode12BitsSample(byte *src, byte **dst, uint32 size, bool stereo);
+
 	void playBundleMusic(const char *song);
 	void pauseBundleMusic(bool state);
 	void bundleMusicHandler(Scumm *scumm);
 	void stopBundleMusic();
 	int playBundleSound(char *sound);
-	byte *readCreativeVocFile(byte *ptr, uint32 &size, uint32 &rate, uint32 &loops);
-	int playSfxSound(void *sound, uint32 size, uint rate, bool isUnsigned);
-	int playSfxSound_MP3(void *sound, uint32 size);
-	int playSfxSound_Vorbis(void *sound, uint32 size);
+
+	uint32 decode12BitsSample(byte *src, byte **dst, uint32 size, bool stereo);
 
 	void startCDTimer();
 	void stopCDTimer();
@@ -181,6 +129,16 @@
 	void updateCD();
 
 protected:
+	void clearSoundQue();
+
+	File *openSfxFile();
+	int startSfxSound(File *file, int file_size);
+	void stopSfxSound();
+	bool isSfxFinished();
+	int playSfxSound(void *sound, uint32 size, uint rate, bool isUnsigned);
+	int playSfxSound_MP3(void *sound, uint32 size);
+	int playSfxSound_Vorbis(void *sound, uint32 size);
+
 	int getCachedTrack(int track);
 	int playMP3CDTrack(int track, int num_loops, int start, int delay);
 	int stopMP3CD();





More information about the Scummvm-git-logs mailing list