SoundSource* SoundManager::create_sound_source(const std::string& filename) { if(!sound_enabled) return create_dummy_sound_source(); try { return intern_create_sound_source(filename); } catch(std::exception &e) { log_warning << "Couldn't create audio source: " << e.what() << std::endl; return create_dummy_sound_source(); } }
void SoundManager::play(const std::string& filename, const Vector& pos) { if(!sound_enabled) return; try { std::unique_ptr<OpenALSoundSource> source(intern_create_sound_source(filename)); if(pos.x < 0 || pos.y < 0) { source->set_relative(true); } else { source->set_position(pos); } source->play(); sources.push_back(std::move(source)); } catch(std::exception& e) { log_warning << "Couldn't play sound " << filename << ": " << e.what() << std::endl; } }