Debian Codegraph @

sndlib/sdlsound.cpp

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include <algorithm>
20 #include <cstdio>
21 #include <cstdlib>
22 #include <cstdarg>
23
24 #include <SDL.h>
25
26 #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/
27 #include "mem.h"cxx . . $ `<file>/mem/mem.h`/
28 #include "mono.h"cxx . . $ `<file>/ddebug/mono.h`/
29 #include "ssl_lib.h"cxx . . $ `<file>/sndlib/ssl_lib.h`/
30 #include "application.h"cxx . . $ `<file>/lib/application.h`/
31 #include "sdlsound.h"cxx . . $ `<file>/sndlib/sdlsound.h`/
32 #include "mixer.h"cxx . . $ `<file>/sndlib/mixer.h`/
33 #include "ddio.h"cxx . . $ `<file>/ddio/ddio.h`/
34 #include "args.h"cxx . . $ `<file>/Descent3/args.h`/
35
36 #define SOUNDLIB_SAMPLE_RATEcxx . . $ `sndlib/sdlsound.cpp:36:9`! 22050
37 #define SOUNDLIB_SAMPLE_SIZEcxx . . $ `sndlib/sdlsound.cpp:37:9`! 16
38 #define SOUNDLIB_CHANNELScxx . . $ `sndlib/sdlsound.cpp:38:9`! 2
39 #define SOUNDLIB_DEFAULT_SAMPLEScxx . . $ `sndlib/sdlsound.cpp:39:9`! 1024
40
41 // ===============================
42 #define MAX_SOUNDS_PLAYING_AT_ONCEcxx . . $ `sndlib/sdlsound.cpp:42:9`! 256
43 static sound_buffer_infocxx . . $ sound_buffer_info# sound_cachecxx . . $ sound_cache.[MAX_SOUNDS_PLAYING_AT_ONCEcxx . . $ `sndlib/sdlsound.cpp:42:9`!];
44 static int sound_buffer_sizecxx . . $ sound_buffer_size. = MAX_SOUNDS_PLAYING_AT_ONCEcxx . . $ `sndlib/sdlsound.cpp:42:9`!;
45
46 lnxsoundcxx . . $ lnxsound# *ll_sound_ptrcxx . . $ ll_sound_ptr.;
47
48 // A peroidic mixer that uses the primary buffer as a stream buffer
49 static void StreamAudiocxx . . $ StreamAudio(c52f2c8079c5ae6).(void *user_ptr, Uint8cxx . . $ Uint8# *stream, int len);
50
51 lnxsoundcxx . . $ lnxsound#::lnxsoundcxx . . $ lnxsound#lnxsound(49f6e7a06ebc5aa8).() : llsSystemcxx . . $ llsSystem#() {
52 ll_sound_ptrcxx . . $ ll_sound_ptr. = this;
53 sound_devicecxx . . $ lnxsound#sound_device. = 0;
54 in_at_exitcxx . . $ lnxsound#in_at_exit. = false;
55 }
56
57 lnxsoundcxx . . $ lnxsound#::~cxx . . $ lnxsound#`~lnxsound`(ced63f7c635d850d).lnxsoundcxx . . $ lnxsound#() {
58 in_at_exitcxx . . $ lnxsound#in_at_exit. = true;
59 DestroySoundLibcxx . . $ lnxsound#DestroySoundLib(49f6e7a06ebc5aa8).();
60 SetSoundCardcxx . . $ lnxsound#SetSoundCard(85c52e162fed56f9).(nullptr);
61 }
62
63 // Starts the sound library, maybe have it send back some information -- 3d support?
64 int lnxsoundcxx . . $ lnxsound#::InitSoundLibcxx . . $ lnxsound#InitSoundLib(964874524976ed1).(char mixer_type, oeApplicationcxx . . $ oeApplication# *sos, uint8_tcxx . . $ uint8_t# max_sounds_played) {
65 SDL_AudioSpec spec;
66
67 // setup mixer
68 tMixerInitcxx . . $ tMixerInit# mi;
69 mi.primary_buffercxx . . $ tMixerInit#primary_buffer. = nullptr;
70 mi.primary_frequencycxx . . $ tMixerInit#primary_frequency. = SOUNDLIB_SAMPLE_RATEcxx . . $ `sndlib/sdlsound.cpp:36:9`!;
71 mi.max_sounds_availablecxx . . $ tMixerInit#max_sounds_available. = &sound_buffer_sizecxx . . $ sound_buffer_size.;
72 mi.sound_cachecxx . . $ tMixerInit#sound_cache. = sound_cachecxx . . $ sound_cache.;
73 mi.primary_alignmentcxx . . $ tMixerInit#primary_alignment. = SOUNDLIB_CHANNELScxx . . $ `sndlib/sdlsound.cpp:38:9`! * (SOUNDLIB_SAMPLE_SIZEcxx . . $ `sndlib/sdlsound.cpp:37:9`! >> 3);
74 mi.fp_SetErrorcxx . . $ tMixerInit#fp_SetError. = lnxsound_SetErrorcxx . . $ lnxsound_SetError(d4f767463ce0a6b3).;
75 mi.fp_ErrorTextcxx . . $ tMixerInit#fp_ErrorText. = lnxsound_ErrorTextcxx . . $ lnxsound_ErrorText(326aeb464d16410c).;
76 mi.p_error_codecxx . . $ tMixerInit#p_error_code. = &m_lib_error_codecxx . . $ llsSystem#m_lib_error_code.;
77 mi.ll_sound_ptrcxx . . $ tMixerInit#ll_sound_ptr. = ll_sound_ptrcxx . . $ ll_sound_ptr.;
78
79 if (!m_mixercxx . . $ lnxsound#m_mixer..Initializecxx . . $ software_mixer#Initialize(f98e0e26c84ad24b).(&mi)) {
80 return false;
81 } // if
82
83 int sampleCount = SOUNDLIB_DEFAULT_SAMPLEScxx . . $ `sndlib/sdlsound.cpp:39:9`!;
84 int sampleArgIndex = FindArgcxx . . $ FindArg(5c4306d8553b3696).("-sdlSndSize");
85 if (sampleArgIndex != 0) {
86 const char *sampleCountStr = GetArgcxx . . $ GetArg(f7ae7e56280f18ae).(sampleArgIndex + 1);
87 if (sampleCountStr) {
88 sampleCount = atoicxx . . $ atoi(f5ecf3191ed0cd93).(sampleCountStr);
89 if (sampleCount <= 0) {
90 sampleCount = SOUNDLIB_DEFAULT_SAMPLEScxx . . $ `sndlib/sdlsound.cpp:39:9`!;
91 }
92 }
93 }
94
95 spec.freq = SOUNDLIB_SAMPLE_RATEcxx . . $ `sndlib/sdlsound.cpp:36:9`!;
96 spec.format = SOUNDLIB_SAMPLE_SIZEcxx . . $ `sndlib/sdlsound.cpp:37:9`! == 8 ? AUDIO_U8cxx . . $ `<external>/178947386371380387/SDL_audio.h:91:9`! : AUDIO_S16SYScxx . . $ `<external>/178947386371380387/SDL_audio.h:125:9`!;
97 spec.channels = SOUNDLIB_CHANNELScxx . . $ `sndlib/sdlsound.cpp:38:9`!;
98 spec.samples = sampleCount;
99 spec.callback = StreamAudiocxx . . $ StreamAudio(c52f2c8079c5ae6).;
100 spec.userdata = &m_mixercxx . . $ lnxsound#m_mixer.;
101
102 sound_devicecxx . . $ lnxsound#sound_device. = SDL_OpenAudioDevice(nullptr, 0, &spec, nullptr, 0);
103 if (sound_devicecxx . . $ lnxsound#sound_device. == 0) {
104 strcpy(m_error_textcxx . . $ llsSystem#m_error_text., SDL_GetError());
105 return false;
106 }
107
108 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Sound: Hardware configured. Kicking off stream thread...");
109 SDL_PauseAudioDevice(sound_devicecxx . . $ lnxsound#sound_device., 0);
110
111 m_total_sounds_playedcxx . . $ lnxsound#m_total_sounds_played. = 0;
112 m_cur_sounds_playedcxx . . $ lnxsound#m_cur_sounds_played. = 0;
113 m_in_sound_framecxx . . $ lnxsound#m_in_sound_frame. = false;
114 m_pending_actionscxx . . $ lnxsound#m_pending_actions. = false;
115 m_cache_stress_timercxx . . $ lnxsound#m_cache_stress_timer. = 0.0f;
116 m_timer_last_frametimecxx . . $ lnxsound#m_timer_last_frametime. = -1;
117 m_sound_qualitycxx . . $ lnxsound#m_sound_quality. = SQT_HIGHcxx . . $ `sndlib/ssl_lib.h:352:9`!;
118
119 return true;
120 }
121
122 bool lnxsoundcxx . . $ lnxsound#::GetDeviceSettingscxx . . $ lnxsound#GetDeviceSettings(23ffcdbfb576de00).(SDL_AudioDeviceID *device, uint32_tcxx . . $ uint32_t# *freq, uint32_tcxx . . $ uint32_t# *bit_depth,
123 uint32_tcxx . . $ uint32_t# *channels) const {
124 if (sound_devicecxx . . $ lnxsound#sound_device. == 0)
125 return false;
126
127 *device = sound_devicecxx . . $ lnxsound#sound_device.;
128 *freq = SOUNDLIB_SAMPLE_RATEcxx . . $ `sndlib/sdlsound.cpp:36:9`!;
129 *bit_depth = SOUNDLIB_SAMPLE_SIZEcxx . . $ `sndlib/sdlsound.cpp:37:9`!;
130 *channels = SOUNDLIB_CHANNELScxx . . $ `sndlib/sdlsound.cpp:38:9`!;
131
132 return true;
133 }
134
135 // Cleans up after the Sound Library
136 void lnxsoundcxx . . $ lnxsound#::DestroySoundLibcxx . . $ lnxsound#DestroySoundLib(49f6e7a06ebc5aa8).() {
137 if (sound_devicecxx . . $ lnxsound#sound_device.) {
138 SDL_CloseAudioDevice(sound_devicecxx . . $ lnxsound#sound_device.);
139 sound_devicecxx . . $ lnxsound#sound_device. = 0;
140 }
141 }
142
143 // Locks and unlocks sounds (used when changing play_info data)
144 bool lnxsoundcxx . . $ lnxsound#::LockSoundcxx . . $ lnxsound#LockSound(83c267b20bac841a).(int sound_uid) { return false; }
145
146 bool lnxsoundcxx . . $ lnxsound#::UnlockSoundcxx . . $ lnxsound#UnlockSound(83c267b20bac841a).(int sound_uid) { return false; }
147
148 bool lnxsoundcxx . . $ lnxsound#::SetSoundQualitycxx . . $ lnxsound#SetSoundQuality(b5fd09639b7a0261).(char quality) {
149 int i;
150
151 if (quality == m_sound_qualitycxx . . $ lnxsound#m_sound_quality.)
152 return true;
153
154 // pause any sounds that may be playing
155 PauseSoundscxx . . $ lnxsound#PauseSounds(49f6e7a06ebc5aa8).();
156
157 if (quality == SQT_NORMALcxx . . $ `sndlib/ssl_lib.h:351:9`!) {
158 m_sound_qualitycxx . . $ lnxsound#m_sound_quality. = SQT_NORMALcxx . . $ `sndlib/ssl_lib.h:351:9`!;
159 } else {
160 m_sound_qualitycxx . . $ lnxsound#m_sound_quality. = SQT_HIGHcxx . . $ `sndlib/ssl_lib.h:352:9`!;
161 }
162
163 for (i = 0; i < MAX_SOUNDScxx . . $ `sndlib/ssl_lib.h:578:9`!; i++) {
164 if (Soundscxx . . $ Sounds.[i].usedcxx . . $ sound_info#used. != 0) {
165 int j = Soundscxx . . $ Sounds.[i].sample_indexcxx . . $ sound_info#sample_index.;
166
167 if (SoundFilescxx . . $ SoundFiles.[j].sample_8bitcxx . . $ sound_file_info#sample_8bit. && m_sound_qualitycxx . . $ lnxsound#m_sound_quality. == SQT_HIGHcxx . . $ `sndlib/ssl_lib.h:352:9`!) {
168 mem_freecxx . . $ `mem/mem.h:80:9`!(SoundFiles[j].sample_8bit);
169 SoundFilescxx . . $ SoundFiles.[j].sample_8bitcxx . . $ sound_file_info#sample_8bit. = nullptr;
170
171 CheckAndForceSoundDataAlloccxx . . $ lnxsound#CheckAndForceSoundDataAlloc(83c267b20bac841a).(i);
172 }
173 if (SoundFilescxx . . $ SoundFiles.[j].sample_16bitcxx . . $ sound_file_info#sample_16bit. && m_sound_qualitycxx . . $ lnxsound#m_sound_quality. == SQT_NORMALcxx . . $ `sndlib/ssl_lib.h:351:9`!) {
174 int count;
175
176 ASSERTcxx . . $ `misc/pserror.h:246:9`!(SoundFiles[j].sample_8bit == nullptr);
177 SoundFilescxx . . $ SoundFiles.[j].sample_8bitcxx . . $ sound_file_info#sample_8bit. = (uint8_tcxx . . $ uint8_t# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(SoundFiles[j].sample_length);
178
179 // NOTE: Interesting note on sound conversion: 16 bit sounds are signed (0 biase). 8 bit sounds are unsigned
180 // (+128 biase).
181 for (count = 0; count < (int)SoundFilescxx . . $ SoundFiles.[j].sample_lengthcxx . . $ sound_file_info#sample_length.; count++) {
182 SoundFilescxx . . $ SoundFiles.[j].sample_8bitcxx . . $ sound_file_info#sample_8bit.[count] = (uint8_tcxx . . $ uint8_t#)((((int)SoundFilescxx . . $ SoundFiles.[j].sample_16bitcxx . . $ sound_file_info#sample_16bit.[count]) + 32767) >> 8);
183 }
184
185 mem_freecxx . . $ `mem/mem.h:80:9`!(SoundFiles[j].sample_16bit);
186 SoundFilescxx . . $ SoundFiles.[j].sample_16bitcxx . . $ sound_file_info#sample_16bit. = nullptr;
187 }
188 }
189 }
190
191 ResumeSoundscxx . . $ lnxsound#ResumeSounds(49f6e7a06ebc5aa8).();
192
193 return true;
194 }
195
196 char lnxsoundcxx . . $ lnxsound#::GetSoundQualitycxx . . $ lnxsound#GetSoundQuality(6e9c618e4dd2eafc).() { return m_sound_qualitycxx . . $ lnxsound#m_sound_quality.; }
197
198 bool lnxsoundcxx . . $ lnxsound#::SetSoundMixercxx . . $ lnxsound#SetSoundMixer(b5fd09639b7a0261).(char mixer_type) { return true; }
199
200 char lnxsoundcxx . . $ lnxsound#::GetSoundMixercxx . . $ lnxsound#GetSoundMixer(6e9c618e4dd2eafc).() { return SOUND_MIXER_SOFTWARE_16cxx . . $ `sndlib/ssl_lib.h:342:9`!; }
201
202 // Determines if a sound will play. Takes into account maximum allowable
203 // sounds.
204 // Also put prioritization code in here
205 // ignore reserved slots
206 #ifdef _DEBUGcxx . . $ `<built-in>:480:9`!
207 int16_t lnxsoundcxx . . $ lnxsound#::FindFreeSoundSlotcxx . . $ lnxsound#FindFreeSoundSlot(1685579755b59590).(int sound_index, float volume, int priority)
208 #else
209 int16_t lnxsound::FindFreeSoundSlot(float volume, int priority)
210 #endif
211 {
212 int current_slot;
213 sound_buffer_infocxx . . $ sound_buffer_info# *sb;
214
215 for (current_slot = 0; current_slot < MAX_SOUNDS_PLAYING_AT_ONCEcxx . . $ `sndlib/sdlsound.cpp:42:9`!; current_slot++) {
216 sb = &sound_cachecxx . . $ sound_cache.[current_slot];
217 if (sb->m_statuscxx . . $ sound_buffer_info#m_status. == SSF_UNUSEDcxx . . $ `sndlib/ssl_lib.h:416:9`!) {
218 return current_slot;
219 }
220 }
221
222 // no more slots? take priority into account.
223 // throw out lowest priority sound slot (must be lower than or equal to new sound priority)
224 float weighted_priority = (priority * 2.0f) * volume;
225 if (current_slot == MAX_SOUNDS_PLAYING_AT_ONCEcxx . . $ `sndlib/sdlsound.cpp:42:9`!) {
226 int throw_out_slot = -1, equiv_priority_slot = -1;
227 float weighted_priorityA, weighted_priorityB;
228 for (current_slot = 0; current_slot < MAX_SOUNDS_PLAYING_AT_ONCEcxx . . $ `sndlib/sdlsound.cpp:42:9`!; current_slot++) {
229 sb = &sound_cachecxx . . $ sound_cache.[current_slot];
230 if (!(sb->m_statuscxx . . $ sound_buffer_info#m_status. & (SSF_PLAY_LOOPINGcxx . . $ `sndlib/ssl_lib.h:418:9`! + SSF_PLAY_STREAMINGcxx . . $ `sndlib/ssl_lib.h:420:9`!))) {
231 weighted_priorityA = sb->play_infocxx . . $ sound_buffer_info#play_info.->prioritycxx . . $ play_information#priority. * 2.0f * sb->m_volumecxx . . $ sound_buffer_info#m_volume.;
232 if (weighted_priorityA < weighted_priority) {
233 if (throw_out_slot == -1) {
234 throw_out_slot = current_slot;
235 } else {
236 play_informationcxx . . $ play_information# *play_info2 = sound_cachecxx . . $ sound_cache.[throw_out_slot].play_infocxx . . $ sound_buffer_info#play_info.;
237 weighted_priorityB = play_info2->prioritycxx . . $ play_information#priority. * 2.0f * sb->m_volumecxx . . $ sound_buffer_info#m_volume.;
238 if (weighted_priorityB > weighted_priorityA) {
239 throw_out_slot = current_slot;
240 }
241 }
242 }
243
244 else if (equiv_priority_slot == -1 && weighted_priorityA == weighted_priority) {
245 equiv_priority_slot = current_slot;
246 }
247 }
248 }
249
250 // if no slot found to stop, look for a slot with priority == new priority
251 if (throw_out_slot == -1) {
252 throw_out_slot = equiv_priority_slot;
253 }
254 if (throw_out_slot > -1) {
255 sb = &sound_cachecxx . . $ sound_cache.[throw_out_slot];
256 StopSoundcxx . . $ lnxsound#StopSound(9633529ce3c4ff50).(sb->m_unique_idcxx . . $ sound_buffer_info#m_unique_id., SKT_HOLD_UNTIL_STOPcxx . . $ `sndlib/ssl_lib.h:407:9`!);
257 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "DDSNDLIB: Replace sound (p:%d) with sound (p:%d) in slot %d\n", sb->play_info->priority, priority,
258 throw_out_slot);
259 return throw_out_slot;
260 }
261 }
262
263 #ifdef _DEBUGcxx . . $ `<built-in>:480:9`!
264 if (sound_index > -1) {
265 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "DDSNDLIB: Sound %s with priority (%d) too low.\n", Sounds[sound_index].name, priority);
266 } else {
267 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "DDSNDLIB: Sound unknown with priority (%d) too low.\n", priority);
268 }
269 #endif
270 return -1;
271 }
272
273 // Plays a 2d sound
274 int lnxsoundcxx . . $ lnxsound#::PlaySound2dcxx . . $ lnxsound#PlaySound2d(8751acdd249a09c0).(play_informationcxx . . $ play_information# *play_info, int sound_index, float f_volume, float f_pan, bool f_looped) {
275 sound_buffer_infocxx . . $ sound_buffer_info# *sb;
276 int16_t sound_slot;
277
278 if (sound_devicecxx . . $ lnxsound#sound_device. == 0) {
279 return -1;
280 }
281
282 // calculate volume and pan
283 f_volume = (f_volume < 0.0f) ? 0.0f : (f_volume > 1.0f) ? 1.0f : f_volume;
284 play_info->left_volumecxx . . $ play_information#left_volume. = play_info->right_volumecxx . . $ play_information#right_volume. = f_volume;
285
286 f_pan = (f_pan < -1.0f) ? -1.0f : (f_pan > 1.0f) ? 1.0f : f_pan;
287 if (f_pan < 0.0) {
288 play_info->right_volumecxx . . $ play_information#right_volume. += f_volume * f_pan;
289 } else {
290 play_info->left_volumecxx . . $ play_information#left_volume. -= f_volume * f_pan;
291 }
292
293 // do common processing.
294 if (SoundFilescxx . . $ SoundFiles.[Soundscxx . . $ Sounds.[sound_index].sample_indexcxx . . $ sound_info#sample_index.].usedcxx . . $ sound_file_info#used. == 0) {
•295 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Tried to play %d sound, it DNE.\n", sound_index);
296 return -1;
297 }
298 #ifdef _DEBUGcxx . . $ `<built-in>:480:9`!
299 sound_slot = FindFreeSoundSlotcxx . . $ lnxsound#FindFreeSoundSlot(1685579755b59590).(sound_index, f_volume, play_info->prioritycxx . . $ play_information#priority.);
300 #else
301 sound_slot = FindFreeSoundSlot(f_volume, play_info->priority);
302 #endif
303 if (sound_slot < 0) {
304 // do prioritization code here.
305 return -1;
306 }
307 sb = &sound_cachecxx . . $ sound_cache.[sound_slot];
308 m_total_sounds_playedcxx . . $ lnxsound#m_total_sounds_played.++;
309 sb->play_infocxx . . $ sound_buffer_info#play_info. = play_info;
310 sb->m_unique_idcxx . . $ sound_buffer_info#m_unique_id. = MakeUniqueIdcxx . . $ lnxsound#MakeUniqueId(7ccb52b1bfe01045).(sound_slot);
311 sb->m_buffer_typecxx . . $ sound_buffer_info#m_buffer_type. = SBT_2Dcxx . . $ `sndlib/ssl_lib.h:425:9`!;
312 sb->m_sound_indexcxx . . $ sound_buffer_info#m_sound_index. = sound_index;
313 sb->m_statuscxx . . $ sound_buffer_info#m_status. = SSF_UNUSEDcxx . . $ `sndlib/ssl_lib.h:416:9`!;
314
315 ASSERTcxx . . $ `misc/pserror.h:246:9`!(sb->m_unique_id != -1);
316
317 // play 2d sound
318 sb->m_statuscxx . . $ sound_buffer_info#m_status. = (f_looped) ? SSF_PLAY_LOOPINGcxx . . $ `sndlib/ssl_lib.h:418:9`! : SSF_PLAY_NORMALcxx . . $ `sndlib/ssl_lib.h:417:9`!;
319 return sb->m_unique_idcxx . . $ sound_buffer_info#m_unique_id.;
320 }
321
322 // This function limits the number of sounds cached to 255(8bits) and 256 bit is for invalid channel
323 // The purpose is to create unique signatures for each sound played (and allow for
324 // the slot_number to be quickly determined)
325 inline int lnxsoundcxx . . $ lnxsound#::MakeUniqueIdcxx . . $ lnxsound#MakeUniqueId(7ccb52b1bfe01045).(int sound_slot) const { return ((((int)m_total_sounds_playedcxx . . $ lnxsound#m_total_sounds_played.) << 8) + sound_slot); }
326
327 inline int lnxsoundcxx . . $ lnxsound#::ValidateUniqueIdcxx . . $ lnxsound#ValidateUniqueId(7864480464b09eea).(int sound_uid) {
328 if (sound_uid == sound_cachecxx . . $ sound_cache.[sound_uid & 0x00FF].m_unique_idcxx . . $ sound_buffer_info#m_unique_id.) {
329 return sound_uid & 0x00FF;
330 } else {
331 return -1;
332 }
333 }
334
335 int lnxsoundcxx . . $ lnxsound#::PlayStreamcxx . . $ lnxsound#PlayStream(c3f562479373c168).(play_informationcxx . . $ play_information# *play_info) {
336 int16_t sound_slot;
337
338 ASSERTcxx . . $ `misc/pserror.h:246:9`!(play_info != nullptr);
339
340 float volume = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(play_info->left_volumecxx . . $ play_information#left_volume., play_info->right_volumecxx . . $ play_information#right_volume.);
341
342 if (sound_devicecxx . . $ lnxsound#sound_device. == 0)
343 return -1;
344
345 #ifdef _DEBUGcxx . . $ `<built-in>:480:9`!
346 sound_slot = FindFreeSoundSlotcxx . . $ lnxsound#FindFreeSoundSlot(1685579755b59590).(-1, volume, play_info->prioritycxx . . $ play_information#priority.);
347 #else
348 sound_slot = FindFreeSoundSlot(volume, play_info->priority);
349 #endif
350 // Out of sound slots
351 if (sound_slot < 0) {
352 return -1;
353 }
354
355 m_total_sounds_playedcxx . . $ lnxsound#m_total_sounds_played.++;
356 sound_cachecxx . . $ sound_cache.[sound_slot].play_infocxx . . $ sound_buffer_info#play_info. = play_info;
357
358 sound_cachecxx . . $ sound_cache.[sound_slot].m_unique_idcxx . . $ sound_buffer_info#m_unique_id. = MakeUniqueIdcxx . . $ lnxsound#MakeUniqueId(7ccb52b1bfe01045).(sound_slot);
359 ASSERTcxx . . $ `misc/pserror.h:246:9`!(sound_cache[sound_slot].m_unique_id != -1);
360
361 sound_cachecxx . . $ sound_cache.[sound_slot].m_buffer_typecxx . . $ sound_buffer_info#m_buffer_type. = SBT_2Dcxx . . $ `sndlib/ssl_lib.h:425:9`!;
362 sound_cachecxx . . $ sound_cache.[sound_slot].m_statuscxx . . $ sound_buffer_info#m_status. = SSF_PLAY_STREAMINGcxx . . $ `sndlib/ssl_lib.h:420:9`!;
363
364 m_cur_sounds_playedcxx . . $ lnxsound#m_cur_sounds_played.++;
365
366 return (sound_cachecxx . . $ sound_cache.[sound_slot].m_unique_idcxx . . $ sound_buffer_info#m_unique_id.);
367 }
368
369 void lnxsoundcxx . . $ lnxsound#::SetListenercxx . . $ lnxsound#SetListener(c7791b6699e1fa9e).(pos_statecxx . . $ pos_state# *cur_pos) {
370 if (sound_devicecxx . . $ lnxsound#sound_device. == 0)
371 return;
372
373 m_emulated_listenercxx . . $ lnxsound#m_emulated_listener..orientcxx . . $ emulated_listener#orient. =cxx . . $ matrix#`operator=`(4c6f8b29806742). *cur_pos->orientcxx . . $ pos_state#orient.;
374 m_emulated_listenercxx . . $ lnxsound#m_emulated_listener..positioncxx . . $ emulated_listener#position. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). *cur_pos->positioncxx . . $ pos_state#position.;
375 m_emulated_listenercxx . . $ lnxsound#m_emulated_listener..velocitycxx . . $ emulated_listener#velocity. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). *cur_pos->velocitycxx . . $ pos_state#velocity.;
376 }
377
378 int lnxsoundcxx . . $ lnxsound#::PlaySound3dcxx . . $ lnxsound#PlaySound3d(112e06fe9f197cc1).(play_informationcxx . . $ play_information# *play_info, int sound_index, pos_statecxx . . $ pos_state# *cur_pos, float adjusted_volume,
379 bool f_looped, float reverb) //, uint16_t frequency
380 {
381 float volume = adjusted_volume; // Adjust base volume by sent volume, let 3d stuff do the rest
382
383 if (sound_devicecxx . . $ lnxsound#sound_device. == 0)
384 return -1;
385
386 ASSERTcxx . . $ `misc/pserror.h:246:9`!(Sounds[sound_index].used != 0);
387 if (Soundscxx . . $ Sounds.[sound_index].usedcxx . . $ sound_info#used. == 0)
388 return -1;
389
390 float dist;
391 vectorcxx . . $ vector# dir_to_sound = *cur_pos->positioncxx . . $ pos_state#position. -cxx . . $ operator-(b77b703cd1e43e33). m_emulated_listenercxx . . $ lnxsound#m_emulated_listener..positioncxx . . $ emulated_listener#position.;
392 float pan;
393
394 dist = vm_NormalizeVectorcxx . . $ vm_NormalizeVector(4939a7e530383cd4).(&dir_to_sound);
395 if (dist < .1f) {
396 dir_to_sound =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). m_emulated_listenercxx . . $ lnxsound#m_emulated_listener..orientcxx . . $ emulated_listener#orient..fveccxx . . $ matrix#fvec.;
397 }
398
399 if (dist >= Soundscxx . . $ Sounds.[sound_index].max_distancecxx . . $ sound_info#max_distance.) {
400 return -1;
401 } else if (dist > Soundscxx . . $ Sounds.[sound_index].min_distancecxx . . $ sound_info#min_distance.) {
402 volume *= (1.0f - ((dist - Soundscxx . . $ Sounds.[sound_index].min_distancecxx . . $ sound_info#min_distance.) /
403 (Soundscxx . . $ Sounds.[sound_index].max_distancecxx . . $ sound_info#max_distance. - Soundscxx . . $ Sounds.[sound_index].min_distancecxx . . $ sound_info#min_distance.)));
404 }
405
406 pan = (dir_to_sound *cxx . . $ `operator*`(4a721543d64e126a). m_emulated_listenercxx . . $ lnxsound#m_emulated_listener..orientcxx . . $ emulated_listener#orient..rveccxx . . $ matrix#rvec.);
407
408 if (volume < 0.0f)
409 volume = 0.0f;
410 else if (volume > 1.0f)
411 volume = 1.0f;
412
413 if (pan < -1.0f)
414 pan = -1.0f;
415 else if (pan > 1.0f)
416 pan = 1.0f;
417
418 return PlaySound2dcxx . . $ lnxsound#PlaySound2d(8751acdd249a09c0).(play_info, sound_index, volume, pan, f_looped);
419 }
420
421 void lnxsoundcxx . . $ lnxsound#::AdjustSoundcxx . . $ lnxsound#AdjustSound(96ebaef3518743f8).(int sound_uid, float f_volume, float f_pan, uint16_tcxx . . $ uint16_t# frequency) {
422 int current_slot;
423
424 if (sound_devicecxx . . $ lnxsound#sound_device. == 0)
425 return;
426
427 if ((current_slot = ValidateUniqueIdcxx . . $ lnxsound#ValidateUniqueId(7864480464b09eea).(sound_uid)) == -1)
428 return;
429 if (sound_cachecxx . . $ sound_cache.[current_slot].m_statuscxx . . $ sound_buffer_info#m_status. == SSF_UNUSEDcxx . . $ `sndlib/ssl_lib.h:416:9`!)
430 return;
431
432 sound_buffer_infocxx . . $ sound_buffer_info# *sb = &sound_cachecxx . . $ sound_cache.[current_slot];
433 play_informationcxx . . $ play_information# *play_info = sb->play_infocxx . . $ sound_buffer_info#play_info.;
434
435 play_info->left_volumecxx . . $ play_information#left_volume. = play_info->right_volumecxx . . $ play_information#right_volume. = f_volume;
436 if (f_pan < 0.0)
437 play_info->right_volumecxx . . $ play_information#right_volume. += f_volume * f_pan;
438 else
439 play_info->left_volumecxx . . $ play_information#left_volume. -= f_volume * f_pan;
440 }
441
442 void lnxsoundcxx . . $ lnxsound#::AdjustSoundcxx . . $ lnxsound#AdjustSound(f041466fe69f6310).(int sound_uid, pos_statecxx . . $ pos_state# *cur_pos, float adjusted_volume, float reverb) {
443 if (sound_devicecxx . . $ lnxsound#sound_device. == 0)
444 return;
445
446 int current_slot;
447
448 if ((current_slot = ValidateUniqueIdcxx . . $ lnxsound#ValidateUniqueId(7864480464b09eea).(sound_uid)) == -1)
449 return;
450 if (sound_cachecxx . . $ sound_cache.[current_slot].m_statuscxx . . $ sound_buffer_info#m_status. == SSF_UNUSEDcxx . . $ `sndlib/ssl_lib.h:416:9`!)
451 return;
452
453 // We need to determine the pan and volume
454 float volume;
455
456 volume = adjusted_volume;
457
458 float dist;
459 vectorcxx . . $ vector# dir_to_sound = *cur_pos->positioncxx . . $ pos_state#position. -cxx . . $ operator-(b77b703cd1e43e33). m_emulated_listenercxx . . $ lnxsound#m_emulated_listener..positioncxx . . $ emulated_listener#position.;
460 float pan;
461
462 dist = vm_NormalizeVectorcxx . . $ vm_NormalizeVector(4939a7e530383cd4).(&dir_to_sound);
463 if (dist < .1f) {
464 dir_to_sound =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). m_emulated_listenercxx . . $ lnxsound#m_emulated_listener..orientcxx . . $ emulated_listener#orient..fveccxx . . $ matrix#fvec.;
465 }
466
467 if (dist >= Soundscxx . . $ Sounds.[sound_cachecxx . . $ sound_cache.[current_slot].m_sound_indexcxx . . $ sound_buffer_info#m_sound_index.].max_distancecxx . . $ sound_info#max_distance.) {
468 volume = 0.0f;
469 } else if (dist > Soundscxx . . $ Sounds.[sound_cachecxx . . $ sound_cache.[current_slot].m_sound_indexcxx . . $ sound_buffer_info#m_sound_index.].min_distancecxx . . $ sound_info#min_distance.) {
470 volume *= (1.0f - ((dist - Soundscxx . . $ Sounds.[sound_cachecxx . . $ sound_cache.[current_slot].m_sound_indexcxx . . $ sound_buffer_info#m_sound_index.].min_distancecxx . . $ sound_info#min_distance.) /
471 (Soundscxx . . $ Sounds.[sound_cachecxx . . $ sound_cache.[current_slot].m_sound_indexcxx . . $ sound_buffer_info#m_sound_index.].max_distancecxx . . $ sound_info#max_distance. -
472 Soundscxx . . $ Sounds.[sound_cachecxx . . $ sound_cache.[current_slot].m_sound_indexcxx . . $ sound_buffer_info#m_sound_index.].min_distancecxx . . $ sound_info#min_distance.)));
473 }
474
475 pan = (dir_to_sound *cxx . . $ `operator*`(4a721543d64e126a). m_emulated_listenercxx . . $ lnxsound#m_emulated_listener..orientcxx . . $ emulated_listener#orient..rveccxx . . $ matrix#rvec.);
476
477 if (volume < 0.0f)
478 volume = 0.0f;
479 else if (volume > 1.0f)
480 volume = 1.0f;
481
482 if (pan < -1.0f)
483 pan = -1.0f;
484 else if (pan > 1.0f)
485 pan = 1.0f;
486
487 AdjustSoundcxx . . $ lnxsound#AdjustSound(96ebaef3518743f8).(sound_cachecxx . . $ sound_cache.[current_slot].m_unique_idcxx . . $ sound_buffer_info#m_unique_id., volume, pan, 22050);
488 }
489
490 void lnxsoundcxx . . $ lnxsound#::StopAllSoundscxx . . $ lnxsound#StopAllSounds(49f6e7a06ebc5aa8).() {
491 for (auto &current_slot : sound_cachecxx . . $ sound_cache.) {
492 if (current_slot.m_statuscxx . . $ sound_buffer_info#m_status. != SSF_UNUSEDcxx . . $ `sndlib/ssl_lib.h:416:9`!) {
493 StopSoundcxx . . $ lnxsound#StopSound(9633529ce3c4ff50).(current_slot.m_unique_idcxx . . $ sound_buffer_info#m_unique_id.);
494 }
495 }
496 }
497
498 // Checks if a sound is playing (removes finished sound);
499 bool lnxsoundcxx . . $ lnxsound#::IsSoundInstancePlayingcxx . . $ lnxsound#IsSoundInstancePlaying(83c267b20bac841a).(int sound_uid) {
500 int current_slot;
501
502 if (sound_devicecxx . . $ lnxsound#sound_device. == 0)
503 return false;
504
505 if ((current_slot = ValidateUniqueIdcxx . . $ lnxsound#ValidateUniqueId(7864480464b09eea).(sound_uid)) == -1)
506 return false;
507
508 if (sound_cachecxx . . $ sound_cache.[current_slot].m_statuscxx . . $ sound_buffer_info#m_status. != SSF_UNUSEDcxx . . $ `sndlib/ssl_lib.h:416:9`!) {
509 return true;
510 }
511
512 return false;
513 }
514
515 int lnxsoundcxx . . $ lnxsound#::IsSoundPlayingcxx . . $ lnxsound#IsSoundPlaying(7864480464b09eea).(int sound_index) {
516 if (sound_devicecxx . . $ lnxsound#sound_device. == 0)
517 return -1;
518
519 for (auto &current_slot : sound_cachecxx . . $ sound_cache.) {
520 if ((current_slot.m_statuscxx . . $ sound_buffer_info#m_status. != SSF_UNUSEDcxx . . $ `sndlib/ssl_lib.h:416:9`!) && (current_slot.m_sound_indexcxx . . $ sound_buffer_info#m_sound_index. == sound_index)) {
521 return current_slot.m_unique_idcxx . . $ sound_buffer_info#m_unique_id.;
522 }
523 }
524
525 return -1;
526 }
527
528 // Stops 2d and 3d sounds
529 void lnxsoundcxx . . $ lnxsound#::StopSoundcxx . . $ lnxsound#StopSound(9633529ce3c4ff50).(int sound_uid, uint8_tcxx . . $ uint8_t# f_immediately) {
530 int current_slot;
531 sound_buffer_infocxx . . $ sound_buffer_info# *sb;
532
533 if (sound_devicecxx . . $ lnxsound#sound_device. == 0)
534 return;
535
536 if ((current_slot = ValidateUniqueIdcxx . . $ lnxsound#ValidateUniqueId(7864480464b09eea).(sound_uid)) == -1)
537 return;
538
539 sb = &sound_cachecxx . . $ sound_cache.[current_slot];
540
541 if (sb->m_statuscxx . . $ sound_buffer_info#m_status. == SSF_UNUSEDcxx . . $ `sndlib/ssl_lib.h:416:9`!)
542 return;
543
544 // update sound count.
545 m_cur_sounds_playedcxx . . $ lnxsound#m_cur_sounds_played.--;
546
547 if (f_immediately == SKT_STOP_AFTER_LOOPcxx . . $ `sndlib/ssl_lib.h:405:9`!) {
548 sb->m_statuscxx . . $ sound_buffer_info#m_status. &= ~SSF_PLAY_LOOPINGcxx . . $ `sndlib/ssl_lib.h:418:9`!;
549 sb->m_statuscxx . . $ sound_buffer_info#m_status. |= SSF_PLAY_NORMALcxx . . $ `sndlib/ssl_lib.h:417:9`!;
550 return;
551 }
552
553 sound_cachecxx . . $ sound_cache.[current_slot].m_statuscxx . . $ sound_buffer_info#m_status. = SSF_UNUSEDcxx . . $ `sndlib/ssl_lib.h:416:9`!;
554 }
555
556 // Pause all sounds/resume all sounds
557 void lnxsoundcxx . . $ lnxsound#::PauseSoundscxx . . $ lnxsound#PauseSounds(49f6e7a06ebc5aa8).() {
558 for (auto &current_slot : sound_cachecxx . . $ sound_cache.) {
559 sound_buffer_infocxx . . $ sound_buffer_info# *sb = &current_slot;
560 if (sb->m_statuscxx . . $ sound_buffer_info#m_status. != SSF_UNUSEDcxx . . $ `sndlib/ssl_lib.h:416:9`! && !(sb->m_statuscxx . . $ sound_buffer_info#m_status. & SSF_PAUSEDcxx . . $ `sndlib/ssl_lib.h:419:9`!)) {
561 sb->m_statuscxx . . $ sound_buffer_info#m_status. |= SSF_PAUSEDcxx . . $ `sndlib/ssl_lib.h:419:9`!;
562 }
563 }
564 }
565
566 void lnxsoundcxx . . $ lnxsound#::ResumeSoundscxx . . $ lnxsound#ResumeSounds(49f6e7a06ebc5aa8).() {
567 for (auto &current_slot : sound_cachecxx . . $ sound_cache.) {
568 sound_buffer_infocxx . . $ sound_buffer_info# *sb = &current_slot;
569
570 if (sb->m_statuscxx . . $ sound_buffer_info#m_status. != SSF_UNUSEDcxx . . $ `sndlib/ssl_lib.h:416:9`! && (sb->m_statuscxx . . $ sound_buffer_info#m_status. & SSF_PAUSEDcxx . . $ `sndlib/ssl_lib.h:419:9`!)) {
571 current_slot.m_statuscxx . . $ sound_buffer_info#m_status. &= (~SSF_PAUSEDcxx . . $ `sndlib/ssl_lib.h:419:9`!);
572 }
573 }
574 }
575
576 void lnxsoundcxx . . $ lnxsound#::PauseSoundcxx . . $ lnxsound#PauseSound(d4f767463ce0a6b3).(int sound_uid) {
577 for (auto &current_slot : sound_cachecxx . . $ sound_cache.) {
578 sound_buffer_infocxx . . $ sound_buffer_info# *sb = &current_slot;
579 if (sb->m_unique_idcxx . . $ sound_buffer_info#m_unique_id. == sound_uid) {
580 if (sb->m_statuscxx . . $ sound_buffer_info#m_status. != SSF_UNUSEDcxx . . $ `sndlib/ssl_lib.h:416:9`! && !(sb->m_statuscxx . . $ sound_buffer_info#m_status. & SSF_PAUSEDcxx . . $ `sndlib/ssl_lib.h:419:9`!)) {
581 sb->m_statuscxx . . $ sound_buffer_info#m_status. |= SSF_PAUSEDcxx . . $ `sndlib/ssl_lib.h:419:9`!;
582 }
583 break;
584 }
585 }
586 }
587
588 void lnxsoundcxx . . $ lnxsound#::ResumeSoundcxx . . $ lnxsound#ResumeSound(d4f767463ce0a6b3).(int sound_uid) {
589 for (auto &current_slot : sound_cachecxx . . $ sound_cache.) {
590 if (sound_uid == current_slot.m_unique_idcxx . . $ sound_buffer_info#m_unique_id.) {
591 if (current_slot.m_statuscxx . . $ sound_buffer_info#m_status. != SSF_UNUSEDcxx . . $ `sndlib/ssl_lib.h:416:9`! && (current_slot.m_statuscxx . . $ sound_buffer_info#m_status. & SSF_PAUSEDcxx . . $ `sndlib/ssl_lib.h:419:9`!)) {
592 current_slot.m_statuscxx . . $ sound_buffer_info#m_status. &= (~SSF_PAUSEDcxx . . $ `sndlib/ssl_lib.h:419:9`!);
593 break;
594 }
595 }
596 }
597 }
598
599 bool lnxsoundcxx . . $ lnxsound#::CheckAndForceSoundDataAlloccxx . . $ lnxsound#CheckAndForceSoundDataAlloc(83c267b20bac841a).(int sound_index) {
600 int sound_file_index = Soundscxx . . $ Sounds.[sound_index].sample_indexcxx . . $ sound_info#sample_index.;
601
602 // ASSERT(sound_file_index >= 0 && sound_file_index < MAX_SOUND_FILES);
603
604 if (sound_file_index < 0 || sound_file_index >= MAX_SOUND_FILEScxx . . $ `sndlib/ssl_lib.h:579:9`!) {
605 return false;
606 }
607
608 // Check if the sample data is already loaded
609 if (SoundFilescxx . . $ SoundFiles.[sound_file_index].sample_16bitcxx . . $ sound_file_info#sample_16bit. != nullptr || SoundFilescxx . . $ SoundFiles.[sound_file_index].sample_8bitcxx . . $ sound_file_info#sample_8bit. != nullptr)
610 return true;
611
612 // If not, get the sound data
613 int result = SoundLoadWaveFilecxx . . $ SoundLoadWaveFile(a6965b2b334606ff).(SoundFilescxx . . $ SoundFiles.[sound_file_index].namecxx . . $ sound_file_info#name., Soundscxx . . $ Sounds.[sound_index].import_volumecxx . . $ sound_info#import_volume., sound_file_index,
614 (m_sound_qualitycxx . . $ lnxsound#m_sound_quality. == SQT_HIGHcxx . . $ `sndlib/ssl_lib.h:352:9`!), true);
615
616 // Why would it load once (table load time) and not now?
617 if (!result)
618 return false;
619
620 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Sound %s loaded.\n", SoundFiles[sound_file_index].name);
621
622 return true;
623 }
624
625 // Begin sound frame
626 void lnxsoundcxx . . $ lnxsound#::SoundStartFramecxx . . $ lnxsound#SoundStartFrame(49f6e7a06ebc5aa8).() {
627 float frame_time;
628
629 if (m_timer_last_frametimecxx . . $ lnxsound#m_timer_last_frametime. == -1) {
630 frame_time = 0.0f;
631 } else {
632 frame_time = (timer_GetMSTimecxx . . $ `ddio/ddio.h:237:9`!() - m_timer_last_frametimecxx . . $ lnxsound#m_timer_last_frametime.) / 1000.0f;
633 }
634 m_timer_last_frametimecxx . . $ lnxsound#m_timer_last_frametime. = timer_GetMSTimecxx . . $ `ddio/ddio.h:237:9`!();
635
636 // perform necessary functions if sound events are pending for frame, this doesn't have to do anything
637 // if the mixer doesn't require such actions. Aureal does though.
638 if (m_pending_actionscxx . . $ lnxsound#m_pending_actions.) {
639 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "pending actions\n");
640 }
641
642 m_in_sound_framecxx . . $ lnxsound#m_in_sound_frame. = true;
643 m_pending_actionscxx . . $ lnxsound#m_pending_actions. = false;
644
645 int counter = 0, loop_counter = 0, stream_counter = 0, buf_loop_counter = 0;
646
647 #ifdef _DEBUGcxx . . $ `<built-in>:480:9`!
648 int n_p5 = 0, n_p4 = 0, n_p3 = 0, n_p2 = 0, n_p1 = 0, n_p0 = 0;
649 #endif
650
651 for (auto &current_slot : sound_cachecxx . . $ sound_cache.) {
652 sound_buffer_infocxx . . $ sound_buffer_info# *sb = &current_slot;
653 if (sb->m_statuscxx . . $ sound_buffer_info#m_status. != SSF_UNUSEDcxx . . $ `sndlib/ssl_lib.h:416:9`!) {
654 counter++;
655 if (sb->m_statuscxx . . $ sound_buffer_info#m_status. & SSF_PLAY_LOOPINGcxx . . $ `sndlib/ssl_lib.h:418:9`!) {
656 if (sb->m_statuscxx . . $ sound_buffer_info#m_status. & SSF_BUFFERED_LOOPcxx . . $ `sndlib/ssl_lib.h:421:9`!)
657 buf_loop_counter++;
658 loop_counter++;
659 }
660 if (sb->m_statuscxx . . $ sound_buffer_info#m_status. & SSF_PLAY_STREAMINGcxx . . $ `sndlib/ssl_lib.h:420:9`!)
661 stream_counter++;
662
663 #ifdef _DEBUGcxx . . $ `<built-in>:480:9`!
664 if (sb->play_infocxx . . $ sound_buffer_info#play_info.->prioritycxx . . $ play_information#priority. == SND_PRIORITY_CRITICALcxx . . $ `sndlib/ssl_lib.h:281:9`!)
665 n_p5++;
666 else if (sb->play_infocxx . . $ sound_buffer_info#play_info.->prioritycxx . . $ play_information#priority. == SND_PRIORITY_HIGHESTcxx . . $ `sndlib/ssl_lib.h:282:9`!)
667 n_p4++;
668 else if (sb->play_infocxx . . $ sound_buffer_info#play_info.->prioritycxx . . $ play_information#priority. == SND_PRIORITY_HIGHcxx . . $ `sndlib/ssl_lib.h:283:9`!)
669 n_p3++;
670 else if (sb->play_infocxx . . $ sound_buffer_info#play_info.->prioritycxx . . $ play_information#priority. == SND_PRIORITY_NORMALcxx . . $ `sndlib/ssl_lib.h:284:9`!)
671 n_p2++;
672 else if (sb->play_infocxx . . $ sound_buffer_info#play_info.->prioritycxx . . $ play_information#priority. == SND_PRIORITY_LOWcxx . . $ `sndlib/ssl_lib.h:285:9`!)
673 n_p1++;
674 else if (sb->play_infocxx . . $ sound_buffer_info#play_info.->prioritycxx . . $ play_information#priority. == SND_PRIORITY_LOWESTcxx . . $ `sndlib/ssl_lib.h:286:9`!)
675 n_p0++;
676 #endif
677 }
678 }
679
680 // update cache stress timer.
681 if (counter < (MAX_SOUNDS_PLAYING_AT_ONCEcxx . . $ `sndlib/sdlsound.cpp:42:9`! * 3 / 4)) {
682 m_cache_stress_timercxx . . $ lnxsound#m_cache_stress_timer. += frame_time;
683 } else {
684 m_cache_stress_timercxx . . $ lnxsound#m_cache_stress_timer. = 0.0f;
685 }
686
687 #ifdef _DEBUGcxx . . $ `<built-in>:480:9`!
688 mprintf_atcxx . . $ `ddebug/mono.h:83:9`!(3, 2, 0, "LNS: %02d/%02d", counter, MAX_SOUNDS_PLAYING_AT_ONCE);
689 mprintf_atcxx . . $ `ddebug/mono.h:83:9`!(3, 3, 1, "Lp: %02d", loop_counter);
690 mprintf_atcxx . . $ `ddebug/mono.h:83:9`!(3, 4, 1, "St: %02d", stream_counter);
691 mprintf_atcxx . . $ `ddebug/mono.h:83:9`!(3, 5, 0, " Ot: %02d", counter - loop_counter - stream_counter);
692
693 mprintf_atcxx . . $ `ddebug/mono.h:83:9`!(3, 2, 20, "P5:%02d P4:%02d P3:%02d", n_p5, n_p4, n_p3);
694 mprintf_atcxx . . $ `ddebug/mono.h:83:9`!(3, 3, 20, "P2:%02d P1:%02d P0:%02d", n_p2, n_p1, n_p0);
695 #endif
696 }
697
698 // End sound frame
699 void lnxsoundcxx . . $ lnxsound#::SoundEndFramecxx . . $ lnxsound#SoundEndFrame(49f6e7a06ebc5aa8).() {
700 CheckForErrorscxx . . $ lnxsound#CheckForErrors(49f6e7a06ebc5aa8).(); // handles errors.
701 m_in_sound_framecxx . . $ lnxsound#m_in_sound_frame. = false;
702 }
703
704 // Sound System Error Handler.
705 void lnxsoundcxx . . $ lnxsound#::CheckForErrorscxx . . $ lnxsound#CheckForErrors(49f6e7a06ebc5aa8).() {
706 // if a fatal error occurred, quit and display an error
707 // non-fatal errors should be put inside a logfile, or just mprinted out.
708 switch (m_lib_error_codecxx . . $ llsSystem#m_lib_error_code.) {
709 case SSL_ERROR_SAMPLE_NODATAcxx . . $ `sndlib/ssl_lib.h:412:9`!:
710 Errorcxx . . $ Error(326aeb464d16410c).("%s\nSample had no data.", m_error_textcxx . . $ llsSystem#m_error_text.);
711 break;
712
713 case SSL_ERROR_STREAMMIXERcxx . . $ `sndlib/ssl_lib.h:413:9`!:
714 Errorcxx . . $ Error(326aeb464d16410c).("%s\nMixer alignment check failed.", m_error_textcxx . . $ llsSystem#m_error_text.);
715 break;
716
717 case SSL_ERROR_GENERICcxx . . $ `sndlib/ssl_lib.h:411:9`!:
718 Errorcxx . . $ Error(326aeb464d16410c).("%s\nGeneric error.", m_error_textcxx . . $ llsSystem#m_error_text.);
719 break;
720 }
721
722 // must call!
723 llsSystemcxx . . $ llsSystem#::CheckForErrorscxx . . $ llsSystem#CheckForErrors(49f6e7a06ebc5aa8).();
724 }
725
726 // returns the error string.
727 const char *lnxsoundcxx . . $ lnxsound#::GetErrorStrcxx . . $ lnxsound#GetErrorStr(a9f41ea0e82d88cf).() const {
728 static char buffer[] = "No Error Given";
729 return buffer;
730 }
731
732 bool lnxsoundcxx . . $ lnxsound#::SetGlobalReverbPropertiescxx . . $ lnxsound#SetGlobalReverbProperties(5f279dd7f821a414).(float volume, float damping, float decay) { return false; }
733
734 void lnxsoundcxx . . $ lnxsound#::StartStreamingcxx . . $ lnxsound#StartStreaming(49f6e7a06ebc5aa8).() {}
735
736 void lnxsoundcxx . . $ lnxsound#::EndStreamingcxx . . $ lnxsound#EndStreaming(49f6e7a06ebc5aa8).() {}
737
738 // may be called before init (must be to be valid, the card passed here will be initialized in InitSoundLib)
739 void lnxsoundcxx . . $ lnxsound#::SetSoundCardcxx . . $ lnxsound#SetSoundCard(85c52e162fed56f9).(const char *name) {}
740
741 // set special parameters for the 3d environment.
742 // of strcuture passed, you must set the appropriate 'flags' value for values you wish to modify
743 void lnxsoundcxx . . $ lnxsound#::SetEnvironmentValuescxx . . $ lnxsound#SetEnvironmentValues(9789f8e644620ab0).(const t3dEnvironmentValuescxx . . $ t3dEnvironmentValues# *env) {}
744
745 // get special parameters for the 3d environment.
746 // of strcuture passed, you must set the appropriate 'flags' value for values you wish to modify
747 void lnxsoundcxx . . $ lnxsound#::GetEnvironmentValuescxx . . $ lnxsound#GetEnvironmentValues(f6503759d22bce78).(t3dEnvironmentValuescxx . . $ t3dEnvironmentValues# *env) {}
748
749 // enable special parameters for the 3d environment.
750 // of strcuture passed, you must set the appropriate 'flags' value for values you wish to modify
751 void lnxsoundcxx . . $ lnxsound#::SetEnvironmentTogglescxx . . $ lnxsound#SetEnvironmentToggles(4f564680f5be55d7).(const t3dEnvironmentTogglescxx . . $ t3dEnvironmentToggles# *env) {}
752
753 // get states of special parameters for the 3d environment.
754 // of strcuture passed, you must set the appropriate 'flags' value for values you wish to modify
755 void lnxsoundcxx . . $ lnxsound#::GetEnvironmentTogglescxx . . $ lnxsound#GetEnvironmentToggles(3d0214c48b4fff80).(t3dEnvironmentTogglescxx . . $ t3dEnvironmentToggles# *env) {}
756
757 void lnxsound_SetErrorcxx . . $ lnxsound_SetError(d4f767463ce0a6b3).(int code) { ll_sound_ptrcxx . . $ ll_sound_ptr.->SetErrorcxx . . $ llsSystem#SetError(d4f767463ce0a6b3).(code); }
758
759 void lnxsound_ErrorTextcxx . . $ lnxsound_ErrorText(326aeb464d16410c).(const char *fmt, ...) {
760 char buffer[384];
761 va_list args;
762 va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(args, fmt);
763 stdcxx . . $ std/::vsnprintfcxx . . $ std/vsnprintf(348eb892742d8727).(buffer, sizeof(buffer), fmt, args);
764 va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(args);
765
766 ll_sound_ptrcxx . . $ ll_sound_ptr.->ErrorTextcxx . . $ llsSystem#ErrorText(326aeb464d16410c).(buffer);
767 }
768
769 // A peroidic mixer that uses the primary buffer as a stream buffer
770 static void StreamAudiocxx . . $ StreamAudio(c52f2c8079c5ae6).(void *user_ptr, Uint8cxx . . $ Uint8# *stream, int len) {
771 ((software_mixercxx . . $ software_mixer# *)user_ptr)->StreamMixercxx . . $ software_mixer#StreamMixer(a07d8cccb7673f5a).((char *)stream, len);
772 }