+ALenum
+SoundManager::get_sample_format(SoundFile* file)
+{
+ if(file->channels == 2) {
+ if(file->bits_per_sample == 16) {
+ return AL_FORMAT_STEREO16;
+ } else if(file->bits_per_sample == 8) {
+ return AL_FORMAT_STEREO8;
+ } else {
+ throw std::runtime_error("Only 16 and 8 bit samples supported");
+ }
+ } else if(file->channels == 1) {
+ if(file->bits_per_sample == 16) {
+ return AL_FORMAT_MONO16;
+ } else if(file->bits_per_sample == 8) {
+ return AL_FORMAT_MONO8;
+ } else {
+ throw std::runtime_error("Only 16 and 8 bit samples supported");
+ }
+ }
+
+ throw std::runtime_error("Only 1 and 2 channel samples supported");
+}
+
+void
+SoundManager::print_openal_version()
+{
+ log_info << "OpenAL Vendor: " << alGetString(AL_VENDOR) << std::endl;
+ log_info << "OpenAL Version: " << alGetString(AL_VERSION) << std::endl;
+ log_info << "OpenAL Renderer: " << alGetString(AL_RENDERER) << std::endl;
+ log_info << "OpenAl Extensions: " << alGetString(AL_EXTENSIONS) << std::endl;
+}
+
+void
+SoundManager::check_alc_error(const char* message)
+{
+ int err = alcGetError(device);
+ if(err != ALC_NO_ERROR) {
+ std::stringstream msg;
+ msg << message << alcGetString(device, err);
+ throw std::runtime_error(msg.str());
+ }
+}
+
+void
+SoundManager::check_al_error(const char* message)
+{
+ int err = alGetError();
+ if(err != AL_NO_ERROR) {
+ std::stringstream msg;
+ msg << message << alGetString(err);
+ throw std::runtime_error(msg.str());
+ }
+}