aboutsummaryrefslogtreecommitdiff
path: root/sound/vorbis.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sound/vorbis.cpp')
-rw-r--r--sound/vorbis.cpp40
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 -