Initializes the sound module.
()
| 109 | * Initializes the sound module. |
| 110 | */ |
| 111 | public static void Init() { |
| 112 | |
| 113 | Com.Printf("\n------- sound initialization -------\n"); |
| 114 | |
| 115 | cvar_t cv = Cvar.getInstance().Get("s_initsound", "1", 0); |
| 116 | if (cv.value == 0.0f) { |
| 117 | Com.Printf("not initializing.\n"); |
| 118 | useDriver("dummy"); |
| 119 | return; |
| 120 | } |
| 121 | |
| 122 | // set the last registered driver as default |
| 123 | String defaultDriver = "dummy"; |
| 124 | if (drivers.size() > 1){ |
| 125 | defaultDriver = ((Sound)drivers.lastElement()).getName(); |
| 126 | } |
| 127 | |
| 128 | s_impl = Cvar.getInstance().Get("s_impl", defaultDriver, Defines.CVAR_ARCHIVE); |
| 129 | useDriver(s_impl.string); |
| 130 | |
| 131 | if (impl.Init()) { |
| 132 | // driver ok |
| 133 | Cvar.getInstance().Set("s_impl", impl.getName()); |
| 134 | } else { |
| 135 | // fallback |
| 136 | useDriver("dummy"); |
| 137 | } |
| 138 | |
| 139 | Com.Printf("\n------- use sound driver \"" + impl.getName() + "\" -------\n"); |
| 140 | StopAllSounds(); |
| 141 | } |
| 142 | |
| 143 | public static void Shutdown() { |
| 144 | impl.Shutdown(); |