[Scummvm-cvs-logs] CVS: scummvm/queen sound.cpp,1.21,1.22

Max Horn fingolfin at users.sourceforge.net
Sun Dec 21 07:49:01 CET 2003


Update of /cvsroot/scummvm/scummvm/queen
In directory sc8-pr-cvs1:/tmp/cvs-serv18221/queen

Modified Files:
	sound.cpp 
Log Message:
added convenience SoundMixer::playVorbis variant which calls through to playSfxSound_Vorbis; made scumm/queen engines use it

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/sound.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- sound.cpp	21 Dec 2003 00:07:16 -0000	1.21
+++ sound.cpp	21 Dec 2003 15:47:52 -0000	1.22
@@ -32,69 +32,6 @@
 
 namespace Queen {
 
-#ifdef USE_VORBIS
-// These are wrapper functions to allow using a File object to
-// provide data to the OggVorbis_File object.
-
-struct file_info {
-	File *file;
-	int start, curr_pos;
-	size_t len;
-};
-
-static size_t read_wrap(void *ptr, size_t size, size_t nmemb, void *datasource) {
-	file_info *f = (file_info *) datasource;
-	int result;
-
-	nmemb *= size;
-	if (f->curr_pos > (int) f->len)
-		nmemb = 0;
-	else if (nmemb > f->len - f->curr_pos)
-		nmemb = f->len - f->curr_pos;
-	result = f->file->read(ptr, nmemb);
-	if (result == -1) {
-		f->curr_pos = f->file->pos() - f->start;
-		return (size_t) -1;
-	} else {
-		f->curr_pos += result;
-		return result / size;
-	}
-}
-
-static int seek_wrap(void *datasource, ogg_int64_t offset, int whence) {
-	file_info *f = (file_info *) datasource;
-
-	if (whence == SEEK_SET)
-		offset += f->start;
-	else if (whence == SEEK_END) {
-		offset += f->start + f->len;
-		whence = SEEK_SET;
-	}
-
-	f->file->seek(offset, whence);
-	f->curr_pos = f->file->pos() - f->start;
-	return f->curr_pos;
-}
-
-static int close_wrap(void *datasource) {
-	file_info *f = (file_info *) datasource;
-
-	f->file->close();
-	delete f;
-	return 0;
-}
-
-static long tell_wrap(void *datasource) {
-	file_info *f = (file_info *) datasource;
-
-	return f->curr_pos;
-}
-
-static ov_callbacks g_File_wrap = {
-	read_wrap, seek_wrap, close_wrap, tell_wrap
-};
-#endif
-
 Sound::Sound(SoundMixer *mixer, QueenEngine *vm) : 
 	_mixer(mixer), _vm(vm), _sfxToggle(true), _speechToggle(true), _musicToggle(true), _lastOverride(0), _currentSong(0), _sfxHandle(0) {
 }
@@ -216,21 +153,8 @@
 #ifdef USE_VORBIS
 void OGGSound::sfxPlay(const char *name) {
 	waitSfxFinished();	
-	if (_vm->resource()->exists(name)) {
-		OggVorbis_File *oggFile = new OggVorbis_File;
-		file_info *f = new file_info;
-
-		f->file = _vm->resource()->giveCompressedSound(name);
-		f->start = _vm->resource()->fileOffset(name);
-		f->len = _vm->resource()->fileSize(name);
-		f->curr_pos = 0;
-
-		if (ov_open_callbacks((void *)f, oggFile, NULL, 0, g_File_wrap) < 0) {
-			delete oggFile;
-			delete f;
-		} else
-			_mixer->playVorbis(&_sfxHandle, oggFile, 0, false);
-	}
+	if (_vm->resource()->exists(name))
+		_mixer->playVorbis(&_sfxHandle, _vm->resource()->giveCompressedSound(name), _vm->resource()->fileSize(name));
 }
 #endif
 





More information about the Scummvm-git-logs mailing list