aboutsummaryrefslogtreecommitdiff
path: root/sound/vorbis.cpp
diff options
context:
space:
mode:
authorMax Horn2004-06-28 22:35:22 +0000
committerMax Horn2004-06-28 22:35:22 +0000
commite0eab01e639acfa7eee9fcd755f6fceb88f38710 (patch)
tree049ebd5a41f6bdb1d73f2e8bb0049be8be93ee09 /sound/vorbis.cpp
parenta5df4fba77214a93442a0a9e9607cd0a523f24a8 (diff)
downloadscummvm-rg350-e0eab01e639acfa7eee9fcd755f6fceb88f38710.tar.gz
scummvm-rg350-e0eab01e639acfa7eee9fcd755f6fceb88f38710.tar.bz2
scummvm-rg350-e0eab01e639acfa7eee9fcd755f6fceb88f38710.zip
Make use of new File refcount code; also fixed long standing bug in vorbis code (ov_clear was not being called, resulting in a file not being closed)
svn-id: r14107
Diffstat (limited to 'sound/vorbis.cpp')
-rw-r--r--sound/vorbis.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/sound/vorbis.cpp b/sound/vorbis.cpp
index 4773823520..3d48d12b1b 100644
--- a/sound/vorbis.cpp
+++ b/sound/vorbis.cpp
@@ -102,7 +102,7 @@ static int seek_wrap(void *datasource, ogg_int64_t offset, int whence) {
static int close_wrap(void *datasource) {
file_info *f = (file_info *) datasource;
- f->file->close();
+ f->file->decRef();
delete f;
return 0;
}
@@ -193,6 +193,8 @@ class VorbisInputStream : public AudioStream {
inline bool eosIntern() const;
public:
VorbisInputStream(OggVorbis_File *file, int duration);
+ ~VorbisInputStream();
+
int readBuffer(int16 *buffer, const int numSamples);
int16 read();
@@ -225,6 +227,10 @@ VorbisInputStream::VorbisInputStream(OggVorbis_File *file, int duration)
refill();
}
+VorbisInputStream::~VorbisInputStream() {
+ ov_clear(_ov_file);
+}
+
inline int16 VorbisInputStream::read() {
assert(!eosIntern());
@@ -309,8 +315,10 @@ AudioStream *makeVorbisStream(File *file, uint32 size) {
delete ov_file;
delete f;
return 0;
- } else
+ } else {
+ file->incRef();
return new VorbisInputStream(ov_file, 0);
+ }
}
#endif