[Scummvm-cvs-logs] CVS: scummvm/sound audiocd.cpp,1.7,1.8 mixer.cpp,1.151,1.152 mixer.h,1.70,1.71 mp3.cpp,1.5,1.6 mp3.h,1.4,1.5 vorbis.cpp,1.5,1.6 vorbis.h,1.4,1.5

Max Horn fingolfin at users.sourceforge.net
Fri Jan 2 17:26:06 CET 2004


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

Modified Files:
	audiocd.cpp mixer.cpp mixer.h mp3.cpp mp3.h vorbis.cpp 
	vorbis.h 
Log Message:
more MAD MP3 / Ogg Vorbis cleanup: try not to expose anything about the libs used for MP3/Vorbis support -> this eases changing the implementations, and reduces header dependencies (and thus compile time) :-)

Index: audiocd.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/audiocd.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- audiocd.cpp	24 Dec 2003 00:25:17 -0000	1.7
+++ audiocd.cpp	3 Jan 2004 01:25:45 -0000	1.8
@@ -132,7 +132,7 @@
 	file->open(track_name, g_engine->getGameDataPath());
 
 	if (file->isOpen()) {
-		_track_info[current_index] = new MP3TrackInfo(file);
+		_track_info[current_index] = makeMP3TrackInfo(file);
 		if (_track_info[current_index]->error()) {
 			delete _track_info[current_index];
 			_track_info[current_index] = NULL;
@@ -147,7 +147,7 @@
 	file->open(track_name, g_engine->getGameDataPath());
 
 	if (file->isOpen()) {
-		_track_info[current_index] = new VorbisTrackInfo(file);
+		_track_info[current_index] = makeVorbisTrackInfo(file);
 		if (_track_info[current_index]->error()) {
 			delete _track_info[current_index];
 			_track_info[current_index] = NULL;

Index: mixer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.cpp,v
retrieving revision 1.151
retrieving revision 1.152
diff -u -d -r1.151 -r1.152
--- mixer.cpp	3 Jan 2004 00:55:28 -0000	1.151
+++ mixer.cpp	3 Jan 2004 01:25:45 -0000	1.152
@@ -260,11 +260,6 @@
 	AudioInputStream *input = makeVorbisStream(file, size);
 	playInputStream(handle, input, false, volume, pan, id);
 }
-void SoundMixer::playVorbis(PlayingSoundHandle *handle, OggVorbis_File *ov_file, int duration, bool is_cd_track, byte volume, int8 pan, int id) {
-	// Create the input stream
-	AudioInputStream *input = makeVorbisStream(ov_file, duration);
-	playInputStream(handle, input, is_cd_track, volume, pan, id);
-}
 #endif
 
 void SoundMixer::playInputStream(PlayingSoundHandle *handle, AudioInputStream *input, bool isMusic, byte volume, int8 pan, int id, bool autofreeStream) {

Index: mixer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.h,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- mixer.h	3 Jan 2004 00:55:28 -0000	1.70
+++ mixer.h	3 Jan 2004 01:25:45 -0000	1.71
@@ -27,10 +27,6 @@
 #include "common/scummsys.h"
 #include "common/system.h"
 
-#ifdef USE_VORBIS
-#include <vorbis/vorbisfile.h>
-#endif
-
 
 class AudioInputStream;
 class Channel;
@@ -115,7 +111,6 @@
 #endif
 #ifdef USE_VORBIS
 	void playVorbis(PlayingSoundHandle *handle, File *file, uint32 size, byte volume = 255, int8 pan = 0, int id = -1);
-	void playVorbis(PlayingSoundHandle *handle, OggVorbis_File *ov_file, int duration, bool is_cd_track, byte volume = 255, int8 pan = 0, int id = -1);
 #endif
 
 	void playInputStream(PlayingSoundHandle *handle, AudioInputStream *input, bool isMusic, byte volume = 255, int8 pan = 0, int id = -1, bool autofreeStream = true);

Index: mp3.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mp3.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- mp3.cpp	3 Jan 2004 00:55:28 -0000	1.5
+++ mp3.cpp	3 Jan 2004 01:25:45 -0000	1.6
@@ -20,11 +20,17 @@
  */
 
 #include "sound/mp3.h"
-#include "sound/audiostream.h"
+
+#ifdef USE_MAD
+
 #include "common/file.h"
 #include "common/util.h"
 
-#ifdef USE_MAD
+#include "sound/audiocd.h"
+#include "sound/audiostream.h"
+
+#include <mad.h>
+
 
 #pragma mark -
 #pragma mark --- MP3 (MAD) stream ---
@@ -264,6 +270,22 @@
 #pragma mark --- MP3 Audio CD emulation ---
 #pragma mark -
 
+
+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; }
+	void play(SoundMixer *mixer, PlayingSoundHandle *handle, int startFrame, int duration);
+};
+
+
 MP3TrackInfo::MP3TrackInfo(File *file) {
 	struct mad_stream stream;
 	struct mad_frame frame;
@@ -361,6 +383,10 @@
 MP3TrackInfo::~MP3TrackInfo() {
 	if (! _error_flag)
 		_file->close();
+}
+
+DigitalTrackInfo *makeMP3TrackInfo(File *file) {
+	return new MP3TrackInfo(file);
 }
 
 

Index: mp3.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mp3.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- mp3.h	3 Jan 2004 00:55:28 -0000	1.4
+++ mp3.h	3 Jan 2004 01:25:45 -0000	1.5
@@ -27,25 +27,11 @@
 
 #ifdef USE_MAD
 
-#include "sound/audiocd.h"
-#include <mad.h>
-
 class AudioInputStream;
+class DigitalTrackInfo;
 class File;
 
-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; }
-	void play(SoundMixer *mixer, PlayingSoundHandle *handle, int startFrame, int duration);
-};
+DigitalTrackInfo *makeMP3TrackInfo(File *file);
 
 AudioInputStream *makeMP3Stream(File *file, uint size);
 

Index: vorbis.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/vorbis.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- vorbis.cpp	23 Dec 2003 19:14:57 -0000	1.5
+++ vorbis.cpp	3 Jan 2004 01:25:45 -0000	1.6
@@ -20,11 +20,38 @@
  */
 
 #include "sound/vorbis.h"
-#include "sound/audiostream.h"
+
+#ifdef USE_VORBIS
+
 #include "common/file.h"
 #include "common/util.h"
 
-#ifdef USE_VORBIS
+#include "sound/audiostream.h"
+#include "sound/audiocd.h"
+
+#include <vorbis/vorbisfile.h>
+
+
+AudioInputStream *makeVorbisStream(OggVorbis_File *file, int duration);
+
+
+#pragma mark -
+#pragma mark --- Ogg Vorbis Audio CD emulation ---
+#pragma mark -
+
+class VorbisTrackInfo : public DigitalTrackInfo {
+private:
+	File *_file;
+	OggVorbis_File _ov_file;
+	bool _error_flag;
+
+public:
+	VorbisTrackInfo(File *file);
+	~VorbisTrackInfo();
+	bool error() { return _error_flag; }
+	void play(SoundMixer *mixer, PlayingSoundHandle *handle, int startFrame, int duration);
+};
+
 
 // These are wrapper functions to allow using a File object to
 // provide data to the OggVorbis_File object.
@@ -117,8 +144,9 @@
 #else
 	ov_time_seek(&_ov_file, startFrame / 75.0);
 #endif
-	mixer->playVorbis(handle, &_ov_file,
-							duration * ov_info(&_ov_file, -1)->rate / 75, true);
+
+	AudioInputStream *input = makeVorbisStream(&_ov_file, duration * ov_info(&_ov_file, -1)->rate / 75);
+	mixer->playInputStream(handle, input, true);
 }
 
 VorbisTrackInfo::~VorbisTrackInfo() {
@@ -126,6 +154,10 @@
 		ov_clear(&_ov_file);
 		delete _file;
 	}
+}
+
+DigitalTrackInfo *makeVorbisTrackInfo(File *file) {
+	return new VorbisTrackInfo(file);
 }
 
 #pragma mark -

Index: vorbis.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/vorbis.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- vorbis.h	23 Dec 2003 19:14:57 -0000	1.4
+++ vorbis.h	3 Jan 2004 01:25:45 -0000	1.5
@@ -27,27 +27,12 @@
 
 #ifdef USE_VORBIS
 
-#include "sound/audiocd.h"
-#include <vorbis/vorbisfile.h>
-
 class AudioInputStream;
+class DigitalTrackInfo;
 class File;
 
-class VorbisTrackInfo : public DigitalTrackInfo {
-private:
-	File *_file;
-	OggVorbis_File _ov_file;
-	bool _error_flag;
-
-public:
-	VorbisTrackInfo(File *file);
-	~VorbisTrackInfo();
-	bool error() { return _error_flag; }
-	void play(SoundMixer *mixer, PlayingSoundHandle *handle, int startFrame, int duration);
-};
-
+DigitalTrackInfo *makeVorbisTrackInfo(File *file);
 
-AudioInputStream *makeVorbisStream(OggVorbis_File *file, int duration);
 AudioInputStream *makeVorbisStream(File *file, uint32 size);
 
 #endif





More information about the Scummvm-git-logs mailing list