(svn r2728) -Fix/Feature: Change the driver probing algorithm

Instead of trying to start a single driver and bailing out if that fails, try to initialise one by one and use the first one which succeeds.
This should fix problems on machines with no sound card, where -s null had to be specified manually.
This commit is contained in:
tron
2005-07-27 19:57:12 +00:00
parent 6c52a8629d
commit 5821529859
10 changed files with 104 additions and 214 deletions

81
win32.c
View File

@@ -17,20 +17,6 @@
#include <fcntl.h>
#include "variables.h"
#include "win32.h"
#include "driver.h"
#include "music/dmusic.h"
#include "music/null_m.h"
#include "music/win32_m.h"
#include "sound/null_s.h"
#include "sound/sdl_s.h"
#include "sound/win32_s.h"
#include "video/dedicated_v.h"
#include "video/null_v.h"
#include "video/sdl_v.h"
#include "video/win32_v.h"
static bool _has_console;
@@ -933,73 +919,6 @@ void FiosDelete(const char *name)
DeleteFile(path);
}
#define Windows_2000 5
#define Windows_NT3_51 4
/* flags show the minimum required OS to use a given feature. Currently
only dwMajorVersion and dwMinorVersion (WindowsME) are used
MajorVersion MinorVersion
Windows Server 2003 5 2 dmusic
Windows XP 5 1 dmusic
Windows 2000 5 0 dmusic
Windows NT 4.0 4 0 win32
Windows Me 4 90 dmusic
Windows 98 4 10 win32
Windows 95 4 0 win32
Windows NT 3.51 3 51 ?????
*/
const DriverDesc _video_driver_descs[] = {
{"null", "Null Video Driver", &_null_video_driver, 0},
#if defined(WITH_SDL)
{"sdl", "SDL Video Driver", &_sdl_video_driver, 1},
#endif
{"win32", "Win32 GDI Video Driver", &_win32_video_driver, Windows_NT3_51},
#ifdef ENABLE_NETWORK
{ "dedicated", "Dedicated Video Driver", &_dedicated_video_driver, 0},
#endif
{ NULL, NULL, NULL, 0 }
};
const DriverDesc _sound_driver_descs[] = {
{"null", "Null Sound Driver", &_null_sound_driver, 0},
#if defined(WITH_SDL)
{"sdl", "SDL Sound Driver", &_sdl_sound_driver, 1},
#endif
{"win32", "Win32 WaveOut Driver", &_win32_sound_driver, Windows_NT3_51},
{ NULL, NULL, NULL, 0 }
};
const DriverDesc _music_driver_descs[] = {
{"null", "Null Music Driver", &_null_music_driver, 0},
#ifdef WIN32_ENABLE_DIRECTMUSIC_SUPPORT
{"dmusic", "DirectMusic MIDI Driver", &_dmusic_midi_driver, Windows_2000},
#endif
// Win32 MIDI driver has higher priority than DMusic, so this one is chosen
{"win32", "Win32 MIDI Driver", &_win32_music_driver, Windows_NT3_51},
{ NULL, NULL, NULL, 0 }
};
byte GetOSVersion(void)
{
OSVERSIONINFO osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if (GetVersionEx(&osvi)) {
DEBUG(misc, 2) ("Windows Version is %d.%d", osvi.dwMajorVersion, osvi.dwMinorVersion);
// WinME needs directmusic too (dmusic, Windows_2000 mode), all others default to OK
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90) { return Windows_2000;} // WinME
return osvi.dwMajorVersion;
}
// GetVersionEx failed, but we can safely assume at least Win95/WinNT3.51 is used
DEBUG(misc, 0) ("Windows version retrieval failed, defaulting to level 4");
return Windows_NT3_51;
}
bool FileExists(const char *filename)
{
HANDLE hand = CreateFile(filename, 0, 0, NULL, OPEN_EXISTING, 0, NULL);