author | KUDr |
Fri, 20 Apr 2007 19:43:06 +0000 | |
changeset 6513 | 454347ca3dfb |
parent 6248 | e4a2ed7e5613 |
child 7045 | 5d5306f074db |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6125
a6fff965707c
(svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas
parents:
6034
diff
changeset
|
3 |
/** @file driver.cpp */ |
a6fff965707c
(svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas
parents:
6034
diff
changeset
|
4 |
|
2171
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
5 |
#include "stdafx.h" |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
6 |
#include "openttd.h" |
2210
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
7 |
#include "debug.h" |
2171
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
8 |
#include "driver.h" |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
9 |
#include "functions.h" |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
10 |
#include "hal.h" |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
11 |
#include "string.h" |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
12 |
|
2210
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
13 |
#include "music/bemidi.h" |
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
14 |
#include "music/dmusic.h" |
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
15 |
#include "music/extmidi.h" |
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
16 |
#include "music/null_m.h" |
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
17 |
#include "music/os2_m.h" |
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
18 |
#include "music/win32_m.h" |
2496
74c42595f8e8
(svn r3022) -feature: [OSX] OSX now uses quicktime to play midi files
bjarni
parents:
2458
diff
changeset
|
19 |
#include "music/qtmidi.h" |
6034
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
5756
diff
changeset
|
20 |
#include "music/libtimidity.h" |
2210
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
21 |
|
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
22 |
#include "sound/null_s.h" |
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
23 |
#include "sound/sdl_s.h" |
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2500
diff
changeset
|
24 |
#include "sound/cocoa_s.h" |
2210
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
25 |
#include "sound/win32_s.h" |
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
26 |
|
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
27 |
#include "video/dedicated_v.h" |
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
28 |
#include "video/null_v.h" |
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
29 |
#include "video/sdl_v.h" |
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2500
diff
changeset
|
30 |
#include "video/cocoa_v.h" |
2210
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
31 |
#include "video/win32_v.h" |
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
32 |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6125
diff
changeset
|
33 |
struct DriverDesc { |
2219
2437978eae8f
(svn r2737) static, const and don't make variables public nobody else needs to know about
tron
parents:
2210
diff
changeset
|
34 |
const char* name; |
2437978eae8f
(svn r2737) static, const and don't make variables public nobody else needs to know about
tron
parents:
2210
diff
changeset
|
35 |
const char* longname; |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
36 |
const HalCommonDriver* drv; |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6125
diff
changeset
|
37 |
}; |
2219
2437978eae8f
(svn r2737) static, const and don't make variables public nobody else needs to know about
tron
parents:
2210
diff
changeset
|
38 |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6125
diff
changeset
|
39 |
struct DriverClass { |
2171
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
40 |
const DriverDesc *descs; |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
41 |
const char *name; |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
42 |
const HalCommonDriver** drv; |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6125
diff
changeset
|
43 |
}; |
2171
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
44 |
|
2222
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
45 |
|
2902
b13a5f9396f6
(svn r3457) -Fix: killed some warnings about strict-alias in an ugly way (but it works ;))
truelight
parents:
2832
diff
changeset
|
46 |
#define M(x, y, z) { x, y, (const HalCommonDriver *)(void *)z } |
2222
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
47 |
static const DriverDesc _music_driver_descs[] = { |
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
48 |
#ifdef __BEOS__ |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
49 |
M("bemidi", "BeOS MIDI Driver", &_bemidi_music_driver), |
2222
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
50 |
#endif |
5305
fab86bb654da
(svn r7461) -Fix: [FS#262] Add support for building with GCC on OS/2 (psmedley)
Darkvater
parents:
5170
diff
changeset
|
51 |
#if defined(__OS2__) && !defined(__INNOTEK_LIBC__) |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
52 |
M("os2", "OS/2 Music Driver", &_os2_music_driver), |
2222
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
53 |
#endif |
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
54 |
#ifdef WIN32_ENABLE_DIRECTMUSIC_SUPPORT |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
55 |
M("dmusic", "DirectMusic MIDI Driver", &_dmusic_midi_driver), |
2222
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
56 |
#endif |
5756
1caf4ff6fadc
(svn r8307) [WinCE] -Fix: for now disable sound and music. That will be done later.
truelight
parents:
5584
diff
changeset
|
57 |
#if defined(WIN32) && !defined(WINCE) |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
58 |
M("win32", "Win32 MIDI Driver", &_win32_music_driver), |
2222
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
59 |
#endif |
2500
92bc404b86ca
(svn r3026) -Fix: [OSX] fixed bug that prevented dedicated servers from compiling (introduced in r3022)
bjarni
parents:
2496
diff
changeset
|
60 |
#if defined(__APPLE__) && !defined(DEDICATED) |
2496
74c42595f8e8
(svn r3022) -feature: [OSX] OSX now uses quicktime to play midi files
bjarni
parents:
2458
diff
changeset
|
61 |
M("qt", "QuickTime MIDI Driver", &_qtime_music_driver), |
74c42595f8e8
(svn r3022) -feature: [OSX] OSX now uses quicktime to play midi files
bjarni
parents:
2458
diff
changeset
|
62 |
#endif |
2222
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
63 |
#ifdef UNIX |
6034
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
5756
diff
changeset
|
64 |
#if defined(LIBTIMIDITY) |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
5756
diff
changeset
|
65 |
M("libtimidity", "LibTimidity MIDI Driver", &_libtimidity_music_driver), |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
5756
diff
changeset
|
66 |
#endif /* LIBTIMIDITY */ |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
5756
diff
changeset
|
67 |
#if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(PSP) |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
68 |
M("extmidi", "External MIDI Driver", &_extmidi_music_driver), |
2222
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
69 |
#endif |
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
70 |
#endif |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
71 |
M("null", "Null Music Driver", &_null_music_driver), |
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
72 |
M(NULL, NULL, NULL) |
2222
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
73 |
}; |
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
74 |
|
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
75 |
static const DriverDesc _sound_driver_descs[] = { |
5756
1caf4ff6fadc
(svn r8307) [WinCE] -Fix: for now disable sound and music. That will be done later.
truelight
parents:
5584
diff
changeset
|
76 |
#if defined(WIN32) && !defined(WINCE) |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
77 |
M("win32", "Win32 WaveOut Driver", &_win32_sound_driver), |
2222
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
78 |
#endif |
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
79 |
#ifdef WITH_SDL |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
80 |
M("sdl", "SDL Sound Driver", &_sdl_sound_driver), |
2222
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
81 |
#endif |
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2500
diff
changeset
|
82 |
#ifdef WITH_COCOA |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2500
diff
changeset
|
83 |
M("cocoa", "Cocoa Sound Driver", &_cocoa_sound_driver), |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2500
diff
changeset
|
84 |
#endif |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
85 |
M("null", "Null Sound Driver", &_null_sound_driver), |
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
86 |
M(NULL, NULL, NULL) |
2222
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
87 |
}; |
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
88 |
|
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
89 |
static const DriverDesc _video_driver_descs[] = { |
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
90 |
#ifdef WIN32 |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
91 |
M("win32", "Win32 GDI Video Driver", &_win32_video_driver), |
2222
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
92 |
#endif |
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
93 |
#ifdef WITH_SDL |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
94 |
M("sdl", "SDL Video Driver", &_sdl_video_driver), |
2222
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
95 |
#endif |
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2500
diff
changeset
|
96 |
#ifdef WITH_COCOA |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2500
diff
changeset
|
97 |
M("cocoa", "Cocoa Video Driver", &_cocoa_video_driver), |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2500
diff
changeset
|
98 |
#endif |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
99 |
M("null", "Null Video Driver", &_null_video_driver), |
2222
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
100 |
#ifdef ENABLE_NETWORK |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
101 |
M("dedicated", "Dedicated Video Driver", &_dedicated_video_driver), |
2222
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
102 |
#endif |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
103 |
M(NULL, NULL, NULL) |
2222
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
104 |
}; |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
105 |
#undef M |
2222
ce4beae3ce18
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
106 |
|
2219
2437978eae8f
(svn r2737) static, const and don't make variables public nobody else needs to know about
tron
parents:
2210
diff
changeset
|
107 |
|
2902
b13a5f9396f6
(svn r3457) -Fix: killed some warnings about strict-alias in an ugly way (but it works ;))
truelight
parents:
2832
diff
changeset
|
108 |
#define M(x, y, z) { x, y, (const HalCommonDriver **)(void *)z } |
2219
2437978eae8f
(svn r2737) static, const and don't make variables public nobody else needs to know about
tron
parents:
2210
diff
changeset
|
109 |
static const DriverClass _driver_classes[] = { |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
110 |
M(_video_driver_descs, "video", &_video_driver), |
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
111 |
M(_sound_driver_descs, "sound", &_sound_driver), |
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
112 |
M(_music_driver_descs, "music", &_music_driver) |
2171
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
113 |
}; |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
114 |
#undef M |
2171
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
115 |
|
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
116 |
static const DriverDesc* GetDriverByName(const DriverDesc* dd, const char* name) |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
117 |
{ |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
118 |
for (; dd->name != NULL; dd++) { |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
119 |
if (strcmp(dd->name, name) == 0) return dd; |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
120 |
} |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
121 |
return NULL; |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
122 |
} |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
123 |
|
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
124 |
void LoadDriver(int driver, const char *name) |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
125 |
{ |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
126 |
const DriverClass *dc = &_driver_classes[driver]; |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
127 |
const DriverDesc *dd; |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
128 |
const char *err; |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
129 |
|
2210
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
130 |
if (*name == '\0') { |
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
131 |
for (dd = dc->descs; dd->name != NULL; dd++) { |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
132 |
err = dd->drv->start(NULL); |
2210
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
133 |
if (err == NULL) break; |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5305
diff
changeset
|
134 |
DEBUG(driver, 1, "Probing %s driver '%s' failed with error: %s", |
2210
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
135 |
dc->name, dd->name, err |
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
136 |
); |
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
137 |
} |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5305
diff
changeset
|
138 |
if (dd->name == NULL) error("Couldn't find any suitable %s driver", dc->name); |
2210
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
139 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5305
diff
changeset
|
140 |
DEBUG(driver, 1, "Successfully probed %s driver '%s'", dc->name, dd->name); |
2210
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
141 |
|
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
142 |
*dc->drv = dd->drv; |
2171
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
143 |
} else { |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
144 |
char* parm; |
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
145 |
char buffer[256]; |
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
146 |
const char* parms[32]; |
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
147 |
|
6125
a6fff965707c
(svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas
parents:
6034
diff
changeset
|
148 |
/* Extract the driver name and put parameter list in parm */ |
2171
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
149 |
ttd_strlcpy(buffer, name, sizeof(buffer)); |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
150 |
parm = strchr(buffer, ':'); |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
151 |
parms[0] = NULL; |
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
152 |
if (parm != NULL) { |
2171
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
153 |
uint np = 0; |
6125
a6fff965707c
(svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas
parents:
6034
diff
changeset
|
154 |
/* Tokenize the parm. */ |
2171
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
155 |
do { |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
156 |
*parm++ = '\0'; |
2171
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
157 |
if (np < lengthof(parms) - 1) |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
158 |
parms[np++] = parm; |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
159 |
while (*parm != '\0' && *parm != ',') |
2171
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
160 |
parm++; |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
161 |
} while (*parm == ','); |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
162 |
parms[np] = NULL; |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
163 |
} |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
164 |
dd = GetDriverByName(dc->descs, buffer); |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
165 |
if (dd == NULL) |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
166 |
error("No such %s driver: %s\n", dc->name, buffer); |
2210
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
167 |
|
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
168 |
if (*dc->drv != NULL) (*dc->drv)->stop(); |
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
169 |
*dc->drv = NULL; |
2210
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
170 |
|
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
171 |
err = dd->drv->start(parms); |
2210
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
172 |
if (err != NULL) { |
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
173 |
error("Unable to load driver %s(%s). The error was: %s\n", |
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
174 |
dd->name, dd->longname, err |
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
175 |
); |
b76184e0929c
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
176 |
} |
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
177 |
*dc->drv = dd->drv; |
2171
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
178 |
} |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
179 |
} |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
180 |
|
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
181 |
|
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
182 |
static const char* GetDriverParam(const char* const* parm, const char* name) |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
183 |
{ |
2458
dbaf5dffbb28
(svn r2984) Use adequate types, this should aid portability a bit
tron
parents:
2303
diff
changeset
|
184 |
size_t len; |
2171
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
185 |
|
2224
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
186 |
if (parm == NULL) return NULL; |
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
187 |
|
af2f147779d3
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
188 |
len = strlen(name); |
2171
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
189 |
for (; *parm != NULL; parm++) { |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
190 |
const char* p = *parm; |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
191 |
|
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
192 |
if (strncmp(p, name, len) == 0) { |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
193 |
if (p[len] == '=') return p + len + 1; |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
194 |
if (p[len] == '\0') return p + len; |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
195 |
} |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
196 |
} |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
197 |
return NULL; |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
198 |
} |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
199 |
|
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
200 |
bool GetDriverParamBool(const char* const* parm, const char* name) |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
201 |
{ |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
202 |
return GetDriverParam(parm, name) != NULL; |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
203 |
} |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
204 |
|
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
205 |
int GetDriverParamInt(const char* const* parm, const char* name, int def) |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
206 |
{ |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
207 |
const char* p = GetDriverParam(parm, name); |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
208 |
return p != NULL ? atoi(p) : def; |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
209 |
} |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
210 |
|
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
211 |
|
5170
817550aa5a5f
(svn r7280) -Codechange: Replace some sprintf() functions with the safer snprintf() functions
Darkvater
parents:
2902
diff
changeset
|
212 |
char *GetDriverList(char* p, const char *last) |
2171
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
213 |
{ |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
214 |
const DriverClass* dc; |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
215 |
|
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
216 |
for (dc = _driver_classes; dc != endof(_driver_classes); dc++) { |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
217 |
const DriverDesc* dd; |
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
218 |
|
5170
817550aa5a5f
(svn r7280) -Codechange: Replace some sprintf() functions with the safer snprintf() functions
Darkvater
parents:
2902
diff
changeset
|
219 |
p += snprintf(p, last - p, "List of %s drivers:\n", dc->name); |
2171
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
220 |
for (dd = dc->descs; dd->name != NULL; dd++) { |
5170
817550aa5a5f
(svn r7280) -Codechange: Replace some sprintf() functions with the safer snprintf() functions
Darkvater
parents:
2902
diff
changeset
|
221 |
p += snprintf(p, last - p, "%10s: %s\n", dd->name, dd->longname); |
2171
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
222 |
} |
5170
817550aa5a5f
(svn r7280) -Codechange: Replace some sprintf() functions with the safer snprintf() functions
Darkvater
parents:
2902
diff
changeset
|
223 |
p = strecpy(p, "\n", last); |
2171
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
224 |
} |
2831
952f77671794
(svn r3379) -Fix: protect showhelp against any possible overflow
truelight
parents:
2736
diff
changeset
|
225 |
|
2832
5a679de4b9f7
(svn r3380) -Fix: removed 'size' from r3379, because it was pretty silly
truelight
parents:
2831
diff
changeset
|
226 |
return p; |
2171
60334c9ca477
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
227 |
} |