1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
--- client/snd_main.c.orig Mon Jul 24 15:09:29 2006
+++ client/snd_main.c Mon Jul 24 15:13:16 2006
@@ -24,7 +24,8 @@
#include "snd_local.h"
qBool snd_isActive = qTrue;
-qBool snd_isInitialized;
+qBool snd_isFirstInit = qTrue;
+qBool snd_isInitialized = qFalse;
qBool snd_isDMA;
qBool snd_isAL;
@@ -870,7 +871,7 @@
uint32 initTime;
if (snd_isInitialized)
- Snd_Shutdown ();
+ return;
Com_Printf (0, "\n--------- Sound Initialization ---------\n");
@@ -892,27 +893,44 @@
s_testsound = Cvar_Register ("s_testsound", "0", 0);
s_primary = Cvar_Register ("s_primary", "0", CVAR_ARCHIVE|CVAR_LATCH_AUDIO); // win32 specific
- al_allowExtensions = Cvar_Register ("al_allowExtensions", "1", CVAR_ARCHIVE|CVAR_LATCH_AUDIO);
- al_device = Cvar_Register ("al_device", "", CVAR_ARCHIVE);
- al_dopplerFactor = Cvar_Register ("al_dopplerFactor", "1", CVAR_ARCHIVE);
- al_dopplerVelocity = Cvar_Register ("al_dopplerVelocity", "16384", CVAR_ARCHIVE);
- al_driver = Cvar_Register ("al_driver", AL_DRIVERNAME, CVAR_ARCHIVE|CVAR_LATCH_AUDIO);
- al_errorCheck = Cvar_Register ("al_errorCheck", "1", CVAR_ARCHIVE);
- al_ext_eax2 = Cvar_Register ("al_ext_eax2", "1", CVAR_ARCHIVE|CVAR_LATCH_AUDIO);
- al_gain = Cvar_Register ("al_gain", "5", CVAR_ARCHIVE);
- al_minDistance = Cvar_Register ("al_minDistance", "100", CVAR_ARCHIVE);
- al_maxDistance = Cvar_Register ("al_maxDistance", "8192", CVAR_ARCHIVE);
- al_rollOffFactor = Cvar_Register ("al_rollOffFactor", "0.8", CVAR_ARCHIVE);
+ if (s_initSound->intVal == 2) {
+ al_allowExtensions = Cvar_Register ("al_allowExtensions", "1", CVAR_ARCHIVE|CVAR_LATCH_AUDIO);
+ al_device = Cvar_Register ("al_device", "", CVAR_ARCHIVE);
+ al_dopplerFactor = Cvar_Register ("al_dopplerFactor", "1", CVAR_ARCHIVE);
+ al_dopplerVelocity = Cvar_Register ("al_dopplerVelocity", "16384", CVAR_ARCHIVE);
+ al_driver = Cvar_Register ("al_driver", AL_DRIVERNAME, CVAR_ARCHIVE|CVAR_LATCH_AUDIO);
+ al_errorCheck = Cvar_Register ("al_errorCheck", "1", CVAR_ARCHIVE);
+ al_ext_eax2 = Cvar_Register ("al_ext_eax2", "1", CVAR_ARCHIVE|CVAR_LATCH_AUDIO);
+ al_gain = Cvar_Register ("al_gain", "5", CVAR_ARCHIVE);
+ al_minDistance = Cvar_Register ("al_minDistance", "100", CVAR_ARCHIVE);
+ al_maxDistance = Cvar_Register ("al_maxDistance", "8192", CVAR_ARCHIVE);
+ al_rollOffFactor = Cvar_Register ("al_rollOffFactor", "0.8", CVAR_ARCHIVE);
+ }
+
+ /*
+ * We need to keep the snd_restart command even if the sound subsystem
+ * is not started, because there has to be a way to start it.
+ */
+ if (snd_isFirstInit) {
+ cmd_snd_restart = Cmd_AddCommand ("snd_restart", Snd_Restart_f, "Restarts the audio subsystem");
+ snd_isFirstInit = qFalse;
+ }
- cmd_snd_restart = Cmd_AddCommand ("snd_restart", Snd_Restart_f, "Restarts the audio subsystem");
cmd_play = Cmd_AddCommand ("play", Snd_Play_f, "Plays a sound");
cmd_stopSound = Cmd_AddCommand ("stopsound", Snd_StopAllSounds, "Stops all currently playing sounds");
cmd_soundList = Cmd_AddCommand ("soundlist", Snd_SoundList_f, "Prints out a list of loaded sound files");
cmd_soundInfo = Cmd_AddCommand ("soundinfo", Snd_SoundInfo_f, "Prints out information on sound subsystem");
+ /*
+ * Make Snd_Shutdown() abort the startup if necessary (it quits when
+ * the subsystem is not initialized, so make it think the opposite).
+ */
+ snd_isInitialized = qTrue;
+
if (!s_initSound->intVal) {
Com_Printf (0, "...not initializing\n");
Com_Printf (0, "----------------------------------------\n");
+ Snd_Shutdown();
return;
}
@@ -927,13 +945,13 @@
}
}
if (!snd_isAL) {
- if (!DMASnd_Init())
+ if (!DMASnd_Init()) {
+ Snd_Shutdown();
return;
+ }
snd_isDMA = qTrue;
}
- snd_isInitialized = qTrue;
-
Snd_StopAllSounds ();
Com_Printf (0, "----------------------------------------\n");
@@ -955,18 +973,19 @@
{
uint32 size;
- Cmd_RemoveCommand ("snd_restart", cmd_snd_restart);
+ if (!snd_isInitialized)
+ return;
+
Cmd_RemoveCommand ("play", cmd_play);
Cmd_RemoveCommand ("stopsound", cmd_stopSound);
Cmd_RemoveCommand ("soundlist", cmd_soundList);
Cmd_RemoveCommand ("soundinfo", cmd_soundInfo);
- if (!snd_isInitialized)
- return;
- snd_isInitialized = qFalse;
-
Com_Printf (0, "\n------------ Sound Shutdown ------------\n");
+ // Stop all sounds
+ Snd_StopAllSounds();
+
// Free all sounds
Snd_FreeSounds ();
@@ -984,6 +1003,8 @@
ALSnd_Shutdown ();
snd_isAL = qFalse;
}
+
+ snd_isInitialized = qFalse;
Com_Printf (0, "----------------------------------------\n");
}
|