diff options
author | Max Horn | 2003-12-21 15:47:52 +0000 |
---|---|---|
committer | Max Horn | 2003-12-21 15:47:52 +0000 |
commit | e439eb51290082f204c10feaea2d5a72e3747879 (patch) | |
tree | 9a1309f9bce0d711f2369039b447d7ba705b1bc3 /queen | |
parent | f19f73eb5069b4f092714535e77efc0d6881c612 (diff) | |
download | scummvm-rg350-e439eb51290082f204c10feaea2d5a72e3747879.tar.gz scummvm-rg350-e439eb51290082f204c10feaea2d5a72e3747879.tar.bz2 scummvm-rg350-e439eb51290082f204c10feaea2d5a72e3747879.zip |
added convenience SoundMixer::playVorbis variant which calls through to playSfxSound_Vorbis; made scumm/queen engines use it
svn-id: r11812
Diffstat (limited to 'queen')
-rw-r--r-- | queen/sound.cpp | 80 |
1 files changed, 2 insertions, 78 deletions
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 |