Note: I believe all the sound resources, etc are still loaded. This could be optimised in the future
SVN-Revision: 3427
{
try {
device = alcOpenDevice(0);
- if(device == 0) {
- print_openal_version();
+ if (device == 0) {
throw std::runtime_error("Couldn't open audio device.");
}
} catch(std::exception& e) {
device = 0;
context = 0;
- log_warning << "Couldn't initialize audio device:" << e.what() << std::endl;
+ log_warning << "Couldn't initialize audio device: " << e.what() << std::endl;
print_openal_version();
- throw e;
}
}
SoundManager::~SoundManager()
{
- delete music_source;
+ if(music_source)
+ delete music_source;
for(SoundSources::iterator i = sources.begin(); i != sources.end(); ++i) {
delete *i;
if(music_source) {
music_source->update();
}
-
- alcProcessContext(context);
- check_alc_error("Error while processing audio context: ");
+
+ if (context)
+ {
+ alcProcessContext(context);
+ check_alc_error("Error while processing audio context: ");
+ }
}
ALenum
void enable_music(bool music_enabled);
void play_music(const std::string& filename, bool fade = false);
void stop_music(float fadetime = 0);
-
+
+ bool is_music_enabled() { return music_enabled; }
bool is_sound_enabled() { return sound_enabled; }
+ bool is_audio_enabled() {
+ return (device == 0 || context == 0 ? false : true);
+ }
+
void update();
private:
add_label(_("Options"));
add_hl();
add_toggle(MNID_FULLSCREEN,_("Fullscreen"), config->use_fullscreen);
- add_toggle(MNID_SOUND, _("Sound"), config->sound_enabled);
- add_toggle(MNID_MUSIC, _("Music"), config->music_enabled);
+ if (sound_manager->is_audio_enabled()) {
+ add_toggle(MNID_SOUND, _("Sound"), config->sound_enabled);
+ add_toggle(MNID_MUSIC, _("Music"), config->music_enabled);
+ }
+ else
+ {
+ add_deactive(MNID_SOUND, _("Sound disabled"));
+ add_deactive(MNID_SOUND, _("Music disabled"));
+ }
add_submenu(_("Setup Keys"), main_controller->get_key_options_menu());
add_submenu(_("Setup Joystick"),main_controller->get_joystick_options_menu());
add_hl();
debugger = NULL;
}
#endif
- sq_close(global_vm);
+
+ if (global_vm)
+ sq_close(global_vm);
+
global_vm = NULL;
}