*******************************************************************************/
-#include <iostream>
#include <string>
#include <SDL/SDL.h>
#include <SDL/SDL_sound.h>
#include <AL/al.h>
+#include "Log.hh"
#include "Mippleton.hh"
#include "Sound.hh"
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)
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);
}
}
};
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);