]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Sound.cc
new timer class
[chaz/yoink] / src / Moof / Sound.cc
index f912b318d153c2dfa13ecf1b991169f4e87751ee..460f7bb24a1054d2a18e0e579f08e8386320e06c 100644 (file)
@@ -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<BufferP>             queue_;
        std::vector<BufferP>    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()
 {
This page took 0.019653 seconds and 4 git commands to generate.