X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FSound.cc;fp=src%2FMoof%2FSound.cc;h=460f7bb24a1054d2a18e0e579f08e8386320e06c;hp=f912b318d153c2dfa13ecf1b991169f4e87751ee;hb=33842c860fe18ca8cf087905992885687434320c;hpb=6dd7ae54e742339cc49e640d1076a310a0f4eedd diff --git a/src/Moof/Sound.cc b/src/Moof/Sound.cc index f912b31..460f7bb 100644 --- a/src/Moof/Sound.cc +++ b/src/Moof/Sound.cc @@ -38,6 +38,7 @@ #include "Log.hh" #include "Mippleton.hh" #include "Sound.hh" +#include "Timer.hh" #define BUFFER_SIZE (64 * 1024) //#define BUFFER_SIZE (5*2048) @@ -161,7 +162,7 @@ struct Sound::Impl } - void beginStream(ALuint source, int nBuffers = 4) + void beginStream(ALuint source, int nBuffers = 8) { if (!oggStream.datasource) openFile(); if (!oggStream.datasource) return; @@ -299,6 +300,9 @@ struct Sound::Impl alSourcei(source_, AL_LOOPING, AL_FALSE); alSourcePlay(source_); playing_ = true; + + streamTimer.init(boost::bind(&Impl::streamUpdate, this, _1, _2), 1.0, + Timer::REPEAT); } inline void update() @@ -446,6 +450,14 @@ struct Sound::Impl std::queue queue_; std::vector expired_; + + Timer streamTimer; + + void streamUpdate(Timer& timer, Scalar t) + { + // don't let the music die! + update(); + } }; Sound::Sound(const std::string& name) : @@ -459,19 +471,12 @@ void Sound::play() impl_->play(); } - void Sound::stream() { // pass through impl_->stream(); } -void Sound::update(Scalar t, Scalar dt) -{ - // pass through - impl_->update(); -} - void Sound::stop() {