diff options
author | Max Horn | 2004-01-03 01:25:45 +0000 |
---|---|---|
committer | Max Horn | 2004-01-03 01:25:45 +0000 |
commit | 81481ad6da949340fc0e886b08d404b7cd3d7b77 (patch) | |
tree | ed1685ae64ee61adece8b422a3c3972c18cd5b69 /sound/vorbis.cpp | |
parent | 56eae68e8bafde62e28af1cf5302d52424362684 (diff) | |
download | scummvm-rg350-81481ad6da949340fc0e886b08d404b7cd3d7b77.tar.gz scummvm-rg350-81481ad6da949340fc0e886b08d404b7cd3d7b77.tar.bz2 scummvm-rg350-81481ad6da949340fc0e886b08d404b7cd3d7b77.zip |
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) :-)
svn-id: r12097
Diffstat (limited to 'sound/vorbis.cpp')
-rw-r--r-- | sound/vorbis.cpp | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/sound/vorbis.cpp b/sound/vorbis.cpp index d5fcb47526..bcee8b792b 100644 --- a/sound/vorbis.cpp +++ b/sound/vorbis.cpp @@ -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 @@ void VorbisTrackInfo::play(SoundMixer *mixer, PlayingSoundHandle *handle, int st #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() { @@ -128,6 +156,10 @@ VorbisTrackInfo::~VorbisTrackInfo() { } } +DigitalTrackInfo *makeVorbisTrackInfo(File *file) { + return new VorbisTrackInfo(file); +} + #pragma mark - #pragma mark --- Ogg Vorbis stream --- #pragma mark - |