comparison minijss/jssmix.c @ 658:c430112449a7

Move miniJSS into a subdirectory.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 16 Apr 2013 07:32:29 +0300
parents jssmix.c@701c3d22e0f9
children eba3b87f3f84
comparison
equal deleted inserted replaced
657:7e25ec0bbf59 658:c430112449a7
1 /*
2 * miniJSS - Mixing device and channel handling
3 * Programmed and designed by Matti 'ccr' Hamalainen
4 * (C) Copyright 2006-2012 Tecnic Software productions (TNSP)
5 */
6 #include "jssmix.h"
7 #include <string.h>
8
9
10 #ifdef DM_USE_C
11 #define JMIXER_HEADER
12 #include "jmix_c_in.c"
13 #undef JMIXER_HEADER
14 #endif
15
16 #undef DM_USE_SIMD
17
18 #ifdef DM_USE_SIMD
19 #define JMIXER_HEADER
20 #include "jmix_mmx_in.c"
21 #undef JMIXER_HEADER
22 #endif
23
24
25 typedef struct
26 {
27 int mixerID;
28 int outFormat;
29 int outChannels;
30
31 int (*jvmMixChannel_FW)(JSSMixer *, JSSChannel *, JMIXER_ADDBUF_TYPE *, const int, const DMFixedPoint);
32 int (*jvmMixChannel_BW)(JSSMixer *, JSSChannel *, JMIXER_ADDBUF_TYPE *, const int, const DMFixedPoint);
33 void (*jvmPostProcess)(JMIXER_ADDBUF_TYPE *, void *, const int);
34 } JSSMixingRoutine;
35
36
37 /* This table should be sorted from fastest to slowest, e.g. MMX/x86
38 * optimized routines first, pure C versions last.
39 */
40 static JSSMixingRoutine jvmMixRoutines[] =
41 {
42 #ifdef DM_USE_SIMD
43 { JMIX_MMX, JSS_AUDIO_U8, JSS_AUDIO_MONO, jvmMix_Mono_MMX_FW, jvmMix_Mono_MMX_BW, jvmPostProcess_U8_MMX },
44 { JMIX_MMX, JSS_AUDIO_S8, JSS_AUDIO_MONO, jvmMix_Mono_MMX_FW, jvmMix_Mono_MMX_BW, jvmPostProcess_S8_MMX },
45 { JMIX_MMX, JSS_AUDIO_U8, JSS_AUDIO_STEREO, jvmMix_Stereo_MMX_FW, jvmMix_Stereo_MMX_BW, jvmPostProcess_U8_MMX },
46 { JMIX_MMX, JSS_AUDIO_S8, JSS_AUDIO_STEREO, jvmMix_Stereo_MMX_FW, jvmMix_Stereo_MMX_BW, jvmPostProcess_S8_MMX },
47
48 { JMIX_MMX, JSS_AUDIO_U16, JSS_AUDIO_MONO, jvmMix_Mono_MMX_FW, jvmMix_Mono_MMX_BW, jvmPostProcess_U16_MMX },
49 { JMIX_MMX, JSS_AUDIO_S16, JSS_AUDIO_MONO, jvmMix_Mono_MMX_FW, jvmMix_Mono_MMX_BW, jvmPostProcess_S16_MMX },
50 { JMIX_MMX, JSS_AUDIO_U16, JSS_AUDIO_STEREO, jvmMix_Stereo_MMX_FW, jvmMix_Stereo_MMX_BW, jvmPostProcess_U16_MMX },
51 { JMIX_MMX, JSS_AUDIO_S16, JSS_AUDIO_STEREO, jvmMix_Stereo_MMX_FW, jvmMix_Stereo_MMX_BW, jvmPostProcess_S16_MMX },
52 #endif
53
54 #ifdef DM_USE_C
55 { JMIX_C, JSS_AUDIO_U8, JSS_AUDIO_MONO, jvmMix_Mono_C_FW, jvmMix_Mono_C_BW, jvmPostProcess_U8_C },
56 { JMIX_C, JSS_AUDIO_S8, JSS_AUDIO_MONO, jvmMix_Mono_C_FW, jvmMix_Mono_C_BW, jvmPostProcess_S8_C },
57 { JMIX_C, JSS_AUDIO_U8, JSS_AUDIO_STEREO, jvmMix_Stereo_C_FW, jvmMix_Stereo_C_BW, jvmPostProcess_U8_C },
58 { JMIX_C, JSS_AUDIO_S8, JSS_AUDIO_STEREO, jvmMix_Stereo_C_FW, jvmMix_Stereo_C_BW, jvmPostProcess_S8_C },
59
60 { JMIX_C, JSS_AUDIO_U16, JSS_AUDIO_MONO, jvmMix_Mono_C_FW, jvmMix_Mono_C_BW, jvmPostProcess_U16_C },
61 { JMIX_C, JSS_AUDIO_S16, JSS_AUDIO_MONO, jvmMix_Mono_C_FW, jvmMix_Mono_C_BW, jvmPostProcess_S16_C },
62 { JMIX_C, JSS_AUDIO_U16, JSS_AUDIO_STEREO, jvmMix_Stereo_C_FW, jvmMix_Stereo_C_BW, jvmPostProcess_U16_C },
63 { JMIX_C, JSS_AUDIO_S16, JSS_AUDIO_STEREO, jvmMix_Stereo_C_FW, jvmMix_Stereo_C_BW, jvmPostProcess_S16_C },
64 #endif
65 };
66
67 static const int jvmNMixRoutines = sizeof(jvmMixRoutines) / sizeof(jvmMixRoutines[0]);
68
69
70 static int jvmFindMixRoutine(int outFormat, int outChannels, int mixerID)
71 {
72 int i;
73
74 for (i = 0; i < jvmNMixRoutines; i++)
75 {
76 if (jvmMixRoutines[i].outFormat == outFormat &&
77 jvmMixRoutines[i].outChannels == outChannels &&
78 (mixerID == JMIX_AUTO || jvmMixRoutines[i].mixerID == mixerID))
79 return i;
80 }
81
82 return -1;
83 }
84
85
86 JSSMixer *jvmInit(const int outFormat, const int outChannels, const int outFreq, const int mixerID)
87 {
88 JSSMixer *mixer;
89 int mixerIdx;
90
91 // Check settings
92 if (outChannels < 1)
93 {
94 JSSERROR(DMERR_INVALID_ARGS, NULL,
95 "Invalid number of channels %d\n", outChannels);
96 }
97
98 if (outFreq < 4000)
99 {
100 JSSERROR(DMERR_INVALID_ARGS, NULL,
101 "Invalid mixing frequency %d\n", outFreq);
102 }
103
104 /* Select mixing routines:
105 * Here we try to choose the most fitting mixing routines
106 * from the compiled in routines, unless caller is forcing
107 * us to select specific ones.
108 */
109 if (mixerID == JMIX_AUTO)
110 {
111 mixerIdx = jvmFindMixRoutine(outFormat, outChannels, JMIX_SSE);
112 if (mixerIdx < 0)
113 mixerIdx = jvmFindMixRoutine(outFormat, outChannels, JMIX_MMX);
114 if (mixerIdx < 0)
115 mixerIdx = jvmFindMixRoutine(outFormat, outChannels, JMIX_AUTO);
116 }
117 else
118 {
119 mixerIdx = jvmFindMixRoutine(outFormat, outChannels, mixerID);
120 }
121
122 if (mixerIdx < 0)
123 {
124 JSSERROR(DMERR_INVALID_ARGS, NULL,
125 "Could not find mixing routine for outFormat=%d, outChannels=%d, outFreq=%d.\n",
126 outFormat, outChannels, outFreq);
127 return NULL;
128 }
129
130 // Allocate a mixer device structure
131 mixer = dmMalloc0(sizeof(JSSMixer));
132 if (mixer == NULL)
133 {
134 JSSERROR(DMERR_MALLOC, NULL,
135 "Could not allocate mixing device structure.\n");
136 }
137
138 // Initialize variables
139 #ifdef JSS_SUP_THREADS
140 mixer->mutex = dmCreateMutex();
141 #endif
142 mixer->outFormat = outFormat;
143 mixer->outFreq = outFreq;
144 mixer->outChannels = outChannels;
145
146 mixer->jvmMixChannel_FW = jvmMixRoutines[mixerIdx].jvmMixChannel_FW;
147 mixer->jvmMixChannel_BW = jvmMixRoutines[mixerIdx].jvmMixChannel_BW;
148 mixer->jvmPostProcess = jvmMixRoutines[mixerIdx].jvmPostProcess;
149
150 // Allocate addBuffer
151 mixer->addBufSize = outChannels * outFreq * 2;
152 mixer->addBuffer = dmMalloc(mixer->addBufSize * sizeof(JMIXER_ADDBUF_TYPE));
153 if (mixer->addBuffer == NULL)
154 {
155 JSSERROR(DMERR_MALLOC, NULL,
156 "Could not allocate mixing addition buffer.\n");
157 }
158
159 return mixer;
160 }
161
162
163 int jvmClose(JSSMixer * mixer)
164 {
165 if (mixer == NULL)
166 return DMERR_NULLPTR;
167
168 // Deallocate resources
169 #ifdef JSS_SUP_THREADS
170 dmDestroyMutex(mixer->mutex);
171 #endif
172 dmFree(mixer->addBuffer);
173
174 memset(mixer, 0, sizeof(JSSMixer));
175 dmFree(mixer);
176
177 return DMERR_OK;
178 }
179
180
181 int jvmGetSampleSize(JSSMixer *mixer)
182 {
183 int sampSize = 1;
184 assert(mixer);
185
186 switch (mixer->outChannels)
187 {
188 case JSS_AUDIO_STEREO:
189 case JSS_AUDIO_MONO:
190 sampSize = mixer->outChannels;
191 break;
192 default:
193 JSSERROR(DMERR_INVALID_ARGS, -1,
194 "outChannels=%d not stereo or mono!\n", mixer->outChannels);
195 break;
196 }
197
198 switch (mixer->outFormat)
199 {
200 case JSS_AUDIO_U16: sampSize *= sizeof(Uint16); break;
201 case JSS_AUDIO_S16: sampSize *= sizeof(Sint16); break;
202 case JSS_AUDIO_U8: sampSize *= sizeof(Uint8); break;
203 case JSS_AUDIO_S8: sampSize *= sizeof(Sint8); break;
204 default:
205 JSSERROR(DMERR_INVALID_ARGS, -1,
206 "outFormat=%d is not supported!\n", mixer->outFormat);
207 }
208
209 return sampSize;
210 }
211
212
213 int jvmGetSampleRes(JSSMixer *mixer)
214 {
215 int sampRes = 0;
216
217 assert(mixer);
218
219 switch (mixer->outFormat)
220 {
221 case JSS_AUDIO_U16: case JSS_AUDIO_S16: sampRes = 16; break;
222 case JSS_AUDIO_U8: case JSS_AUDIO_S8: sampRes = 8; break;
223 default:
224 JSSERROR(DMERR_INVALID_ARGS, -1,
225 "outFormat=%d is not supported!\n", mixer->outFormat);
226 }
227
228 return sampRes;
229 }
230
231
232 static void jvmMixChannel(JSSMixer *mixer, JSSChannel *chn, JMIXER_ADDBUF_TYPE *addBuffer, const int mixLength)
233 {
234 int mixDone = mixLength, mixResult;
235 JMIXER_ADDBUF_TYPE *ab = addBuffer;
236
237 if (!chn->chPlaying || chn->chMute)
238 return;
239
240 DBG("%s(%p, %d)\n", __FUNCTION__, chn, mixLength);
241
242 while (mixDone > 0)
243 {
244 if (chn->chDirection)
245 {
246 // Channel is playing FORWARDS
247 if (chn->chFlags & jsfLooped)
248 {
249 // Sample is looped
250 if (chn->chFlags & jsfBiDi)
251 {
252 // Bi-directional loop
253 if (chn->chPos.dw >= chn->chLoopE.dw)
254 {
255 DMFixedPoint end;
256 FP_ADD_R(end, chn->chLoopE, chn->chLoopE);
257 FP_SUB_R(chn->chPos, end, chn->chPos);
258 chn->chDirection = FALSE;
259 }
260 }
261 else
262 {
263 // Normal forward loop
264 if (chn->chPos.dw >= chn->chLoopE.dw)
265 {
266 DMFixedPoint diff;
267 FP_SUB_R(diff, chn->chPos, chn->chLoopE);
268 FP_ADD_R(chn->chPos, chn->chLoopS, diff);
269 }
270 }
271 }
272 else
273 {
274 // Normal (non-looped) sample
275 if (chn->chPos.dw >= chn->chSize.dw)
276 {
277 chn->chPlaying = FALSE;
278 return;
279 }
280 }
281 }
282 else
283 {
284 // Channel is playing BACKWARDS
285 if (chn->chFlags & jsfLooped)
286 {
287 // Sample is looped
288 if (chn->chFlags & jsfBiDi)
289 {
290 // Bi-directional loop
291 if (chn->chPos.dw <= chn->chLoopS.dw)
292 {
293 DMFixedPoint start;
294 FP_ADD_R(start, chn->chLoopS, chn->chLoopS);
295 FP_SUB_R(chn->chPos, start, chn->chPos);
296 chn->chDirection = TRUE;
297 }
298 }
299 else
300 {
301 // Normal forward loop
302 if (chn->chPos.dw <= chn->chLoopS.dw)
303 {
304 DMFixedPoint diff;
305 FP_SUB_R(diff, chn->chLoopE, chn->chLoopS);
306 FP_ADD(chn->chPos, diff);
307 }
308 }
309 }
310 else
311 {
312 // Normal (non-looped) sample
313 if (chn->chPos.dw <= 0)
314 {
315 chn->chPlaying = FALSE;
316 return;
317 }
318 }
319 }
320
321 // Call the mixing innerloop functions
322 if (chn->chDirection)
323 {
324 DBG("MIX_FW[%p : %d : ", ab, mixDone);
325 if (chn->chFlags & jsfLooped)
326 {
327 DBG("%d (%x)] {loop}\n", FP_GETH(chn->chLoopE), FP_GETH(chn->chLoopE));
328 mixResult = mixer->jvmMixChannel_FW((void *) mixer, chn,
329 ab, mixDone, chn->chLoopE);
330 }
331 else
332 {
333 DBG("%d (%x)]\n", FP_GETH(chn->chSize), FP_GETH(chn->chSize));
334 mixResult = mixer->jvmMixChannel_FW((void *) mixer, chn,
335 ab, mixDone, chn->chSize);
336 }
337 }
338 else
339 {
340 DBG("MIX_BW[%p : %d : ", ab, mixDone);
341 if (chn->chFlags & jsfLooped)
342 {
343 DBG("%d (%x)] {loop}\n", chn->chLoopS, chn->chLoopS);
344 mixResult = mixer->jvmMixChannel_BW(mixer, chn,
345 ab, mixDone, chn->chLoopS);
346 }
347 else
348 {
349 static const DMFixedPoint zero = { 0 };
350 DBG("%d (%x)]\n", 0, 0);
351 mixResult = mixer->jvmMixChannel_BW(mixer, chn,
352 ab, mixDone, zero);
353 }
354 }
355
356 mixDone -= mixResult;
357 ab += mixResult * mixer->outChannels;
358 }
359
360 #ifdef JSS_DEBUG
361 if (mixDone < 0)
362 JSSWARNING(DMERR_BOUNDS,, "mixDone < 0 in mixing logic loop.\n");
363 #endif
364 }
365
366
367 void jvmRenderAudio(JSSMixer *mixer, void *mixBuffer, const int mixLength)
368 {
369 int i, blockLength, mixLeft;
370 JMIXER_ADDBUF_TYPE *ab;
371
372 JSS_LOCK(mixer);
373
374 assert(mixer != NULL);
375 assert(mixBuffer != NULL);
376 assert(mixLength > 0);
377 assert(mixLength * mixer->outChannels <= mixer->addBufSize);
378
379 // Clear mixer->addBuffer
380 memset(mixer->addBuffer, 0, mixLength * mixer->outChannels * sizeof(JMIXER_ADDBUF_TYPE));
381
382 ab = mixer->addBuffer;
383 mixLeft = mixLength;
384 while (mixLeft > 0)
385 {
386 // Check for callbacks
387 blockLength = mixLeft;
388
389 if (mixer->cbFunction)
390 {
391 if (mixer->cbCounter <= 0)
392 {
393 mixer->cbFunction(mixer, mixer->cbData);
394 mixer->cbCounter = mixer->cbFreq;
395 }
396
397 if (mixer->cbCounter < blockLength)
398 blockLength = mixer->cbCounter;
399 }
400
401 // Do mixing
402 for (i = 0; i < jsetNChannels; i++)
403 {
404 JSSChannel *chn = &(mixer->channels[i]);
405 if (chn->chPlaying && !chn->chMute)
406 jvmMixChannel(mixer, chn, ab, blockLength);
407 }
408
409 /*
410 if (chn->chPlaying)
411 {
412 if (!chn->chMute)
413 jvmMixChannel(mixer, chn, ab, blockLength);
414 else
415 jvmAdvanceChannel(mixer, chn, blockLength);
416 }
417 */
418
419 ab += blockLength * mixer->outChannels;
420 mixLeft -= blockLength;
421 mixer->cbCounter -= blockLength;
422 }
423
424 // Post-process
425 mixer->jvmPostProcess(mixer->addBuffer, mixBuffer, mixLength * mixer->outChannels);
426
427 JSS_UNLOCK(mixer);
428 }
429
430
431 int jvmSetCallback(JSSMixer * mixer, void (*cbFunction) (void *, void *), void *cbData)
432 {
433 assert(mixer);
434
435 if (cbFunction == NULL)
436 JSSERROR(DMERR_NULLPTR, DMERR_NULLPTR, "NULL pointer given as cbFunction");
437
438 JSS_LOCK(mixer);
439
440 mixer->cbFunction = cbFunction;
441 mixer->cbData = cbData;
442
443 JSS_UNLOCK(mixer);
444
445 return DMERR_OK;
446 }
447
448
449 void jvmRemoveCallback(JSSMixer * mixer)
450 {
451 assert(mixer);
452
453 JSS_LOCK(mixer);
454
455 mixer->cbFunction = NULL;
456 mixer->cbData = NULL;
457 mixer->cbFreq = mixer->cbCounter = 0;
458
459 JSS_UNLOCK(mixer);
460 }
461
462
463 int jvmSetCallbackFreq(JSSMixer * mixer, const int cbFreq)
464 {
465 assert(mixer);
466
467 JSS_LOCK(mixer);
468
469 mixer->cbFreq = cbFreq;
470 mixer->cbCounter = 0;
471
472 //fprintf(stderr, "set(outFreq = %d, cbFreq = %d) = %d\n", mixer->outFreq, cbFreq, mixer->cbFreq);
473
474 JSS_UNLOCK(mixer);
475 return DMERR_OK;
476 }
477
478
479 /* Channel manipulation routines
480 */
481 void jvmPlay(JSSMixer * mixer, const int channel)
482 {
483 JSS_LOCK(mixer);
484 mixer->channels[channel].chPlaying = TRUE;
485 JSS_UNLOCK(mixer);
486 }
487
488
489 void jvmStop(JSSMixer * mixer, const int channel)
490 {
491 JSS_LOCK(mixer);
492 mixer->channels[channel].chPlaying = FALSE;
493 JSS_UNLOCK(mixer);
494 }
495
496
497 void jvmReset(JSSMixer * mixer, const int channel)
498 {
499 JSSChannel *c;
500
501 JSS_LOCK(mixer);
502 c = &mixer->channels[channel];
503
504 c->chDirection = TRUE;
505 c->chPos.dw = c->chDeltaO.dw = 0;
506
507 JSS_UNLOCK(mixer);
508 }
509
510
511 void jvmSetSample(JSSMixer * mixer, const int channel,
512 void *data, const Sint32 size, const Sint32 loopS,
513 const Sint32 loopE, const int flags)
514 {
515 JSSChannel *c;
516
517 JSS_LOCK(mixer);
518 c = &mixer->channels[channel];
519
520 FP_SETHL(c->chSize, size, 0);
521 FP_SETHL(c->chLoopS, loopS, 0);
522 FP_SETHL(c->chLoopE, loopE, 0);
523 c->chData = data;
524 c->chFlags = flags;
525 c->chDirection = TRUE;
526 c->chPos.dw = c->chDeltaO.dw = 0;
527
528 JSS_UNLOCK(mixer);
529 }
530
531
532 void jvmSetFreq(JSSMixer * mixer, const int channel, const int freq)
533 {
534 JSS_LOCK(mixer);
535
536 mixer->channels[channel].chFreq = freq;
537
538 if (mixer->outFreq > 0)
539 {
540 DMFixedPoint a, b;
541 FP_SETHL(a, freq, 0);
542 FP_CONV(b, mixer->outFreq);
543 FP_DIV_R(mixer->channels[channel].chDeltaO, a, b);
544 }
545 else
546 {
547 FP_SET(mixer->channels[channel].chDeltaO, 0);
548 }
549
550 JSS_UNLOCK(mixer);
551 }
552
553
554 int jvmGetFreq(JSSMixer * mixer, const int channel)
555 {
556 int tmp;
557
558 JSS_LOCK(mixer);
559 tmp = mixer->channels[channel].chFreq;
560 JSS_UNLOCK(mixer);
561
562 return tmp;
563 }
564
565
566 void jvmSetVolume(JSSMixer * mixer, const int channel, const int volume)
567 {
568 JSS_LOCK(mixer);
569 FP_SETHL(mixer->channels[channel].chVolume, volume, 0);
570 mixer->channels[channel].chVolumeD = 0;
571 mixer->channels[channel].chDeltaV.dw = 0;
572 JSS_UNLOCK(mixer);
573 }
574
575
576 void jvmSetVolumeRamp(JSSMixer * mixer, const int channel, const int start, const int end, const int len)
577 {
578 int tmp;
579 DMFixedPoint a, b;
580 JSS_LOCK(mixer);
581 FP_SETHL(mixer->channels[channel].chVolume, start, 0);
582
583 tmp = mixer->channels[channel].chVolumeD =
584 len > 0 ? ((mixer->outFreq * len) / 1000) : mixer->cbFreq;
585
586 FP_SETHL(a, (end - start), 0);
587 FP_CONV(b, tmp);
588 FP_DIV_R(mixer->channels[channel].chDeltaV, a, b);
589
590 JSS_UNLOCK(mixer);
591 }
592
593
594 int jvmGetVolume(JSSMixer * mixer, const int channel)
595 {
596 int tmp;
597
598 JSS_LOCK(mixer);
599 tmp = FP_GETH(mixer->channels[channel].chVolume);
600 JSS_UNLOCK(mixer);
601
602 return tmp;
603 }
604
605
606 void jvmSetPos(JSSMixer * mixer, const int channel, const Sint32 pos)
607 {
608 JSS_LOCK(mixer);
609 FP_SETHL(mixer->channels[channel].chPos, pos, 0);
610 JSS_UNLOCK(mixer);
611 }
612
613
614 Sint32 jvmGetPos(JSSMixer * mixer, const int channel)
615 {
616 Sint32 tmp;
617
618 JSS_LOCK(mixer);
619 tmp = FP_GETH(mixer->channels[channel].chPos);
620 JSS_UNLOCK(mixer);
621
622 return tmp;
623 }
624
625
626 void jvmSetPan(JSSMixer * mixer, const int channel, const int panning)
627 {
628 JSS_LOCK(mixer);
629 FP_SETHL(mixer->channels[channel].chPanning, panning, 0);
630 mixer->channels[channel].chPanningD = 0;
631 mixer->channels[channel].chDeltaP.dw = 0;
632 JSS_UNLOCK(mixer);
633 }
634
635
636 void jvmSetPanRamp(JSSMixer * mixer, const int channel, const int start, const int end, const int len)
637 {
638 int tmp;
639 DMFixedPoint a, b;
640 JSS_LOCK(mixer);
641
642 FP_SETHL(mixer->channels[channel].chPanning, start, 0);
643
644 tmp = mixer->channels[channel].chPanningD =
645 len > 0 ? ((mixer->outFreq * len) / 1000) : mixer->cbFreq;
646
647 FP_SETHL(a, (end - start), 0);
648 FP_CONV(b, tmp);
649 FP_DIV_R(mixer->channels[channel].chDeltaP, a, b);
650
651 JSS_UNLOCK(mixer);
652 }
653
654
655 int jvmGetPan(JSSMixer * mixer, const int channel)
656 {
657 int tmp;
658
659 JSS_LOCK(mixer);
660 tmp = FP_GETH(mixer->channels[channel].chPanning);
661 JSS_UNLOCK(mixer);
662
663 return tmp;
664 }
665
666
667 void jvmMute(JSSMixer * mixer, const int channel, const BOOL mute)
668 {
669 JSS_LOCK(mixer);
670 mixer->channels[channel].chMute = mute;
671 JSS_UNLOCK(mixer);
672 }
673
674
675 BOOL jvmGetMute(JSSMixer * mixer, const int channel)
676 {
677 BOOL tmp;
678
679 JSS_LOCK(mixer);
680 tmp = mixer->channels[channel].chMute;
681 JSS_UNLOCK(mixer);
682
683 return tmp;
684 }
685
686
687 void jvmClear(JSSMixer * mixer, const int channel)
688 {
689 JSS_LOCK(mixer);
690 memset(&mixer->channels[channel], 0, sizeof(JSSChannel));
691 JSS_UNLOCK(mixer);
692 }
693
694
695 void jvmSetGlobalVol(JSSMixer * mixer, const int volume)
696 {
697 JSS_LOCK(mixer);
698 mixer->globalVol = volume;
699 JSS_UNLOCK(mixer);
700 }
701
702
703 int jvmGetGlobalVol(JSSMixer * mixer)
704 {
705 int tmp;
706
707 JSS_LOCK(mixer);
708 tmp = mixer->globalVol;
709 JSS_UNLOCK(mixer);
710
711 return tmp;
712 }