aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO2
-rw-r--r--queen/sound.cpp80
-rw-r--r--scumm/sound.cpp2
-rw-r--r--sound/mixer.cpp3
-rw-r--r--sound/mixer.h1
5 files changed, 8 insertions, 80 deletions
diff --git a/TODO b/TODO
index ce98255843..7af2078a5e 100644
--- a/TODO
+++ b/TODO
@@ -32,7 +32,7 @@ General
- convert said string representation back to FSNode
Of course that can be added w/o a FileManager class, too - but it might be
nice to have all of these integrated.
-
+
Documentation
=============
diff --git a/queen/sound.cpp b/queen/sound.cpp
index d3076ba80d..f907873246 100644
--- a/queen/sound.cpp
+++ b/queen/sound.cpp
@@ -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 @@ void MP3Sound::sfxPlay(const char *name) {
#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
diff --git a/scumm/sound.cpp b/scumm/sound.cpp
index 9da499b67e..046f43da20 100644
--- a/scumm/sound.cpp
+++ b/scumm/sound.cpp
@@ -848,7 +848,7 @@ void Sound::startSfxSound(File *file, int file_size, PlayingSoundHandle *handle)
if (file_size > 0) {
if (_vorbis_mode) {
#ifdef USE_VORBIS
- playSfxSound_Vorbis(_scumm->_mixer, file, file_size, handle);
+ _scumm->_mixer->playVorbis(handle, file, file_size);
#endif
} else {
#ifdef USE_MAD
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index 6f43a4c5f9..4c3e9ca277 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -269,6 +269,9 @@ void SoundMixer::playMP3CDTrack(PlayingSoundHandle *handle, File *file, mad_time
#endif
#ifdef USE_VORBIS
+void SoundMixer::playVorbis(PlayingSoundHandle *handle, File *file, uint32 size) {
+ playSfxSound_Vorbis(this, file, size, handle);
+}
void SoundMixer::playVorbis(PlayingSoundHandle *handle, OggVorbis_File *ov_file, int duration, bool is_cd_track, byte volume, int8 pan) {
// Create the input stream
AudioInputStream *input = makeVorbisStream(ov_file, duration);
diff --git a/sound/mixer.h b/sound/mixer.h
index 1f70419c81..fa015dadcf 100644
--- a/sound/mixer.h
+++ b/sound/mixer.h
@@ -104,6 +104,7 @@ public:
void playMP3CDTrack(PlayingSoundHandle *handle, File *file, mad_timer_t duration, byte volume = 255, int8 pan = 0);
#endif
#ifdef USE_VORBIS
+ void playVorbis(PlayingSoundHandle *handle, File *file, uint32 size);
void playVorbis(PlayingSoundHandle *handle, OggVorbis_File *ov_file, int duration, bool is_cd_track, byte volume = 255, int8 pan = 0);
#endif