+ try {
+ device = alcOpenDevice(0);
+ if (device == NULL) {
+ throw std::runtime_error("Couldn't open audio device.");
+ }
+
+ int attributes[] = { 0 };
+ context = alcCreateContext(device, attributes);
+ check_alc_error("Couldn't create audio context: ");
+ alcMakeContextCurrent(context);
+ check_alc_error("Couldn't select audio context: ");
+
+ check_al_error("Audio error after init: ");
+ sound_enabled = true;
+ } catch(std::exception& e) {
+ if(context != NULL)
+ alcDestroyContext(context);
+ context = NULL;
+ if(device != NULL)
+ alcCloseDevice(device);
+ device = NULL;
+ log_warning << "Couldn't initialize audio device: " << e.what() << std::endl;
+ print_openal_version();
+ }