inetcomm/tests: Return interface pointer for test stream.
[wine.git] / dlls / msacm32 / pcmconverter.c
blob70ec62fd2fd112d42b8483724fe69a50e2150efc
1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
3 /*
4 * MSACM32 library
6 * Copyright 2000 Eric Pouech
7 * Copyright 2004 Robert Reif
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 * FIXME / TODO list
24 * + get rid of hack for PCM_DriverProc (msacm32.dll shouldn't export
25 * a DriverProc, but this would require implementing a generic
26 * embedded driver handling scheme in msacm32.dll which isn't done yet
29 #include "config.h"
31 #include <assert.h>
32 #include <stdarg.h>
33 #include <string.h>
35 #include "windef.h"
36 #include "winbase.h"
37 #include "mmsystem.h"
38 #define NOBITMAP
39 #include "mmreg.h"
40 #include "msacm.h"
41 #include "wingdi.h"
42 #include "winnls.h"
43 #include "winuser.h"
45 #include "msacmdrv.h"
46 #include "wineacm.h"
48 #include "wine/debug.h"
50 WINE_DEFAULT_DEBUG_CHANNEL(msacm);
52 /***********************************************************************
53 * PCM_drvOpen
55 static DWORD PCM_drvOpen(LPCSTR str, PACMDRVOPENDESCW adod)
57 TRACE("(%p, %p)\n", str, adod);
59 return (adod == NULL) ||
60 (adod->fccType == ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC &&
61 adod->fccComp == ACMDRIVERDETAILS_FCCCOMP_UNDEFINED);
64 /***********************************************************************
65 * PCM_drvClose
67 static DWORD PCM_drvClose(DWORD dwDevID)
69 TRACE("(%d)\n", dwDevID);
71 return 1;
74 #define NUM_PCM_FORMATS (sizeof(PCM_Formats) / sizeof(PCM_Formats[0]))
75 #define NUM_OF(a,b) ((a)/(b))
77 /* flags for fdwDriver */
78 #define PCM_RESAMPLE 1
80 /* data used while converting */
81 typedef struct tagAcmPcmData {
82 /* conversion routine, depending if rate conversion is required */
83 union {
84 void (*cvtKeepRate)(const unsigned char*, int, unsigned char*);
85 void (*cvtChangeRate)(DWORD, const unsigned char*, LPDWORD,
86 DWORD, unsigned char*, LPDWORD);
87 } cvt;
88 } AcmPcmData;
90 /* table to list all supported formats... those are the basic ones. this
91 * also helps given a unique index to each of the supported formats
93 static const struct {
94 int nChannels;
95 int nBits;
96 int rate;
97 } PCM_Formats[] = {
98 {1, 8, 8000}, {2, 8, 8000}, {1, 16, 8000}, {2, 16, 8000}, {1, 24, 8000}, {2, 24, 8000},
99 {1, 8, 11025}, {2, 8, 11025}, {1, 16, 11025}, {2, 16, 11025}, {1, 24, 11025}, {2, 24, 11025},
100 {1, 8, 22050}, {2, 8, 22050}, {1, 16, 22050}, {2, 16, 22050}, {1, 24, 22050}, {2, 24, 22050},
101 {1, 8, 44100}, {2, 8, 44100}, {1, 16, 44100}, {2, 16, 44100}, {1, 24, 44100}, {2, 24, 44100},
102 {1, 8, 48000}, {2, 8, 48000}, {1, 16, 48000}, {2, 16, 48000}, {1, 24, 48000}, {2, 24, 48000},
103 {1, 8, 96000}, {2, 8, 96000}, {1, 16, 96000}, {2, 16, 96000}, {1, 24, 96000}, {2, 24, 96000},
106 /***********************************************************************
107 * PCM_GetFormatIndex
109 static DWORD PCM_GetFormatIndex(LPWAVEFORMATEX wfx)
111 unsigned int i;
112 TRACE("(%p)\n", wfx);
114 for (i = 0; i < NUM_PCM_FORMATS; i++) {
115 if (wfx->nChannels == PCM_Formats[i].nChannels &&
116 wfx->nSamplesPerSec == PCM_Formats[i].rate &&
117 wfx->wBitsPerSample == PCM_Formats[i].nBits)
118 return i;
120 return 0xFFFFFFFF;
123 /* PCM Conversions:
125 * parameters:
126 * + 8 bit unsigned vs 16 bit signed
127 * + mono vs stereo (1 or 2 channels)
128 * + sampling rate (8.0, 11.025, 22.05, 44.1 kHz are defined, but algo
129 * shall work in all cases)
131 * mono => stereo: copy the same sample on Left & Right channels
132 * stereo => mono: use the sum of Left & Right channels
135 /***********************************************************************
136 * C816
138 * Converts a 8 bit sample to a 16 bit one
140 static inline short C816(unsigned char b)
142 return (b - 128) << 8;
145 /***********************************************************************
146 * C168
148 * Converts a 16 bit sample to a 8 bit one (data loss !!)
150 static inline unsigned char C168(short s)
152 return HIBYTE(s) ^ (unsigned char)0x80;
155 /***********************************************************************
156 * C248
158 * Converts a 24 bit sample to a 8 bit one (data loss !!)
160 static inline unsigned char C248(int s)
162 return HIBYTE(HIWORD(s)) ^ (unsigned char)0x80;
165 /***********************************************************************
166 * C2416
168 * Converts a 24 bit sample to a 16 bit one (data loss !!)
170 static inline short C2416(int s)
172 return HIWORD(s);
175 /***********************************************************************
176 * R16
178 * Read a 16 bit sample (correctly handles endianness)
180 static inline short R16(const unsigned char* src)
182 return (short)((unsigned short)src[0] | ((unsigned short)src[1] << 8));
185 /***********************************************************************
186 * R24
188 * Read a 24 bit sample (correctly handles endianness)
189 * Note, to support signed arithmetic, the values are shifted high in the int
190 * and low 8 bytes are unused.
192 static inline int R24(const unsigned char* src)
194 return ((int)src[0] | (int)src[1] << 8 | (int)src[2] << 16) << 8;
197 /***********************************************************************
198 * W16
200 * Write a 16 bit sample (correctly handles endianness)
202 static inline void W16(unsigned char* dst, short s)
204 dst[0] = LOBYTE(s);
205 dst[1] = HIBYTE(s);
208 /***********************************************************************
209 * W24
211 * Write a 24 bit sample (correctly handles endianness)
213 static inline void W24(unsigned char* dst, int s)
215 dst[0] = HIBYTE(LOWORD(s));
216 dst[1] = LOBYTE(HIWORD(s));
217 dst[2] = HIBYTE(HIWORD(s));
220 /***********************************************************************
221 * M24
223 * Convert the (l,r) 24 bit stereo sample into a 24 bit mono
224 * (takes the sum of the two values)
226 static inline int M24(int l, int r)
228 LONGLONG sum = l + r;
230 /* clip sum to saturation */
231 if (sum > 0x7fffff00)
232 sum = 0x7fffff00;
233 else if (sum < -0x7fffff00)
234 sum = -0x7fffff00;
236 return sum;
239 /***********************************************************************
240 * M16
242 * Convert the (l,r) 16 bit stereo sample into a 16 bit mono
243 * (takes the sum of the two values)
245 static inline short M16(short l, short r)
247 int sum = l + r;
249 /* clip sum to saturation */
250 if (sum > 32767)
251 sum = 32767;
252 else if (sum < -32768)
253 sum = -32768;
255 return sum;
258 /***********************************************************************
259 * M8
261 * Convert the (l,r) 8 bit stereo sample into a 8 bit mono
262 * (takes the sum of the two values)
264 static inline unsigned char M8(unsigned char a, unsigned char b)
266 int l = a - 128;
267 int r = b - 128;
268 int sum = (l + r) + 128;
270 /* clip sum to saturation */
271 if (sum > 0xff)
272 sum = 0xff;
273 else if (sum < 0)
274 sum = 0;
276 return sum;
279 /* the conversion routines without rate conversion are labelled cvt<X><Y><N><M>K
280 * where :
281 * <X> is the (M)ono/(S)tereo configuration of input channel
282 * <Y> is the (M)ono/(S)tereo configuration of output channel
283 * <N> is the number of bits of input channel (8 or 16)
284 * <M> is the number of bits of output channel (8 or 16)
286 * in the parameters, ns is always the number of samples, so the size of input
287 * buffer (resp output buffer) is ns * (<X> == 'Mono' ? 1:2) * (<N> == 8 ? 1:2)
290 static void cvtMM88K(const unsigned char* src, int ns, unsigned char* dst)
292 TRACE("(%p, %d, %p)\n", src, ns, dst);
293 memcpy(dst, src, ns);
296 static void cvtSS88K(const unsigned char* src, int ns, unsigned char* dst)
298 TRACE("(%p, %d, %p)\n", src, ns, dst);
299 memcpy(dst, src, ns * 2);
302 static void cvtMM1616K(const unsigned char* src, int ns, unsigned char* dst)
304 TRACE("(%p, %d, %p)\n", src, ns, dst);
305 memcpy(dst, src, ns * 2);
308 static void cvtSS1616K(const unsigned char* src, int ns, unsigned char* dst)
310 TRACE("(%p, %d, %p)\n", src, ns, dst);
311 memcpy(dst, src, ns * 4);
314 static void cvtMS88K(const unsigned char* src, int ns, unsigned char* dst)
316 TRACE("(%p, %d, %p)\n", src, ns, dst);
318 while (ns--) {
319 *dst++ = *src;
320 *dst++ = *src++;
324 static void cvtMS816K(const unsigned char* src, int ns, unsigned char* dst)
326 short v;
327 TRACE("(%p, %d, %p)\n", src, ns, dst);
329 while (ns--) {
330 v = C816(*src++);
331 W16(dst, v); dst += 2;
332 W16(dst, v); dst += 2;
336 static void cvtMS168K(const unsigned char* src, int ns, unsigned char* dst)
338 unsigned char v;
339 TRACE("(%p, %d, %p)\n", src, ns, dst);
341 while (ns--) {
342 v = C168(R16(src)); src += 2;
343 *dst++ = v;
344 *dst++ = v;
348 static void cvtMS1616K(const unsigned char* src, int ns, unsigned char* dst)
350 short v;
351 TRACE("(%p, %d, %p)\n", src, ns, dst);
353 while (ns--) {
354 v = R16(src); src += 2;
355 W16(dst, v); dst += 2;
356 W16(dst, v); dst += 2;
360 static void cvtSM88K(const unsigned char* src, int ns, unsigned char* dst)
362 TRACE("(%p, %d, %p)\n", src, ns, dst);
364 while (ns--) {
365 *dst++ = M8(src[0], src[1]);
366 src += 2;
370 static void cvtSM816K(const unsigned char* src, int ns, unsigned char* dst)
372 short v;
373 TRACE("(%p, %d, %p)\n", src, ns, dst);
375 while (ns--) {
376 v = M16(C816(src[0]), C816(src[1]));
377 src += 2;
378 W16(dst, v); dst += 2;
382 static void cvtSM168K(const unsigned char* src, int ns, unsigned char* dst)
384 TRACE("(%p, %d, %p)\n", src, ns, dst);
386 while (ns--) {
387 *dst++ = C168(M16(R16(src), R16(src + 2)));
388 src += 4;
392 static void cvtSM1616K(const unsigned char* src, int ns, unsigned char* dst)
394 TRACE("(%p, %d, %p)\n", src, ns, dst);
396 while (ns--) {
397 W16(dst, M16(R16(src),R16(src+2))); dst += 2;
398 src += 4;
402 static void cvtMM816K(const unsigned char* src, int ns, unsigned char* dst)
404 TRACE("(%p, %d, %p)\n", src, ns, dst);
406 while (ns--) {
407 W16(dst, C816(*src++)); dst += 2;
411 static void cvtSS816K(const unsigned char* src, int ns, unsigned char* dst)
413 TRACE("(%p, %d, %p)\n", src, ns, dst);
415 while (ns--) {
416 W16(dst, C816(*src++)); dst += 2;
417 W16(dst, C816(*src++)); dst += 2;
421 static void cvtMM168K(const unsigned char* src, int ns, unsigned char* dst)
423 TRACE("(%p, %d, %p)\n", src, ns, dst);
425 while (ns--) {
426 *dst++ = C168(R16(src)); src += 2;
430 static void cvtSS168K(const unsigned char* src, int ns, unsigned char* dst)
432 TRACE("(%p, %d, %p)\n", src, ns, dst);
434 while (ns--) {
435 *dst++ = C168(R16(src)); src += 2;
436 *dst++ = C168(R16(src)); src += 2;
440 static void cvtMS248K(const unsigned char* src, int ns, unsigned char* dst)
442 unsigned char v;
443 TRACE("(%p, %d, %p)\n", src, ns, dst);
445 while (ns--) {
446 v = C248(R24(src)); src += 3;
447 *dst++ = v;
448 *dst++ = v;
452 static void cvtSM248K(const unsigned char* src, int ns, unsigned char* dst)
454 TRACE("(%p, %d, %p)\n", src, ns, dst);
456 while (ns--) {
457 *dst++ = C248(M24(R24(src), R24(src + 3)));
458 src += 6;
462 static void cvtMM248K(const unsigned char* src, int ns, unsigned char* dst)
464 TRACE("(%p, %d, %p)\n", src, ns, dst);
466 while (ns--) {
467 *dst++ = C248(R24(src)); src += 3;
471 static void cvtSS248K(const unsigned char* src, int ns, unsigned char* dst)
473 TRACE("(%p, %d, %p)\n", src, ns, dst);
475 while (ns--) {
476 *dst++ = C248(R24(src)); src += 3;
477 *dst++ = C248(R24(src)); src += 3;
481 static void cvtMS2416K(const unsigned char* src, int ns, unsigned char* dst)
483 short v;
484 TRACE("(%p, %d, %p)\n", src, ns, dst);
486 while (ns--) {
487 v = C2416(R24(src)); src += 3;
488 W16(dst, v); dst += 2;
489 W16(dst, v); dst += 2;
493 static void cvtSM2416K(const unsigned char* src, int ns, unsigned char* dst)
495 TRACE("(%p, %d, %p)\n", src, ns, dst);
497 while (ns--) {
498 W16(dst, C2416(M24(R24(src), R24(src + 3))));
499 dst += 2;
500 src += 6;
504 static void cvtMM2416K(const unsigned char* src, int ns, unsigned char* dst)
506 TRACE("(%p, %d, %p)\n", src, ns, dst);
508 while (ns--) {
509 W16(dst, C2416(R24(src))); dst += 2; src += 3;
513 static void cvtSS2416K(const unsigned char* src, int ns, unsigned char* dst)
515 TRACE("(%p, %d, %p)\n", src, ns, dst);
517 while (ns--) {
518 W16(dst, C2416(R24(src))); dst += 2; src += 3;
519 W16(dst, C2416(R24(src))); dst += 2; src += 3;
524 typedef void (*PCM_CONVERT_KEEP_RATE)(const unsigned char*, int, unsigned char*);
526 static const PCM_CONVERT_KEEP_RATE PCM_ConvertKeepRate[] = {
527 cvtSS88K, cvtSM88K, cvtMS88K, cvtMM88K,
528 cvtSS816K, cvtSM816K, cvtMS816K, cvtMM816K,
529 NULL, NULL, NULL, NULL, /* TODO: 8->24 */
530 cvtSS168K, cvtSM168K, cvtMS168K, cvtMM168K,
531 cvtSS1616K, cvtSM1616K, cvtMS1616K, cvtMM1616K,
532 NULL, NULL, NULL, NULL, /* TODO: 16->24 */
533 cvtSS248K, cvtSM248K, cvtMS248K, cvtMM248K,
534 cvtSS2416K, cvtSM2416K, cvtMS2416K, cvtMM2416K,
535 NULL, NULL, NULL, NULL, /* TODO: 24->24 */
538 /* the conversion routines with rate conversion are labelled cvt<X><Y><N><M>C
539 * where :
540 * <X> is the (M)ono/(S)tereo configuration of input channel
541 * <Y> is the (M)ono/(S)tereo configuration of output channel
542 * <N> is the number of bits of input channel (8 or 16)
543 * <M> is the number of bits of output channel (8 or 16)
546 static void cvtSS88C(DWORD srcRate, const unsigned char* src, LPDWORD nsrc,
547 DWORD dstRate, unsigned char* dst, LPDWORD ndst)
549 DWORD error = dstRate / 2;
550 TRACE("(%d, %p, %p, %d, %p, %p)\n", srcRate, src, nsrc, dstRate, dst, ndst);
552 while ((*ndst)--) {
553 *dst++ = *src;
554 *dst++ = *src;
555 error = error + srcRate;
556 while (error > dstRate) {
557 src += 2;
558 (*nsrc)--;
559 if (*nsrc == 0)
560 return;
561 error = error - dstRate;
566 static void cvtSM88C(DWORD srcRate, const unsigned char* src, LPDWORD nsrc,
567 DWORD dstRate, unsigned char* dst, LPDWORD ndst)
569 DWORD error = dstRate / 2;
570 TRACE("(%d, %p, %p, %d, %p, %p)\n", srcRate, src, nsrc, dstRate, dst, ndst);
572 while ((*ndst)--) {
573 *dst++ = M8(src[0], src[1]);
574 error = error + srcRate;
575 while (error > dstRate) {
576 src += 2;
577 (*nsrc)--;
578 if (*nsrc == 0)
579 return;
580 error = error - dstRate;
585 static void cvtMS88C(DWORD srcRate, const unsigned char* src, LPDWORD nsrc,
586 DWORD dstRate, unsigned char* dst, LPDWORD ndst)
588 DWORD error = dstRate / 2;
589 TRACE("(%d, %p, %p, %d, %p, %p)\n", srcRate, src, nsrc, dstRate, dst, ndst);
591 while ((*ndst)--) {
592 *dst++ = *src;
593 *dst++ = *src;
594 error = error + srcRate;
595 while (error > dstRate) {
596 src++;
597 (*nsrc)--;
598 if (*nsrc == 0)
599 return;
600 error = error - dstRate;
605 static void cvtMM88C(DWORD srcRate, const unsigned char* src, LPDWORD nsrc,
606 DWORD dstRate, unsigned char* dst, LPDWORD ndst)
608 DWORD error = dstRate / 2;
609 TRACE("(%d, %p, %p, %d, %p, %p)\n", srcRate, src, nsrc, dstRate, dst, ndst);
611 while ((*ndst)--) {
612 *dst++ = *src;
613 error = error + srcRate;
614 while (error > dstRate) {
615 src++;
616 (*nsrc)--;
617 if (*nsrc==0)
618 return;
619 error = error - dstRate;
624 static void cvtSS816C(DWORD srcRate, const unsigned char* src, LPDWORD nsrc,
625 DWORD dstRate, unsigned char* dst, LPDWORD ndst)
627 DWORD error = dstRate / 2;
628 TRACE("(%d, %p, %p, %d, %p, %p)\n", srcRate, src, nsrc, dstRate, dst, ndst);
630 while ((*ndst)--) {
631 W16(dst, C816(src[0])); dst += 2;
632 W16(dst, C816(src[1])); dst += 2;
633 error = error + srcRate;
634 while (error > dstRate) {
635 src += 2;
636 (*nsrc)--;
637 if (*nsrc==0)
638 return;
639 error = error - dstRate;
644 static void cvtSM816C(DWORD srcRate, const unsigned char* src, LPDWORD nsrc,
645 DWORD dstRate, unsigned char* dst, LPDWORD ndst)
647 DWORD error = dstRate / 2;
648 TRACE("(%d, %p, %p, %d, %p, %p)\n", srcRate, src, nsrc, dstRate, dst, ndst);
650 while ((*ndst)--) {
651 W16(dst, M16(C816(src[0]), C816(src[1]))); dst += 2;
652 error = error + srcRate;
653 while (error > dstRate) {
654 src += 2;
655 (*nsrc)--;
656 if (*nsrc==0)
657 return;
658 error = error - dstRate;
663 static void cvtMS816C(DWORD srcRate, const unsigned char* src, LPDWORD nsrc,
664 DWORD dstRate, unsigned char* dst, LPDWORD ndst)
666 DWORD error = dstRate / 2;
667 TRACE("(%d, %p, %p, %d, %p, %p)\n", srcRate, src, nsrc, dstRate, dst, ndst);
669 while ((*ndst)--) {
670 W16(dst, C816(*src)); dst += 2;
671 W16(dst, C816(*src)); dst += 2;
672 error = error + srcRate;
673 while (error > dstRate) {
674 src++;
675 (*nsrc)--;
676 if (*nsrc==0)
677 return;
678 error = error - dstRate;
683 static void cvtMM816C(DWORD srcRate, const unsigned char* src, LPDWORD nsrc,
684 DWORD dstRate, unsigned char* dst, LPDWORD ndst)
686 DWORD error = dstRate / 2;
687 TRACE("(%d, %p, %p, %d, %p, %p)\n", srcRate, src, nsrc, dstRate, dst, ndst);
689 while ((*ndst)--) {
690 W16(dst, C816(*src)); dst += 2;
691 error = error + srcRate;
692 while (error > dstRate) {
693 src++;
694 (*nsrc)--;
695 if (*nsrc==0)
696 return;
697 error = error - dstRate;
702 static void cvtSS168C(DWORD srcRate, const unsigned char* src, LPDWORD nsrc,
703 DWORD dstRate, unsigned char* dst, LPDWORD ndst)
705 DWORD error = dstRate / 2;
706 TRACE("(%d, %p, %p, %d, %p, %p)\n", srcRate, src, nsrc, dstRate, dst, ndst);
708 while ((*ndst)--) {
709 *dst++ = C168(R16(src));
710 *dst++ = C168(R16(src + 2));
711 error = error + srcRate;
712 while (error > dstRate) {
713 src += 4;
714 (*nsrc)--;
715 if (*nsrc==0)
716 return;
717 error = error - dstRate;
722 static void cvtSM168C(DWORD srcRate, const unsigned char* src, LPDWORD nsrc,
723 DWORD dstRate, unsigned char* dst, LPDWORD ndst)
725 DWORD error = dstRate / 2;
726 TRACE("(%d, %p, %p, %d, %p, %p)\n", srcRate, src, nsrc, dstRate, dst, ndst);
728 while ((*ndst)--) {
729 *dst++ = C168(M16(R16(src), R16(src + 2)));
730 error = error + srcRate;
731 while (error > dstRate) {
732 src += 4;
733 (*nsrc)--;
734 if (*nsrc==0)
735 return;
736 error = error - dstRate;
741 static void cvtMS168C(DWORD srcRate, const unsigned char* src, LPDWORD nsrc,
742 DWORD dstRate, unsigned char* dst, LPDWORD ndst)
744 DWORD error = dstRate / 2;
745 TRACE("(%d, %p, %p, %d, %p, %p)\n", srcRate, src, nsrc, dstRate, dst, ndst);
747 while ((*ndst)--) {
748 *dst++ = C168(R16(src));
749 *dst++ = C168(R16(src));
750 error = error + srcRate;
751 while (error > dstRate) {
752 src += 2;
753 (*nsrc)--;
754 if (*nsrc==0)
755 return;
756 error = error - dstRate;
761 static void cvtMM168C(DWORD srcRate, const unsigned char* src, LPDWORD nsrc,
762 DWORD dstRate, unsigned char* dst, LPDWORD ndst)
764 DWORD error = dstRate / 2;
765 TRACE("(%d, %p, %p, %d, %p, %p)\n", srcRate, src, nsrc, dstRate, dst, ndst);
767 while ((*ndst)--) {
768 *dst++ = C168(R16(src));
769 error = error + srcRate;
770 while (error > dstRate) {
771 src += 2;
772 (*nsrc)--;
773 if (*nsrc == 0)
774 return;
775 error = error - dstRate;
780 static void cvtSS1616C(DWORD srcRate, const unsigned char* src, LPDWORD nsrc,
781 DWORD dstRate, unsigned char* dst, LPDWORD ndst)
783 DWORD error = dstRate / 2;
784 TRACE("(%d, %p, %p, %d, %p, %p)\n", srcRate, src, nsrc, dstRate, dst, ndst);
786 while ((*ndst)--) {
787 W16(dst, R16(src)); dst += 2;
788 W16(dst, R16(src)); dst += 2;
789 error = error + srcRate;
790 while (error > dstRate) {
791 src += 4;
792 (*nsrc)--;
793 if (*nsrc == 0)
794 return;
795 error = error - dstRate;
800 static void cvtSM1616C(DWORD srcRate, const unsigned char* src, LPDWORD nsrc,
801 DWORD dstRate, unsigned char* dst, LPDWORD ndst)
803 DWORD error = dstRate / 2;
804 TRACE("(%d, %p, %p, %d, %p, %p)\n", srcRate, src, nsrc, dstRate, dst, ndst);
806 while ((*ndst)--) {
807 W16(dst, M16(R16(src), R16(src + 2))); dst += 2;
808 error = error + srcRate;
809 while (error > dstRate) {
810 src += 4;
811 (*nsrc)--;
812 if (*nsrc == 0)
813 return;
814 error = error - dstRate;
819 static void cvtMS1616C(DWORD srcRate, const unsigned char* src, LPDWORD nsrc,
820 DWORD dstRate, unsigned char* dst, LPDWORD ndst)
822 DWORD error = dstRate / 2;
823 TRACE("(%d, %p, %p, %d, %p, %p)\n", srcRate, src, nsrc, dstRate, dst, ndst);
825 while((*ndst)--) {
826 W16(dst, R16(src)); dst += 2;
827 W16(dst, R16(src)); dst += 2;
828 error = error + srcRate;
829 while (error > dstRate) {
830 src += 2;
831 (*nsrc)--;
832 if (*nsrc == 0)
833 return;
834 error = error - dstRate;
839 static void cvtMM1616C(DWORD srcRate, const unsigned char* src, LPDWORD nsrc,
840 DWORD dstRate, unsigned char* dst, LPDWORD ndst)
842 DWORD error = dstRate / 2;
843 TRACE("(%d, %p, %p, %d, %p, %p)\n", srcRate, src, nsrc, dstRate, dst, ndst);
845 while ((*ndst)--) {
846 W16(dst, R16(src)); dst += 2;
847 error = error + srcRate;
848 while (error > dstRate) {
849 src += 2;
850 (*nsrc)--;
851 if (*nsrc == 0)
852 return;
853 error = error - dstRate;
858 static void cvtSS2424C(DWORD srcRate, const unsigned char* src, LPDWORD nsrc,
859 DWORD dstRate, unsigned char* dst, LPDWORD ndst)
861 DWORD error = dstRate / 2;
862 TRACE("(%d, %p, %p, %d, %p, %p)\n", srcRate, src, nsrc, dstRate, dst, ndst);
864 while ((*ndst)--) {
865 W24(dst, R24(src)); dst += 3;
866 W24(dst, R24(src)); dst += 3;
867 error = error + srcRate;
868 while (error > dstRate) {
869 src += 6;
870 (*nsrc)--;
871 if (*nsrc == 0)
872 return;
873 error = error - dstRate;
878 static void cvtSM2424C(DWORD srcRate, const unsigned char* src, LPDWORD nsrc,
879 DWORD dstRate, unsigned char* dst, LPDWORD ndst)
881 DWORD error = dstRate / 2;
882 TRACE("(%d, %p, %p, %d, %p, %p)\n", srcRate, src, nsrc, dstRate, dst, ndst);
884 while ((*ndst)--) {
885 W24(dst, M24(R24(src), R24(src + 3))); dst += 3;
886 error = error + srcRate;
887 while (error > dstRate) {
888 src += 6;
889 (*nsrc)--;
890 if (*nsrc == 0)
891 return;
892 error = error - dstRate;
897 static void cvtMS2424C(DWORD srcRate, const unsigned char* src, LPDWORD nsrc,
898 DWORD dstRate, unsigned char* dst, LPDWORD ndst)
900 DWORD error = dstRate / 2;
901 TRACE("(%d, %p, %p, %d, %p, %p)\n", srcRate, src, nsrc, dstRate, dst, ndst);
903 while((*ndst)--) {
904 W24(dst, R24(src)); dst += 3;
905 W24(dst, R24(src)); dst += 3;
906 error = error + srcRate;
907 while (error > dstRate) {
908 src += 3;
909 (*nsrc)--;
910 if (*nsrc == 0)
911 return;
912 error = error - dstRate;
917 static void cvtMM2424C(DWORD srcRate, const unsigned char* src, LPDWORD nsrc,
918 DWORD dstRate, unsigned char* dst, LPDWORD ndst)
920 DWORD error = dstRate / 2;
921 TRACE("(%d, %p, %p, %d, %p, %p)\n", srcRate, src, nsrc, dstRate, dst, ndst);
923 while ((*ndst)--) {
924 W24(dst, R24(src)); dst += 3;
925 error = error + srcRate;
926 while (error > dstRate) {
927 src += 3;
928 (*nsrc)--;
929 if (*nsrc == 0)
930 return;
931 error = error - dstRate;
936 typedef void (*PCM_CONVERT_CHANGE_RATE)(DWORD, const unsigned char*, LPDWORD, DWORD, unsigned char*, LPDWORD);
938 static const PCM_CONVERT_CHANGE_RATE PCM_ConvertChangeRate[] = {
939 cvtSS88C, cvtSM88C, cvtMS88C, cvtMM88C,
940 cvtSS816C, cvtSM816C, cvtMS816C, cvtMM816C,
941 NULL, NULL, NULL, NULL, /* TODO: 8->24 */
942 cvtSS168C, cvtSM168C, cvtMS168C, cvtMM168C,
943 cvtSS1616C, cvtSM1616C, cvtMS1616C, cvtMM1616C,
944 NULL, NULL, NULL, NULL, /* TODO: 16->24 */
945 NULL, NULL, NULL, NULL, /* TODO: 24->8 */
946 NULL, NULL, NULL, NULL, /* TODO: 24->16 */
947 cvtSS2424C, cvtSM2424C, cvtMS2424C, cvtMM2424C,
950 /***********************************************************************
951 * PCM_DriverDetails
954 static LRESULT PCM_DriverDetails(PACMDRIVERDETAILSW add)
956 TRACE("(%p)\n", add);
958 add->fccType = ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC;
959 add->fccComp = ACMDRIVERDETAILS_FCCCOMP_UNDEFINED;
960 add->wMid = MM_MICROSOFT;
961 add->wPid = MM_MSFT_ACM_PCM;
962 add->vdwACM = 0x01000000;
963 add->vdwDriver = 0x01000000;
964 add->fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CONVERTER;
965 add->cFormatTags = 1;
966 add->cFilterTags = 0;
967 add->hicon = NULL;
968 MultiByteToWideChar( CP_ACP, 0, "MS-PCM", -1,
969 add->szShortName, sizeof(add->szShortName)/sizeof(WCHAR) );
970 MultiByteToWideChar( CP_ACP, 0, "Wine PCM converter", -1,
971 add->szLongName, sizeof(add->szLongName)/sizeof(WCHAR) );
972 MultiByteToWideChar( CP_ACP, 0, "Brought to you by the Wine team...", -1,
973 add->szCopyright, sizeof(add->szCopyright)/sizeof(WCHAR) );
974 MultiByteToWideChar( CP_ACP, 0, "Refer to LICENSE file", -1,
975 add->szLicensing, sizeof(add->szLicensing)/sizeof(WCHAR) );
976 add->szFeatures[0] = 0;
978 return MMSYSERR_NOERROR;
981 /***********************************************************************
982 * PCM_FormatTagDetails
985 static LRESULT PCM_FormatTagDetails(PACMFORMATTAGDETAILSW aftd, DWORD dwQuery)
987 TRACE("(%p, %08x)\n", aftd, dwQuery);
989 switch (dwQuery) {
990 case ACM_FORMATTAGDETAILSF_INDEX:
991 if (aftd->dwFormatTagIndex != 0) {
992 WARN("not possible\n");
993 return ACMERR_NOTPOSSIBLE;
995 break;
996 case ACM_FORMATTAGDETAILSF_FORMATTAG:
997 if (aftd->dwFormatTag != WAVE_FORMAT_PCM) {
998 WARN("not possible\n");
999 return ACMERR_NOTPOSSIBLE;
1001 break;
1002 case ACM_FORMATTAGDETAILSF_LARGESTSIZE:
1003 if (aftd->dwFormatTag != WAVE_FORMAT_UNKNOWN &&
1004 aftd->dwFormatTag != WAVE_FORMAT_PCM) {
1005 WARN("not possible\n");
1006 return ACMERR_NOTPOSSIBLE;
1008 break;
1009 default:
1010 WARN("Unsupported query %08x\n", dwQuery);
1011 return MMSYSERR_NOTSUPPORTED;
1014 aftd->dwFormatTagIndex = 0;
1015 aftd->dwFormatTag = WAVE_FORMAT_PCM;
1016 aftd->cbFormatSize = sizeof(PCMWAVEFORMAT);
1017 aftd->fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CONVERTER;
1018 aftd->cStandardFormats = NUM_PCM_FORMATS;
1019 aftd->szFormatTag[0] = 0;
1021 return MMSYSERR_NOERROR;
1024 /***********************************************************************
1025 * PCM_FormatDetails
1028 static LRESULT PCM_FormatDetails(PACMFORMATDETAILSW afd, DWORD dwQuery)
1030 TRACE("(%p, %08x)\n", afd, dwQuery);
1032 switch (dwQuery) {
1033 case ACM_FORMATDETAILSF_FORMAT:
1034 if (PCM_GetFormatIndex(afd->pwfx) == 0xFFFFFFFF) {
1035 WARN("not possible\n");
1036 return ACMERR_NOTPOSSIBLE;
1038 break;
1039 case ACM_FORMATDETAILSF_INDEX:
1040 assert(afd->dwFormatIndex < NUM_PCM_FORMATS);
1041 afd->pwfx->wFormatTag = WAVE_FORMAT_PCM;
1042 afd->pwfx->nChannels = PCM_Formats[afd->dwFormatIndex].nChannels;
1043 afd->pwfx->nSamplesPerSec = PCM_Formats[afd->dwFormatIndex].rate;
1044 afd->pwfx->wBitsPerSample = PCM_Formats[afd->dwFormatIndex].nBits;
1045 /* native MSACM uses a PCMWAVEFORMAT structure, so cbSize is not
1046 * accessible afd->pwfx->cbSize = 0;
1048 afd->pwfx->nBlockAlign =
1049 (afd->pwfx->nChannels * afd->pwfx->wBitsPerSample) / 8;
1050 afd->pwfx->nAvgBytesPerSec =
1051 afd->pwfx->nSamplesPerSec * afd->pwfx->nBlockAlign;
1052 break;
1053 default:
1054 WARN("Unsupported query %08x\n", dwQuery);
1055 return MMSYSERR_NOTSUPPORTED;
1058 afd->dwFormatTag = WAVE_FORMAT_PCM;
1059 afd->fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CONVERTER;
1060 afd->szFormat[0] = 0; /* let MSACM format this for us... */
1061 afd->cbwfx = sizeof(PCMWAVEFORMAT);
1063 return MMSYSERR_NOERROR;
1066 /***********************************************************************
1067 * PCM_FormatSuggest
1070 static LRESULT PCM_FormatSuggest(PACMDRVFORMATSUGGEST adfs)
1072 TRACE("(%p)\n", adfs);
1074 /* some tests ... */
1075 if (adfs->cbwfxSrc < sizeof(PCMWAVEFORMAT) ||
1076 adfs->cbwfxDst < sizeof(PCMWAVEFORMAT) ||
1077 PCM_GetFormatIndex(adfs->pwfxSrc) == 0xFFFFFFFF) {
1078 WARN("not possible\n");
1079 return ACMERR_NOTPOSSIBLE;
1082 /* is no suggestion for destination, then copy source value */
1083 if (!(adfs->fdwSuggest & ACM_FORMATSUGGESTF_NCHANNELS)) {
1084 adfs->pwfxDst->nChannels = adfs->pwfxSrc->nChannels;
1086 if (!(adfs->fdwSuggest & ACM_FORMATSUGGESTF_NSAMPLESPERSEC)) {
1087 adfs->pwfxDst->nSamplesPerSec = adfs->pwfxSrc->nSamplesPerSec;
1089 if (!(adfs->fdwSuggest & ACM_FORMATSUGGESTF_WBITSPERSAMPLE)) {
1090 adfs->pwfxDst->wBitsPerSample = adfs->pwfxSrc->wBitsPerSample;
1092 if (!(adfs->fdwSuggest & ACM_FORMATSUGGESTF_WFORMATTAG)) {
1093 if (adfs->pwfxSrc->wFormatTag != WAVE_FORMAT_PCM) {
1094 WARN("source format 0x%x not supported\n", adfs->pwfxSrc->wFormatTag);
1095 return ACMERR_NOTPOSSIBLE;
1097 adfs->pwfxDst->wFormatTag = adfs->pwfxSrc->wFormatTag;
1098 } else {
1099 if (adfs->pwfxDst->wFormatTag != WAVE_FORMAT_PCM) {
1100 WARN("destination format 0x%x not supported\n", adfs->pwfxDst->wFormatTag);
1101 return ACMERR_NOTPOSSIBLE;
1104 /* check if result is ok */
1105 if (PCM_GetFormatIndex(adfs->pwfxDst) == 0xFFFFFFFF) {
1106 WARN("not possible\n");
1107 return ACMERR_NOTPOSSIBLE;
1110 /* recompute other values */
1111 adfs->pwfxDst->nBlockAlign = (adfs->pwfxDst->nChannels * adfs->pwfxDst->wBitsPerSample) / 8;
1112 adfs->pwfxDst->nAvgBytesPerSec = adfs->pwfxDst->nSamplesPerSec * adfs->pwfxDst->nBlockAlign;
1114 return MMSYSERR_NOERROR;
1117 /***********************************************************************
1118 * PCM_StreamOpen
1121 static LRESULT PCM_StreamOpen(PACMDRVSTREAMINSTANCE adsi)
1123 AcmPcmData* apd;
1124 int idx;
1125 DWORD flags;
1127 TRACE("(%p)\n", adsi);
1129 assert(!(adsi->fdwOpen & ACM_STREAMOPENF_ASYNC));
1131 switch(adsi->pwfxSrc->wBitsPerSample){
1132 case 8:
1133 idx = 0;
1134 break;
1135 case 16:
1136 idx = 12;
1137 break;
1138 case 24:
1139 if (adsi->pwfxSrc->nBlockAlign != 3 * adsi->pwfxSrc->nChannels) {
1140 FIXME("Source: 24-bit samples must be packed\n");
1141 return MMSYSERR_NOTSUPPORTED;
1143 idx = 24;
1144 break;
1145 default:
1146 FIXME("Unsupported source bit depth: %u\n", adsi->pwfxSrc->wBitsPerSample);
1147 return MMSYSERR_NOTSUPPORTED;
1150 switch(adsi->pwfxDst->wBitsPerSample){
1151 case 8:
1152 break;
1153 case 16:
1154 idx += 4;
1155 break;
1156 case 24:
1157 if (adsi->pwfxDst->nBlockAlign != 3 * adsi->pwfxDst->nChannels) {
1158 FIXME("Destination: 24-bit samples must be packed\n");
1159 return MMSYSERR_NOTSUPPORTED;
1161 idx += 8;
1162 break;
1163 default:
1164 FIXME("Unsupported destination bit depth: %u\n", adsi->pwfxDst->wBitsPerSample);
1165 return MMSYSERR_NOTSUPPORTED;
1168 if (adsi->pwfxSrc->nChannels == 1) idx += 2;
1170 if (adsi->pwfxDst->nChannels == 1) idx += 1;
1172 apd = HeapAlloc(GetProcessHeap(), 0, sizeof(AcmPcmData));
1173 if (!apd)
1174 return MMSYSERR_NOMEM;
1176 if (adsi->pwfxSrc->nSamplesPerSec == adsi->pwfxDst->nSamplesPerSec) {
1177 flags = 0;
1178 apd->cvt.cvtKeepRate = PCM_ConvertKeepRate[idx];
1179 } else {
1180 flags = PCM_RESAMPLE;
1181 apd->cvt.cvtChangeRate = PCM_ConvertChangeRate[idx];
1184 if(!apd->cvt.cvtChangeRate && !apd->cvt.cvtKeepRate){
1185 FIXME("Unimplemented conversion from %u -> %u bps\n",
1186 adsi->pwfxSrc->wBitsPerSample,
1187 adsi->pwfxDst->wBitsPerSample);
1188 HeapFree(GetProcessHeap(), 0, apd);
1189 return MMSYSERR_NOTSUPPORTED;
1192 adsi->dwDriver = (DWORD_PTR)apd;
1193 adsi->fdwDriver = flags;
1195 return MMSYSERR_NOERROR;
1198 /***********************************************************************
1199 * PCM_StreamClose
1202 static LRESULT PCM_StreamClose(PACMDRVSTREAMINSTANCE adsi)
1204 TRACE("(%p)\n", adsi);
1206 HeapFree(GetProcessHeap(), 0, (void*)adsi->dwDriver);
1207 return MMSYSERR_NOERROR;
1210 /***********************************************************************
1211 * PCM_round
1214 static inline DWORD PCM_round(DWORD a, DWORD b, DWORD c)
1216 assert(c);
1217 /* to be sure, always return an entire number of c... */
1218 return ((double)a * (double)b + (double)c - 1) / (double)c;
1221 /***********************************************************************
1222 * PCM_StreamSize
1225 static LRESULT PCM_StreamSize(PACMDRVSTREAMINSTANCE adsi, PACMDRVSTREAMSIZE adss)
1227 DWORD srcMask = ~(adsi->pwfxSrc->nBlockAlign - 1);
1228 DWORD dstMask = ~(adsi->pwfxDst->nBlockAlign - 1);
1230 TRACE("(%p, %p)\n", adsi, adss);
1232 switch (adss->fdwSize) {
1233 case ACM_STREAMSIZEF_DESTINATION:
1234 /* cbDstLength => cbSrcLength */
1235 adss->cbSrcLength = PCM_round(adss->cbDstLength & dstMask,
1236 adsi->pwfxSrc->nAvgBytesPerSec,
1237 adsi->pwfxDst->nAvgBytesPerSec) & srcMask;
1238 break;
1239 case ACM_STREAMSIZEF_SOURCE:
1240 /* cbSrcLength => cbDstLength */
1241 adss->cbDstLength = PCM_round(adss->cbSrcLength & srcMask,
1242 adsi->pwfxDst->nAvgBytesPerSec,
1243 adsi->pwfxSrc->nAvgBytesPerSec) & dstMask;
1244 break;
1245 default:
1246 WARN("Unsupported query %08x\n", adss->fdwSize);
1247 return MMSYSERR_NOTSUPPORTED;
1249 return MMSYSERR_NOERROR;
1252 /***********************************************************************
1253 * PCM_StreamConvert
1256 static LRESULT PCM_StreamConvert(PACMDRVSTREAMINSTANCE adsi, PACMDRVSTREAMHEADER adsh)
1258 AcmPcmData* apd = (AcmPcmData*)adsi->dwDriver;
1259 DWORD nsrc = NUM_OF(adsh->cbSrcLength, adsi->pwfxSrc->nBlockAlign);
1260 DWORD ndst = NUM_OF(adsh->cbDstLength, adsi->pwfxDst->nBlockAlign);
1262 TRACE("(%p, %p)\n", adsi, adsh);
1264 TRACE("nsrc=%d,adsh->cbSrcLength=%d\n", nsrc, adsh->cbSrcLength);
1265 TRACE("ndst=%d,adsh->cbDstLength=%d\n", ndst, adsh->cbDstLength);
1266 TRACE("src [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%u, nAvgBytesPerSec=%u, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n",
1267 adsi->pwfxSrc->wFormatTag, adsi->pwfxSrc->nChannels, adsi->pwfxSrc->nSamplesPerSec, adsi->pwfxSrc->nAvgBytesPerSec,
1268 adsi->pwfxSrc->nBlockAlign, adsi->pwfxSrc->wBitsPerSample, adsi->pwfxSrc->cbSize);
1269 TRACE("dst [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%u, nAvgBytesPerSec=%u, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n",
1270 adsi->pwfxDst->wFormatTag, adsi->pwfxDst->nChannels, adsi->pwfxDst->nSamplesPerSec, adsi->pwfxDst->nAvgBytesPerSec,
1271 adsi->pwfxDst->nBlockAlign, adsi->pwfxDst->wBitsPerSample, adsi->pwfxDst->cbSize);
1273 if (adsh->fdwConvert &
1274 ~(ACM_STREAMCONVERTF_BLOCKALIGN|
1275 ACM_STREAMCONVERTF_END|
1276 ACM_STREAMCONVERTF_START)) {
1277 FIXME("Unsupported fdwConvert (%08x), ignoring it\n", adsh->fdwConvert);
1279 /* ACM_STREAMCONVERTF_BLOCKALIGN
1280 * currently all conversions are block aligned, so do nothing for this flag
1281 * ACM_STREAMCONVERTF_END
1282 * no pending data, so do nothing for this flag
1284 if ((adsh->fdwConvert & ACM_STREAMCONVERTF_START) &&
1285 (adsi->fdwDriver & PCM_RESAMPLE)) {
1288 /* do the job */
1289 if (adsi->fdwDriver & PCM_RESAMPLE) {
1290 DWORD nsrc2 = nsrc;
1291 DWORD ndst2 = ndst;
1292 apd->cvt.cvtChangeRate(adsi->pwfxSrc->nSamplesPerSec, adsh->pbSrc, &nsrc2,
1293 adsi->pwfxDst->nSamplesPerSec, adsh->pbDst, &ndst2);
1294 nsrc -= nsrc2;
1295 ndst -= ndst2;
1296 } else {
1297 if (nsrc < ndst) ndst = nsrc; else nsrc = ndst;
1299 /* nsrc is now equal to ndst */
1300 apd->cvt.cvtKeepRate(adsh->pbSrc, nsrc, adsh->pbDst);
1303 adsh->cbSrcLengthUsed = nsrc * adsi->pwfxSrc->nBlockAlign;
1304 adsh->cbDstLengthUsed = ndst * adsi->pwfxDst->nBlockAlign;
1306 return MMSYSERR_NOERROR;
1309 /**************************************************************************
1310 * DriverProc (MSACM32.@)
1312 LRESULT CALLBACK PCM_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg,
1313 LPARAM dwParam1, LPARAM dwParam2)
1315 TRACE("(%08lx %p %u %08lx %08lx);\n",
1316 dwDevID, hDriv, wMsg, dwParam1, dwParam2);
1318 switch (wMsg) {
1319 case DRV_LOAD: return 1;
1320 case DRV_FREE: return 1;
1321 case DRV_OPEN: return PCM_drvOpen((LPSTR)dwParam1, (PACMDRVOPENDESCW)dwParam2);
1322 case DRV_CLOSE: return PCM_drvClose(dwDevID);
1323 case DRV_ENABLE: return 1;
1324 case DRV_DISABLE: return 1;
1325 case DRV_QUERYCONFIGURE: return 1;
1326 case DRV_CONFIGURE: MessageBoxA(0, "MSACM PCM filter !", "Wine Driver", MB_OK); return 1;
1327 case DRV_INSTALL: return DRVCNF_RESTART;
1328 case DRV_REMOVE: return DRVCNF_RESTART;
1330 case ACMDM_DRIVER_NOTIFY:
1331 /* no caching from other ACM drivers is done so far */
1332 return MMSYSERR_NOERROR;
1334 case ACMDM_DRIVER_DETAILS:
1335 return PCM_DriverDetails((PACMDRIVERDETAILSW)dwParam1);
1337 case ACMDM_FORMATTAG_DETAILS:
1338 return PCM_FormatTagDetails((PACMFORMATTAGDETAILSW)dwParam1, dwParam2);
1340 case ACMDM_FORMAT_DETAILS:
1341 return PCM_FormatDetails((PACMFORMATDETAILSW)dwParam1, dwParam2);
1343 case ACMDM_FORMAT_SUGGEST:
1344 return PCM_FormatSuggest((PACMDRVFORMATSUGGEST)dwParam1);
1346 case ACMDM_STREAM_OPEN:
1347 return PCM_StreamOpen((PACMDRVSTREAMINSTANCE)dwParam1);
1349 case ACMDM_STREAM_CLOSE:
1350 return PCM_StreamClose((PACMDRVSTREAMINSTANCE)dwParam1);
1352 case ACMDM_STREAM_SIZE:
1353 return PCM_StreamSize((PACMDRVSTREAMINSTANCE)dwParam1, (PACMDRVSTREAMSIZE)dwParam2);
1355 case ACMDM_STREAM_CONVERT:
1356 return PCM_StreamConvert((PACMDRVSTREAMINSTANCE)dwParam1, (PACMDRVSTREAMHEADER)dwParam2);
1358 case ACMDM_HARDWARE_WAVE_CAPS_INPUT:
1359 case ACMDM_HARDWARE_WAVE_CAPS_OUTPUT:
1360 /* this converter is not a hardware driver */
1361 case ACMDM_FILTERTAG_DETAILS:
1362 case ACMDM_FILTER_DETAILS:
1363 /* this converter is not a filter */
1364 case ACMDM_STREAM_RESET:
1365 /* only needed for asynchronous driver... we aren't, so just say it */
1366 case ACMDM_STREAM_PREPARE:
1367 case ACMDM_STREAM_UNPREPARE:
1368 /* nothing special to do here... so don't do anything */
1369 return MMSYSERR_NOTSUPPORTED;
1371 default:
1372 return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);