summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-06-30 12:38:18 +0000
committerrubidium <rubidium@openttd.org>2009-06-30 12:38:18 +0000
commitc29afac0a7264b7a3ab2cb3880abd5ba5ad4a8b5 (patch)
treebca01c5527e1d48a9328204fafb30339c038d254
parent791187cd12e0f784925c593d6ddc3e46c3f5ce1d (diff)
downloadopenttd-c29afac0a7264b7a3ab2cb3880abd5ba5ad4a8b5.tar.xz
(svn r16700) -Fix: if allegro fails to start or fails open a window or sound card fall back to another driver
-rw-r--r--src/music/allegro_m.cpp5
-rw-r--r--src/sound/allegro_s.cpp6
-rw-r--r--src/video/allegro_v.cpp6
3 files changed, 10 insertions, 7 deletions
diff --git a/src/music/allegro_m.cpp b/src/music/allegro_m.cpp
index 9400e7f49..1322ca54b 100644
--- a/src/music/allegro_m.cpp
+++ b/src/music/allegro_m.cpp
@@ -18,15 +18,16 @@ extern int _allegro_instance_count;
const char *MusicDriver_Allegro::Start(const char * const *param)
{
- if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, NULL)) return NULL;
+ if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, NULL)) return "Failed to set up Allegro";
_allegro_instance_count++;
/* Initialise the sound */
- if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0) return NULL;
+ if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0) return "Failed to set up Allegro sound";
/* Okay, there's no soundcard */
if (midi_card == MIDI_NONE) {
DEBUG(driver, 0, "allegro: no midi card found");
+ return "No sound card found";
}
return NULL;
diff --git a/src/sound/allegro_s.cpp b/src/sound/allegro_s.cpp
index 977f33bc8..069e473e5 100644
--- a/src/sound/allegro_s.cpp
+++ b/src/sound/allegro_s.cpp
@@ -45,16 +45,16 @@ extern int _allegro_instance_count;
const char *SoundDriver_Allegro::Start(const char * const *parm)
{
- if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, NULL)) return NULL;
+ if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, NULL)) return "Failed to set up Allegro";
_allegro_instance_count++;
/* Initialise the sound */
- if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0) return NULL;
+ if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0) return "Failed to set up Allegro sound";
/* Okay, there's no soundcard */
if (digi_card == DIGI_NONE) {
DEBUG(driver, 0, "allegro: no sound card found");
- return NULL;
+ return "No sound card found";
}
_stream = play_audio_stream(BUFFER_SIZE, 16, true, 11025, 255, 128);
diff --git a/src/video/allegro_v.cpp b/src/video/allegro_v.cpp
index de0a08eed..61ce20f13 100644
--- a/src/video/allegro_v.cpp
+++ b/src/video/allegro_v.cpp
@@ -404,7 +404,7 @@ int _allegro_instance_count = 0;
const char *VideoDriver_Allegro::Start(const char * const *parm)
{
- if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, NULL)) return NULL;
+ if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, NULL)) return "Failed to set up Allegro";
_allegro_instance_count++;
install_timer();
@@ -425,7 +425,9 @@ const char *VideoDriver_Allegro::Start(const char * const *parm)
#endif
GetVideoModes();
- CreateMainSurface(_cur_resolution.width, _cur_resolution.height);
+ if (!CreateMainSurface(_cur_resolution.width, _cur_resolution.height)) {
+ return "Failed to set up Allegro video";
+ }
MarkWholeScreenDirty();
set_close_button_callback(HandleExitGameRequest);