X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fmoof%2Fsound.cc;h=2c19d265b721f0b9d0e01a94f0bd93007157f948;hp=0714698673f02f8d7a757e0923ba39ca509f2191;hb=6f1b787a10d8ab1a3117a4b8c004dd2d90599608;hpb=ed04ddaaa59dcc42e375ec492dbda77f693530e9 diff --git a/src/moof/sound.cc b/src/moof/sound.cc index 0714698..2c19d26 100644 --- a/src/moof/sound.cc +++ b/src/moof/sound.cc @@ -13,7 +13,6 @@ #include #include #include -#include #include #include @@ -25,22 +24,24 @@ #include "hash.hh" #include "log.hh" -#include "manager.hh" #include "sound.hh" #include "resource.hh" #include "timer.hh" #ifndef BUF_SIZE -#define BUF_SIZE (4096) +#define BUF_SIZE (4096 * 64) #endif -#define NUM_BUFFERS (8) +#define NUM_BUFFERS (4) namespace moof { +/*] Sound backend + *************************************************************************/ + class sound_backend { public: @@ -104,27 +105,11 @@ ALCcontext* sound_backend::al_context; class sound_resource; typedef resource_handle sound_handle; - -class sound_resource_loader -{ -public: - - sound_resource_loader() - { - resource::register_type("ogg", "sounds"); - } - - ~sound_resource_loader() - { - resource::unregister_type("ogg"); - } -}; - -static sound_resource_loader loader; - +MOOF_REGISTER_RESOURCE(sound_resource, ogg, sounds); -// SOUND BUFFER +/*] Sound buffer + *************************************************************************/ class buffer { @@ -226,7 +211,8 @@ buffer::retcount_lookup buffer::retain_counts_; -// SOUND RESOURCE +/*] Sound resource + *************************************************************************/ class sound_resource : public boost::noncopyable { @@ -334,6 +320,8 @@ private: }; +/*] Sound class + *************************************************************************/ class sound::impl { @@ -419,7 +407,7 @@ public: if (!stream_timer_.is_valid()) { stream_timer_.init(boost::bind(&impl::stream_update, this, _1, _2), - 0.01, timer::repeat); + SCALAR(0.5), timer::repeat); } alSourcePlay(source_); @@ -603,12 +591,6 @@ void sound::enqueue(const std::string& path) void sound::play() -{ - // pass through - impl_->play(); -} - -void sound::stream() { // pass through impl_->stream(); @@ -637,7 +619,6 @@ void sound::toggle() { if (is_playing()) pause(); else play(); - // TODO: what about streaming sources? } bool sound::is_playing() const