X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FSound.cc;h=368e9388bca4aee4f3665ae40b1abf1afa71f6cd;hp=59acfaa9af269886ec0cc34a8286671751f75505;hb=5fa5f117f28922a7e539a432367960c1a61f837d;hpb=a5f0d391406a68275b41448fc3f49e8d8396c497 diff --git a/src/Moof/Sound.cc b/src/Moof/Sound.cc index 59acfaa..368e938 100644 --- a/src/Moof/Sound.cc +++ b/src/Moof/Sound.cc @@ -26,13 +26,13 @@ *******************************************************************************/ -#include #include #include #include #include +#include "Log.hh" #include "Mippleton.hh" #include "Sound.hh" @@ -84,8 +84,8 @@ struct Sound::Impl if (!sound) { - std::cerr << "could not load sound from file" << std::endl; - exit(1); + logWarning("audio not found: %s", getName().c_str()); + throw Exception(Exception::FILE_NOT_FOUND); } if (!stream) @@ -93,27 +93,27 @@ struct Sound::Impl unsigned decoded = Sound_DecodeAll(sound); if (decoded == 0) { - std::cout << "decoded no bytes" << std::endl; - exit(1); + logWarning("decoded not bytes from %s", getName().c_str()); + throw Exception(Exception::FILE_NOT_FOUND); } alGenBuffers(2, objects); alBufferData(objects[0], getAudioFormat(sound->actual), sound->buffer, sound->buffer_size, sound->actual.rate); - std::cerr << "buffer size: " << sound->buffer_size << std::endl; - std::cerr << "channels: " << (int)sound->actual.channels << std::endl; - std::cerr << "format: " << sound->actual.format << std::endl; - std::cerr << "frequency: " << sound->actual.rate << std::endl; + logDebug("buffer size: %d", sound->buffer_size); + logDebug(" channels: %d", sound->actual.channels); + logDebug(" format: %d", sound->actual.format); + logDebug(" frequency: %d", sound->actual.rate); Sound_FreeSample(sound); sound = 0; } else { - std::cerr << "buffer size: " << sound->buffer_size << std::endl; - std::cerr << "channels: " << (int)sound->actual.channels << std::endl; - std::cerr << "format: " << sound->actual.format << std::endl; - std::cerr << "frequency: " << sound->actual.rate << std::endl; + logDebug("buffer size: %d", sound->buffer_size); + logDebug(" channels: %d", sound->actual.channels); + logDebug(" format: %d", sound->actual.format); + logDebug(" frequency: %d", sound->actual.rate); alGenBuffers(2, objects); } } @@ -143,7 +143,7 @@ struct Sound::Impl }; Impl(const std::string& name, bool stream = false) : - buffer_(Buffer::retain(name), Buffer::release) + buffer_(Buffer::getInstance(name)) { if (!stream) buffer_->loadFromFile(Sound::getPath(name), stream); else buffer_->loadFromFile(SoundStream::getPath(name), stream);