Debian Codegraph @

RSPiX/Src/GREEN/Mix/mix.h

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////cxx . . $ `<file>/RSPiX/Src/GREEN/Mix/mix.h`/
2 //
3 // Copyright 2016 RWS Inc, All Rights Reserved
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of version 2 of the GNU General Public License as published by
7 // the Free Software Foundation
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License along
15 // with this program; if not, write to the Free Software Foundation, Inc.,
16 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 //
18 ///////////////////////////////////////////////////////////////////////////////
19 //
20 // mix.h
21 //
22 // History:
23 // 06/17/95 JMI Started.
24 //
25 // 06/26/97 JMI Started tracking history of this .h file.
26 // Added optional constant playing of silence.
27 //
28 // 07/16/97 JRD Added volume members and volume parameters to Start.
29 // Modified BlueCall to pass parameters to MixBuf.
30 //
31 // 07/17/97 JRD Removed Volume parameters, as they should be set
32 // by the callback.
33 //
34 // 07/17/97 JRD Added Volume parameters, as they aren't always set
35 // by the callback.
36 //
37 // 08/05/97 JMI Added IsPaused(), PauseChannel(), ResumeChannel(),
38 // and IsChannelPaused().
39 //
40 // 10/30/97 JMI Added alternate version of SetMode() which allows more
41 // detail as to bit depth quality of samples and mixing.
42 //
43 //////////////////////////////////////////////////////////////////////////////
44 //
45 // See CPP header comment for details.
46 //
47 //////////////////////////////////////////////////////////////////////////////
48
49 #ifndef MIX_H
50 #define MIX_Hcxx . . $ `RSPiX/Src/GREEN/Mix/mix.h:50:9`!
51 ///////////////////////////////////////////////////////////////////////////////
52 // Headers.
53 ///////////////////////////////////////////////////////////////////////////////
54 #include "System.h"cxx . . $ `<file>/RSPiX/Src/BLUE/System.h`/
55
56 // If PATHS_IN_INCLUDES macro is defined, we can utilized relative
57 // paths to a header file. In this case we generally go off of our
58 // RSPiX root directory. System.h MUST be included before this macro
59 // is evaluated. System.h is the header that, based on the current
60 // platform (or more so in this case on the compiler), defines
61 // PATHS_IN_INCLUDES. Blue.h includes system.h so you can include that
62 // instead.
63 #ifdef PATHS_IN_INCLUDEScxx . . $ `RSPiX/Src/BLUE/unix/UnixSystem.h:65:9`!
64 #include "ORANGE/CDT/List.h"cxx . . $ `<file>/RSPiX/Src/ORANGE/CDT/List.h`/
65 #include "GREEN/Mix/MixBuf.h"cxx . . $ `<file>/RSPiX/Src/GREEN/Mix/MixBuf.h`/
66 #include "GREEN/SndFx/SndFx.h"cxx . . $ `<file>/RSPiX/Src/GREEN/SndFx/SndFx.h`/
67 #else
68 #include "List.h"
69 #include "MixBuf.h"
70 #include "SndFx.h"
71 #endif // PATHS_IN_INCLUDES
72
73 ///////////////////////////////////////////////////////////////////////////////
74 // Macros.
75 ///////////////////////////////////////////////////////////////////////////////
76 // Maximum number of buffers this class will use.
77 #define MAX_BUFScxx . . $ `RSPiX/Src/GREEN/Mix/mix.h:77:9`! 256
78
79 ///////////////////////////////////////////////////////////////////////////////
80 // Types.
81 ///////////////////////////////////////////////////////////////////////////////
82
83 // Forward declare class for handy-dandy typedef.
84 class RMixcxx . . $ RMix#;
85
86 // Handy-dandy typedef.
87 typedef RMixcxx . . $ RMix#* PMIXcxx . . $ PMIX#;
88
89 // Class definition.
90 class RMixcxx . . $ RMix#
91 {
92 public: // Enums and typedefs.
93 typedef enumcxx . . $ RMix#$anonymous_type_0#
94 { // Mix messages (callback can receive in addition to blue messages).
95 Suspendedcxx . . $ RMix#Suspended., // Channel has finished.
96 Datacxx . . $ RMix#Data. // Channel needs new data.
97 } Msgcxx . . $ RMix#Msg#;
98
99 typedef enumcxx . . $ RMix#$anonymous_type_1#
100 { // Mix states for ms_sState and GetState().
101 Idlecxx . . $ RMix#Idle., // No mixing occurring.
102 Processingcxx . . $ RMix#Processing. // There are unfinished channels (i.e.,
103 // either mixing is occurring or there
104 // are channels that have data that is
105 // still being played by Blue).
106 } Statecxx . . $ RMix#State#;
107
108 // Callback.
109 typedef void* (*RMixCallcxx . . $ RMix#RMixCall#)( Msgcxx . . $ RMix#Msg# msg,
110 void* pData,
111 uint32_tcxx . . $ uint32_t#* pulBufSize,
112 uintptr_tcxx . . $ uintptr_t# ulUser,
113 uint8_tcxx . . $ uint8_t#* pucVol1,
114 uint8_tcxx . . $ uint8_t#* pucVol2);
115
116 public: // <Con|De>struction.
117 // Default constructor.
118 RMixcxx . . $ RMix#RMix(49f6e7a06ebc5aa8).();
119 // Destructor.
120 ~cxx . . $ RMix#`~RMix`(49f6e7a06ebc5aa8).RMixcxx . . $ RMix#();
121
122 public: // Methods.
123 /////////////////////////////////////////////////////////////////////////
124 // API that affects a single channel.
125 /////////////////////////////////////////////////////////////////////////
126
127 // Open a mix channel.
128 // Returns 0 on success.
129 int16_t OpenChannelcxx . . $ RMix#OpenChannel(6989aafbb72c2a3a).(int32_t lSampleRate,
130 int32_t lBitsPerSample,
131 int32_t lNumChannels);
132
133 // Close a mix channel.
134 // Returns 0 on success.
135 int16_t CloseChannelcxx . . $ RMix#CloseChannel(4c3706f7850cf040).(void);
136
137 // Start receiving callbacks to fill channel data.
138 // Set the initial mix volumes
139 // Returns 0 on success.
140 int16_t Startcxx . . $ RMix#Start(9d0c6d9e32af71de).(RMixCallcxx . . $ RMix#RMixCall# mcUser, uintptr_tcxx . . $ uintptr_t# ulUser,
141 uint8_tcxx . . $ uint8_t# ucVolume = 255, uint8_tcxx . . $ uint8_t# ucVol2 = 255 );
142
143 // Stop receiving callbacks to fill channel data.
144 int16_t Suspendcxx . . $ RMix#Suspend(4c3706f7850cf040).(void); // Returns 0 on success.
145
146 // Pause mix channel.
147 void PauseChannelcxx . . $ RMix#PauseChannel(49f6e7a06ebc5aa8).(void);
148
149 // Resume mix channel.
150 void ResumeChannelcxx . . $ RMix#ResumeChannel(49f6e7a06ebc5aa8).(void);
151
152 // Check mix channel's paused status.
153 int16_t IsChannelPausedcxx . . $ RMix#IsChannelPaused(4c3706f7850cf040).(void); // Returns TRUE, if sound output is paused; FALSE otherwise.
154
155 // Set or clear (if psndfx is NULL) a RSndFx for this channel.
156 void SetFxcxx . . $ RMix#SetFx(bd99a0409b15416c).( // Returns nothing.
157 RSndFxcxx . . $ RSndFx#* psndfx) // FX for this channel. Clears current, if
158 // NULL.
159 {
160 m_psndfxcxx . . $ RMix#m_psndfx. = psndfx;
161 }
162
163 /////////////////////////////////////////////////////////////////////////
164 // API that affects all channels (static).
165 /////////////////////////////////////////////////////////////////////////
166
167 // Set the current audio mode.
168 // This will cause any open channels to start playing.
169 static int16_t SetModecxx . . $ RMix#SetMode(a8093b2207a9051b).( // Returns 0 on success.
170 int32_t lSamplesPerSec, // Sample rate in samples per second.
171 int32_t lDevBitsPerSample, // Number of bits per sample for device.
172 int32_t lNumChannels, // Number of channels (1 == mono,2 == stereo).
173 int32_t lBufferTime, // Amount of time buffer spends in queue b4
174 // being played.
175 int32_t lMaxBufferTime, // Maximum that lBufferTime can be set to
176 // dynamically with RMix::SetBufferTime().
177 int32_t lMixBitsPerSample, // Bit depth at which samples will be mixed.
178 int32_t lSrcBitsPerSample); // Bit depth at which samples must be to be
179 // mixed or 0 for no preference.
180
181 // Set the current audio mode.
182 // This will cause any open channels to start playing.
183 static int16_t SetModecxx . . $ RMix#SetMode(91191c87c49e21fd).( // Returns 0 on success.
184 int32_t lSamplesPerSec, // Sample rate in samples per second.
185 int32_t lBitsPerSample, // Number of bits per sample.
186 int32_t lNumChannels, // Number of channels (1 == mono,2 == stereo).
187 int32_t lBufferTime, // Amount of time buffer spends in queue b4
188 // being played.
189 int32_t lMaxBufferTime) // Maximum that lBufferTime can be set to
190 // dynamically with RMix::SetBufferTime().
191 {
192 return SetModecxx . . $ RMix#SetMode(a8093b2207a9051b).(
193 lSamplesPerSec,
194 lBitsPerSample,
195 lNumChannels,
196 lBufferTime,
197 lMaxBufferTime,
198 lBitsPerSample,
199 lBitsPerSample);
200 }
201
202 // Kills the current audio mode.
203 // This will cause any open channels to be closed stops Blue from
204 // utilizing the sound audio device.
205 static void KillModecxx . . $ RMix#KillMode(49f6e7a06ebc5aa8).(void);
206
207 // Pause currently playing audio.
208 // NOTE: Pause/Resume is implemented in levels by Blue.
209 static int16_t Pausecxx . . $ RMix#Pause(4c3706f7850cf040).(void); // Returns 0 on success.
210
211 // Resume currently paused audio.
212 // NOTE: Pause/Resume is implemented in levels by Blue.
213 static int16_t Resumecxx . . $ RMix#Resume(4c3706f7850cf040).(void); // Returns 0 on success.
214
215 // Returns TRUE, if sound output is paused; FALSE otherwise.
216 static int16_t IsPausedcxx . . $ RMix#IsPaused(4c3706f7850cf040).(void); // Returns TRUE, if sound output is paused; FALSE otherwise.
217
218 // Do stuff specific to RMix and the playing of audio through Blue.
219 // This includes calling rspDoSound().
220 static int32_t Docxx . . $ RMix#Do(b126dc7c1de90089).(void); // Returns value returned by rspDoSound() that
221 // indicates how much audio, in milliseconds,
222 // was required to be queued.
223
224 // Reset all current mix channels.
225 static int16_t Resetcxx . . $ RMix#Reset(4c3706f7850cf040).(void); // Returns 0 on success.
226
227 // Suspends all current mix channels.
228 static int16_t SuspendAllcxx . . $ RMix#SuspendAll(4c3706f7850cf040).(void); // Returns 0 on success.
229
230 // Sets the maximum duration that can occur between calls
231 // to rspDoSound.
232 static void SetBufferTimecxx . . $ RMix#SetBufferTime(d4f767463ce0a6b3).(int32_t lBufferTime)
233 { ms_ulBufSizecxx . . $ RMix#ms_ulBufSize. = 0; rspSetSoundOutBufferTimecxx . . $ rspSetSoundOutBufferTime(d4f767463ce0a6b3).(lBufferTime); }
234
235 // Set or clear (if psndfx is NULL) a RSndFx for all channels.
236 static void SetGlobalFxcxx . . $ RMix#SetGlobalFx(bd99a0409b15416c).( // Returns nothing.
237 RSndFxcxx . . $ RSndFx#* psndfx) // FX for all channels. Clears current, if
238 // NULL.
239 {
240 ms_psndfxcxx . . $ RMix#ms_psndfx. = psndfx;
241 }
242
243 // Enable or disable auto-pump feature which will keep silence pumping
244 // through Blue's sound interface even when there are no channels to
245 // mix. This, when enabled, keeps delays consistent and removes overhead,
246 // if any, for starting Blue's sound stuff.
247 static void SetAutoPumpcxx . . $ RMix#SetAutoPump(68e3ae50fe6578a9).( // Returns nothing.
248 int16_t sAutoPump) // In: TRUE to auto-pump silence, FALSE othwerise.
249 {
250 ms_sKeepPumpingcxx . . $ RMix#ms_sKeepPumping. = sAutoPump;
251 }
252
253 public: // Querries.
254 /////////////////////////////////////////////////////////////////////////
255 // API that affects a single channel.
256 /////////////////////////////////////////////////////////////////////////
257
258 // Returns TRUE if this mix channel is open; FALSE otherwise.
259 int16_t IsOpencxx . . $ RMix#IsOpen(4c3706f7850cf040).(void) { return m_sOpencxx . . $ RMix#m_sOpen.; }
260 // Returns TRUE if this mix channel is active; FALSE otherwise.
261 int16_t IsActivecxx . . $ RMix#IsActive(4c3706f7850cf040).(void) { return m_sActivecxx . . $ RMix#m_sActive.; }
262
263 // Returns the time for this RMix.
264 int32_t GetTimecxx . . $ RMix#GetTime(b126dc7c1de90089).(void);
265
266 // Returns the position for this RMix.
267 int32_t GetPoscxx . . $ RMix#GetPos(b126dc7c1de90089).(void);
268
269 /////////////////////////////////////////////////////////////////////////
270 // API that affects all channels (static).
271 /////////////////////////////////////////////////////////////////////////
272
273 // Returns the current state for all RMixes.
274 static Statecxx . . $ RMix#State# GetStatecxx . . $ RMix#GetState(c44840632cd23710).() { return ms_sStatecxx . . $ RMix#ms_sState.; }
275
276 // Gets the current mode of the sound output device.
277 static int16_t GetModecxx . . $ RMix#GetMode(d524aa0312a0bc43).( // Returns 0 on success;
278 // nonzero if no mode.
279 int32_t* plSamplesPerSec, // Sample rate in samples per second
280 // returned here, if not NULL.
281 int32_t* plDevBitsPerSample = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!, // Bits per sample of device,
282 // returned here, if not NULL.
283 int32_t* plNumChannels = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, // Number of channels (1 == mono,
284 // 2 == stereo) returned here,
285 // if not NULL.
286 int32_t* plBufferTime = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, // Amount of time in ms to lead the
287 // current play cursor returned here,
288 // if not NULL. This could also be
289 // described as the maximum amount of
290 // time in ms that can occur between
291 // calls to rspDoSound.
292 int32_t* plMaxBufferTime = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, // Maximum buffer time. This is the amt
293 // that *plBufferTime can be increased to.
294 // This is indicative of how much space
295 // was/will-be allocated for the sound
296 // output device on rspLockSoundOut.
297 int32_t* plMixBitsPerSample = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, // Bits per sample at which samples are
298 // mixed, if not NULL.
299 int32_t* plSrcBitsPerSample = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);// Bits per sample at which samples must
300 // be to be mixed (0 if no requirement),
301 // if not NULL.
302
303 protected: // Internal use.
304 // Intialize members.
305 void Initcxx . . $ RMix#Init(49f6e7a06ebc5aa8).(void);
306
307 // Called when all sound on a channel has finished.
308 // Returns 0 on success.
309 int16_t ChannelFinishedcxx . . $ RMix#ChannelFinished(4c3706f7850cf040).(void);
310
311 // Implied this version of BlueCallStatic, called from BlueCallStatic.
312 int16_t BlueCallcxx . . $ RMix#BlueCall(da3cbe0b4bf9100c).( // Returns FALSE when no data mixed.
313 int32_t lDataPos, // Position that this buffer represents in stream.
314 PMIXBUFcxx . . $ PMIXBUF# pmb); // Mix buffer to mix into.
315
316 // Callbacks from Blue.
317 static int16_t BlueCallStaticcxx . . $ RMix#BlueCallStatic(9d30b329a0562ed).( // Returns TRUE to continue mixing in this
318 // buffer or FALSE to not mix this buffer.
319 uint8_tcxx . . $ uint8_t#* pucData,
320 int32_t lBufSize,
321 int32_t lDataPos,
322 uint32_tcxx . . $ uint32_t#* pul_ppmixbuf);
323
324 public: // members
325
326 // Volume information is set from Start and RSND callbacks
327 uint8_tcxx . . $ uint8_t# m_ucVolumecxx . . $ RMix#m_ucVolume.; // 0 - 255
328 uint8_tcxx . . $ uint8_t# m_ucSecondaryVolumecxx . . $ RMix#m_ucSecondaryVolume.; // 0 - 255
329
330 protected: // Members.
331 int32_t m_lSampleRatecxx . . $ RMix#m_lSampleRate.; // Sample rate for audio playback/mix.
332 int32_t m_lBitsPerSamplecxx . . $ RMix#m_lBitsPerSample.; // Sample size in bits.
333 int32_t m_lNumChannelscxx . . $ RMix#m_lNumChannels.; // Number of channels (mono or stereo).
334
335 int16_t m_sOpencxx . . $ RMix#m_sOpen.; // TRUE if channel open; FALSE
336 // otherwise.
337 int16_t m_sActivecxx . . $ RMix#m_sActive.; // TRUE if channel active; FALSE
338 // otherwise.
339 int16_t m_sSuspendingcxx . . $ RMix#m_sSuspending.; // TRUE if channel suspending; FALSE
340 // otherwise.
341 int32_t m_lLastDataPoscxx . . $ RMix#m_lLastDataPos.; // Last byte mixed into.
342 RMixCallcxx . . $ RMix#RMixCall# m_mcUsercxx . . $ RMix#m_mcUser.; // User callback.
343 uintptr_tcxx . . $ uintptr_t# m_ulUsercxx . . $ RMix#m_ulUser.; // User value.
344 uint8_tcxx . . $ uint8_t#* m_pucDatacxx . . $ RMix#m_pucData.; // User data.
345 uint32_tcxx . . $ uint32_t# m_ulAmountcxx . . $ RMix#m_ulAmount.; // Amount of user data remaining.
346
347 int32_t m_lStartTimecxx . . $ RMix#m_lStartTime.; // Audio time when first buffer entered
348 // queue.
349 int32_t m_lStartPoscxx . . $ RMix#m_lStartPos.; // Audio position when first buffer
350 // enter queue.
351
352 RSndFxcxx . . $ RSndFx#* m_psndfxcxx . . $ RMix#m_psndfx.; // Pointer to an RSndFx.
353
354 int16_t m_sPauseLevelcxx . . $ RMix#m_sPauseLevel.; // Current pause level.
355
356 static RListcxx . . $ RList#<RMixcxx . . $ RMix#> ms_listActivecxx . . $ RMix#ms_listActive.; // List of active channels.
357
358 static int16_t ms_sSetModecxx . . $ RMix#ms_sSetMode.; // TRUE if we set Blue's sound
359 // output mode.
360
361 static Statecxx . . $ RMix#State# ms_sStatecxx . . $ RMix#ms_sState.; // Current state for all RMixes.
362 static int32_t ms_lCurPoscxx . . $ RMix#ms_lCurPos.; // Current play position
363 // based on absolute start.
364 static uint32_tcxx . . $ uint32_t# ms_ulBufSizecxx . . $ RMix#ms_ulBufSize.; // The size to use when allocating
365 // RMixBufs.
366 static int16_t ms_sResetcxx . . $ RMix#ms_sReset.; // Resets Blue and returns all
367 // current user buffers.
368 static RSndFxcxx . . $ RSndFx#* ms_psndfxcxx . . $ RMix#ms_psndfx.; // Pointer to a global RSndFx.
369
370 static int16_t ms_sKeepPumpingcxx . . $ RMix#ms_sKeepPumping.; // Keep Blue pumped with silence
371 // when no channels are playing,
372 // if TRUE.
373
374 static RMixBufcxx . . $ RMixBuf# ms_mixbufcxx . . $ RMix#ms_mixbuf.; // One and only mix buffer.
375 };
376
377 #endif // MIX_H
378 ///////////////////////////////////////////////////////////////////////////////
379 // EOF
380 ///////////////////////////////////////////////////////////////////////////////