Added regedit unit test, a couple minor changes to regedit.
[wine] / dlls / msacm / winemp3 / mpegl3.c
1 /*
2  * MPEG Layer 3 handling
3  *
4  *      Copyright (C) 2002              Eric Pouech
5  *
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #include <assert.h>
23 #include <string.h>
24 #include "winnls.h"
25 #include "winbase.h"
26 #include "wingdi.h"
27 #include "winuser.h"
28 #include "msacm.h"
29 #include "mmreg.h"
30 #include "../msacmdrv.h"
31 #include "mpg123.h"
32 #include "mpglib.h"
33
34 #include "wine/debug.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(mpeg3);
37
38 /***********************************************************************
39  *           MPEG3_drvOpen
40  */
41 static  DWORD   MPEG3_drvOpen(LPCSTR str)
42 {
43     return 1;
44 }
45
46 /***********************************************************************
47  *           MPEG3_drvClose
48  */
49 static  DWORD   MPEG3_drvClose(DWORD dwDevID)
50 {
51     return 1;
52 }
53
54 typedef struct tagAcmMpeg3Data 
55 {
56     void (*convert)(PACMDRVSTREAMINSTANCE adsi, 
57                     const unsigned char*, LPDWORD, unsigned char*, LPDWORD);
58     struct mpstr mp;
59 } AcmMpeg3Data;
60
61 /* table to list all supported formats... those are the basic ones. this
62  * also helps given a unique index to each of the supported formats
63  */
64 typedef struct 
65 {
66     int         nChannels;
67     int         nBits;
68     int         rate;
69 } Format;
70
71 static Format PCM_Formats[] = 
72 {
73     {1,  8,  8000}, {2,  8,  8000}, {1, 16,  8000}, {2, 16,  8000},
74     {1,  8, 11025}, {2,  8, 11025}, {1, 16, 11025}, {2, 16, 11025},
75     {1,  8, 22050}, {2,  8, 22050}, {1, 16, 22050}, {2, 16, 22050},
76     {1,  8, 44100}, {2,  8, 44100}, {1, 16, 44100}, {2, 16, 44100},
77 };
78
79 static Format MPEG3_Formats[] = 
80 {
81     {1,  0,  8000}, {2, 0,  8000},  {1,  0, 11025}, {2,  0, 11025}, 
82     {1,  0, 22050}, {2, 0, 22050},  {1,  0, 44100}, {2,  0, 44100},
83 };
84
85 #define NUM_PCM_FORMATS         (sizeof(PCM_Formats) / sizeof(PCM_Formats[0]))
86 #define NUM_MPEG3_FORMATS       (sizeof(MPEG3_Formats) / sizeof(MPEG3_Formats[0]))
87
88 /***********************************************************************
89  *           MPEG3_GetFormatIndex
90  */
91 static  DWORD   MPEG3_GetFormatIndex(LPWAVEFORMATEX wfx)
92 {
93     int         i, hi;
94     Format*     fmts;
95     
96     switch (wfx->wFormatTag) 
97     {
98     case WAVE_FORMAT_PCM:
99         hi = NUM_PCM_FORMATS;
100         fmts = PCM_Formats;
101         break;
102     case WAVE_FORMAT_MPEGLAYER3:
103         hi = NUM_MPEG3_FORMATS;
104         fmts = MPEG3_Formats;
105         break;
106     default:
107         return 0xFFFFFFFF;
108     }
109     
110     for (i = 0; i < hi; i++) 
111     {
112         if (wfx->nChannels == fmts[i].nChannels &&
113             wfx->nSamplesPerSec == fmts[i].rate &&
114             wfx->wBitsPerSample == fmts[i].nBits)
115             return i;
116     }
117     
118     return 0xFFFFFFFF;
119 }
120
121 /***********************************************************************
122  *           R16
123  *
124  * Read a 16 bit sample (correctly handles endianess)
125  */
126 static inline short  R16(const unsigned char* src)
127 {
128     return (short)((unsigned short)src[0] | ((unsigned short)src[1] << 8));
129 }
130
131 /***********************************************************************
132  *           W16
133  *
134  * Write a 16 bit sample (correctly handles endianess)
135  */
136 static inline void  W16(unsigned char* dst, short s)
137 {
138     dst[0] = LOBYTE(s);
139     dst[1] = HIBYTE(s);
140 }
141
142 static void mp3_horse(PACMDRVSTREAMINSTANCE adsi,
143                       const unsigned char* src, LPDWORD nsrc,
144                       unsigned char* dst, LPDWORD ndst)
145 {
146     AcmMpeg3Data*       amd = (AcmMpeg3Data*)adsi->dwDriver;
147     int                 size, ret;
148     DWORD               dpos = 0;
149
150     ret = decodeMP3(&amd->mp, (unsigned char*)src, *nsrc, dst, *ndst, &size);
151     if (ret != MP3_OK)
152     {
153         *ndst = *nsrc = 0;
154         return;
155     }
156     do {
157         dpos += size;
158         if (*ndst - dpos < 4608) break;
159         ret = decodeMP3(&amd->mp, NULL, 0, 
160                         dst + dpos, *ndst - dpos, &size);
161     } while (ret == MP3_OK);
162     *ndst = dpos;
163 }
164
165 /***********************************************************************
166  *           MPEG3_DriverDetails
167  *
168  */
169 static  LRESULT MPEG3_DriverDetails(PACMDRIVERDETAILSW add)
170 {
171     add->fccType = ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC;
172     add->fccComp = ACMDRIVERDETAILS_FCCCOMP_UNDEFINED;
173     add->wMid = 0xFF;
174     add->wPid = 0x00;
175     add->vdwACM = 0x01000000;
176     add->vdwDriver = 0x01000000;
177     add->fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CODEC;
178     add->cFormatTags = 2; /* PCM, MPEG3 */
179     add->cFilterTags = 0;
180     add->hicon = (HICON)0;
181     MultiByteToWideChar( CP_ACP, 0, "WINE-MPEG3", -1,
182                          add->szShortName, sizeof(add->szShortName)/sizeof(WCHAR) );
183     MultiByteToWideChar( CP_ACP, 0, "Wine MPEG3 decoder", -1,
184                          add->szLongName, sizeof(add->szLongName)/sizeof(WCHAR) );
185     MultiByteToWideChar( CP_ACP, 0, "Brought to you by the Wine team (based on mpglib by Michael Hipp)...", -1,
186                          add->szCopyright, sizeof(add->szCopyright)/sizeof(WCHAR) );
187     MultiByteToWideChar( CP_ACP, 0, "Refer to LICENSE file", -1,
188                          add->szLicensing, sizeof(add->szLicensing)/sizeof(WCHAR) );
189     add->szFeatures[0] = 0;
190     
191     return MMSYSERR_NOERROR;
192 }
193
194 /***********************************************************************
195  *           MPEG3_FormatTagDetails
196  *
197  */
198 static  LRESULT MPEG3_FormatTagDetails(PACMFORMATTAGDETAILSW aftd, DWORD dwQuery)
199 {
200     static WCHAR szPcm[]={'P','C','M',0};
201     static WCHAR szMpeg3[]={'M','P','e','g','3',0};
202     
203     switch (dwQuery) 
204     {
205     case ACM_FORMATTAGDETAILSF_INDEX:
206         if (aftd->dwFormatTagIndex >= 2) return ACMERR_NOTPOSSIBLE;
207         break;
208     case ACM_FORMATTAGDETAILSF_LARGESTSIZE:
209         if (aftd->dwFormatTag == WAVE_FORMAT_UNKNOWN) 
210         {
211             aftd->dwFormatTagIndex = 1; /* WAVE_FORMAT_MPEGLAYER3 is bigger than PCM */
212             break;
213         }
214         /* fall thru */
215     case ACM_FORMATTAGDETAILSF_FORMATTAG: 
216         switch (aftd->dwFormatTag) 
217         {
218         case WAVE_FORMAT_PCM:           aftd->dwFormatTagIndex = 0; break;
219         case WAVE_FORMAT_MPEGLAYER3:    aftd->dwFormatTagIndex = 1; break;
220         default:                        return ACMERR_NOTPOSSIBLE;
221         }
222         break;
223     default:
224         WARN("Unsupported query %08lx\n", dwQuery);
225         return MMSYSERR_NOTSUPPORTED;
226     }
227     
228     aftd->fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CODEC;
229     switch (aftd->dwFormatTagIndex) 
230     {
231     case 0:
232         aftd->dwFormatTag = WAVE_FORMAT_PCM;
233         aftd->cbFormatSize = sizeof(PCMWAVEFORMAT);
234         aftd->cStandardFormats = NUM_PCM_FORMATS;
235         lstrcpyW(aftd->szFormatTag, szPcm);
236         break;
237     case 1:
238         aftd->dwFormatTag = WAVE_FORMAT_MPEGLAYER3;
239         aftd->cbFormatSize = sizeof(MPEGLAYER3WAVEFORMAT);
240         aftd->cStandardFormats = NUM_MPEG3_FORMATS;
241         lstrcpyW(aftd->szFormatTag, szMpeg3);
242         break;
243     }
244     return MMSYSERR_NOERROR;
245 }
246
247 static void fill_in_wfx(unsigned cbwfx, WAVEFORMATEX* wfx, unsigned bit_rate)
248 {
249     MPEGLAYER3WAVEFORMAT*   mp3wfx = (MPEGLAYER3WAVEFORMAT*)wfx;
250
251     wfx->nAvgBytesPerSec = bit_rate / 8;
252     if (cbwfx >= sizeof(WAVEFORMATEX))
253         wfx->cbSize = sizeof(MPEGLAYER3WAVEFORMAT) - sizeof(WAVEFORMATEX);
254     if (cbwfx >= sizeof(MPEGLAYER3WAVEFORMAT))
255     {
256         mp3wfx->wID = MPEGLAYER3_ID_MPEG;
257         mp3wfx->fdwFlags = MPEGLAYER3_FLAG_PADDING_OFF;
258         mp3wfx->nBlockSize = (bit_rate * 144) / wfx->nSamplesPerSec;
259         mp3wfx->nFramesPerBlock = 1;
260         mp3wfx->nCodecDelay = 0x0571;
261     }
262 }
263
264 /***********************************************************************
265  *           MPEG3_FormatDetails
266  *
267  */
268 static  LRESULT MPEG3_FormatDetails(PACMFORMATDETAILSW afd, DWORD dwQuery)
269 {
270     switch (dwQuery) 
271     {
272     case ACM_FORMATDETAILSF_FORMAT:
273         if (MPEG3_GetFormatIndex(afd->pwfx) == 0xFFFFFFFF) return ACMERR_NOTPOSSIBLE;
274         break;
275     case ACM_FORMATDETAILSF_INDEX:
276         afd->pwfx->wFormatTag = afd->dwFormatTag;
277         switch (afd->dwFormatTag) 
278         {
279         case WAVE_FORMAT_PCM:
280             if (afd->dwFormatIndex >= NUM_PCM_FORMATS) return ACMERR_NOTPOSSIBLE;
281             afd->pwfx->nChannels = PCM_Formats[afd->dwFormatIndex].nChannels;
282             afd->pwfx->nSamplesPerSec = PCM_Formats[afd->dwFormatIndex].rate;
283             afd->pwfx->wBitsPerSample = PCM_Formats[afd->dwFormatIndex].nBits;
284             /* native MSACM uses a PCMWAVEFORMAT structure, so cbSize is not accessible
285              * afd->pwfx->cbSize = 0; 
286              */
287             afd->pwfx->nBlockAlign = 
288                 (afd->pwfx->nChannels * afd->pwfx->wBitsPerSample) / 8;
289             afd->pwfx->nAvgBytesPerSec = 
290                 afd->pwfx->nSamplesPerSec * afd->pwfx->nBlockAlign;
291             break;
292         case WAVE_FORMAT_MPEGLAYER3:
293             if (afd->dwFormatIndex >= NUM_MPEG3_FORMATS) return ACMERR_NOTPOSSIBLE;
294             afd->pwfx->nChannels = MPEG3_Formats[afd->dwFormatIndex].nChannels;
295             afd->pwfx->nSamplesPerSec = MPEG3_Formats[afd->dwFormatIndex].rate;
296             afd->pwfx->wBitsPerSample = MPEG3_Formats[afd->dwFormatIndex].nBits;
297             afd->pwfx->nBlockAlign = 1;
298             fill_in_wfx(afd->cbwfx, afd->pwfx, 192000);
299             break;
300         default:
301             WARN("Unsupported tag %08lx\n", afd->dwFormatTag);
302             return MMSYSERR_INVALPARAM;
303         }
304         break;
305     default:
306         WARN("Unsupported query %08lx\n", dwQuery);
307         return MMSYSERR_NOTSUPPORTED;   
308     }
309     afd->fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CODEC;
310     afd->szFormat[0] = 0; /* let MSACM format this for us... */
311     
312     return MMSYSERR_NOERROR;
313 }
314
315 /***********************************************************************
316  *           MPEG3_FormatSuggest
317  *
318  */
319 static  LRESULT MPEG3_FormatSuggest(PACMDRVFORMATSUGGEST adfs)
320 {
321     /* some tests ... */
322     if (adfs->cbwfxSrc < sizeof(PCMWAVEFORMAT) ||
323         adfs->cbwfxDst < sizeof(PCMWAVEFORMAT) ||
324         MPEG3_GetFormatIndex(adfs->pwfxSrc) == 0xFFFFFFFF) return ACMERR_NOTPOSSIBLE;
325     /* FIXME: should do those tests against the real size (according to format tag */
326
327     /* If no suggestion for destination, then copy source value */
328     if (!(adfs->fdwSuggest & ACM_FORMATSUGGESTF_NCHANNELS))
329         adfs->pwfxDst->nChannels = adfs->pwfxSrc->nChannels;
330     if (!(adfs->fdwSuggest & ACM_FORMATSUGGESTF_NSAMPLESPERSEC))
331         adfs->pwfxDst->nSamplesPerSec = adfs->pwfxSrc->nSamplesPerSec;
332
333     if (!(adfs->fdwSuggest & ACM_FORMATSUGGESTF_WBITSPERSAMPLE)) 
334     {
335         if (adfs->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM) 
336             adfs->pwfxDst->wBitsPerSample = 4;
337         else
338             adfs->pwfxDst->wBitsPerSample = 16;
339     }
340     if (!(adfs->fdwSuggest & ACM_FORMATSUGGESTF_WFORMATTAG)) 
341     {
342         if (adfs->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM) 
343             adfs->pwfxDst->wFormatTag = WAVE_FORMAT_MPEGLAYER3;
344         else
345             adfs->pwfxDst->wFormatTag = WAVE_FORMAT_PCM;
346     }
347         
348     /* check if result is ok */
349     if (MPEG3_GetFormatIndex(adfs->pwfxDst) == 0xFFFFFFFF) return ACMERR_NOTPOSSIBLE;
350
351     /* recompute other values */
352     switch (adfs->pwfxDst->wFormatTag)
353     {
354     case WAVE_FORMAT_PCM:
355         adfs->pwfxDst->nBlockAlign = (adfs->pwfxDst->nChannels * adfs->pwfxDst->wBitsPerSample) / 8;
356         adfs->pwfxDst->nAvgBytesPerSec = adfs->pwfxDst->nSamplesPerSec * adfs->pwfxDst->nBlockAlign;
357         break;
358     case WAVE_FORMAT_MPEGLAYER3:
359         adfs->pwfxDst->nBlockAlign = 1;
360         fill_in_wfx(adfs->cbwfxDst, adfs->pwfxDst, 192000);
361         break;
362     default:
363         FIXME("\n");
364         break;
365     }
366
367     return MMSYSERR_NOERROR;
368 }
369
370 /***********************************************************************
371  *           MPEG3_Reset
372  *
373  */
374 static  void    MPEG3_Reset(PACMDRVSTREAMINSTANCE adsi, AcmMpeg3Data* aad)
375 {
376 }
377
378 /***********************************************************************
379  *           MPEG3_StreamOpen
380  *
381  */
382 static  LRESULT MPEG3_StreamOpen(PACMDRVSTREAMINSTANCE adsi)
383 {
384     AcmMpeg3Data*       aad;
385
386     assert(!(adsi->fdwOpen & ACM_STREAMOPENF_ASYNC));
387     
388     if (MPEG3_GetFormatIndex(adsi->pwfxSrc) == 0xFFFFFFFF ||
389         MPEG3_GetFormatIndex(adsi->pwfxDst) == 0xFFFFFFFF)
390         return ACMERR_NOTPOSSIBLE;
391     
392     aad = HeapAlloc(GetProcessHeap(), 0, sizeof(AcmMpeg3Data));
393     if (aad == 0) return MMSYSERR_NOMEM;
394     
395     adsi->dwDriver = (DWORD)aad;
396     
397     if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM &&
398         adsi->pwfxDst->wFormatTag == WAVE_FORMAT_PCM) 
399     {
400         goto theEnd;
401     }
402     else if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_MPEGLAYER3 &&
403              adsi->pwfxDst->wFormatTag == WAVE_FORMAT_PCM) 
404     {
405         /* resampling or mono <=> stereo not available 
406          * MPEG3 algo only define 16 bit per sample output
407          */
408         if (adsi->pwfxSrc->nSamplesPerSec != adsi->pwfxDst->nSamplesPerSec ||
409             adsi->pwfxSrc->nChannels != adsi->pwfxDst->nChannels ||
410             adsi->pwfxDst->wBitsPerSample != 16)
411             goto theEnd;
412         aad->convert = mp3_horse;
413         InitMP3(&aad->mp);
414     }
415     /* no encoding yet
416     else if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM &&
417              adsi->pwfxDst->wFormatTag == WAVE_FORMAT_MPEGLAYER3) 
418     */
419     else goto theEnd;
420     MPEG3_Reset(adsi, aad);
421
422     return MMSYSERR_NOERROR;
423     
424  theEnd:
425     HeapFree(GetProcessHeap(), 0, aad);
426     adsi->dwDriver = 0L;
427     return MMSYSERR_NOTSUPPORTED;
428 }
429
430 /***********************************************************************
431  *           MPEG3_StreamClose
432  *
433  */
434 static  LRESULT MPEG3_StreamClose(PACMDRVSTREAMINSTANCE adsi)
435 {
436     ExitMP3(&((AcmMpeg3Data*)adsi->dwDriver)->mp);
437     HeapFree(GetProcessHeap(), 0, (void*)adsi->dwDriver);
438     return MMSYSERR_NOERROR;
439 }
440
441 /***********************************************************************
442  *           MPEG3_round
443  *
444  */
445 static  inline DWORD    MPEG3_round(DWORD a, DWORD b, DWORD c)
446 {
447     assert(a && b && c);
448     /* to be sure, always return an entire number of c... */
449     return ((double)a * (double)b + (double)c - 1) / (double)c;
450 }
451
452 /***********************************************************************
453  *           MPEG3_StreamSize
454  *
455  */
456 static  LRESULT MPEG3_StreamSize(PACMDRVSTREAMINSTANCE adsi, PACMDRVSTREAMSIZE adss)
457 {
458     switch (adss->fdwSize) 
459     {
460     case ACM_STREAMSIZEF_DESTINATION:
461         /* cbDstLength => cbSrcLength */
462         if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM &&
463             adsi->pwfxDst->wFormatTag == WAVE_FORMAT_MPEGLAYER3) 
464         {
465             /* don't take block overhead into account, doesn't matter too much */
466             adss->cbSrcLength = adss->cbDstLength * 4;
467         }
468         else if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_MPEGLAYER3 &&
469                  adsi->pwfxDst->wFormatTag == WAVE_FORMAT_PCM) 
470         {
471             FIXME("misses the block header overhead\n");
472             adss->cbSrcLength = 256 + adss->cbDstLength / 4;
473         }
474         else 
475         {
476             return MMSYSERR_NOTSUPPORTED;
477         }
478         break;
479     case ACM_STREAMSIZEF_SOURCE:
480         /* cbSrcLength => cbDstLength */
481         if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM &&
482             adsi->pwfxDst->wFormatTag == WAVE_FORMAT_MPEGLAYER3) 
483         {
484             FIXME("misses the block header overhead\n");
485             adss->cbDstLength = 256 + adss->cbSrcLength / 4;
486         } 
487         else if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_MPEGLAYER3 &&
488                  adsi->pwfxDst->wFormatTag == WAVE_FORMAT_PCM) 
489         {
490             /* don't take block overhead into account, doesn't matter too much */
491             adss->cbDstLength = adss->cbSrcLength * 4;
492         }
493         else 
494         {
495             return MMSYSERR_NOTSUPPORTED;
496         }
497         break;
498     default:
499         WARN("Unsupported query %08lx\n", adss->fdwSize);
500         return MMSYSERR_NOTSUPPORTED;   
501     }
502     return MMSYSERR_NOERROR;
503 }
504
505 /***********************************************************************
506  *           MPEG3_StreamConvert
507  *
508  */
509 static LRESULT MPEG3_StreamConvert(PACMDRVSTREAMINSTANCE adsi, PACMDRVSTREAMHEADER adsh)
510 {
511     AcmMpeg3Data*       aad = (AcmMpeg3Data*)adsi->dwDriver;
512     DWORD               nsrc = adsh->cbSrcLength;
513     DWORD               ndst = adsh->cbDstLength;
514     
515     if (adsh->fdwConvert & 
516         ~(ACM_STREAMCONVERTF_BLOCKALIGN|
517           ACM_STREAMCONVERTF_END|
518           ACM_STREAMCONVERTF_START)) 
519     {
520         FIXME("Unsupported fdwConvert (%08lx), ignoring it\n", adsh->fdwConvert);
521     }
522     /* ACM_STREAMCONVERTF_BLOCKALIGN
523      *  currently all conversions are block aligned, so do nothing for this flag
524      * ACM_STREAMCONVERTF_END
525      *  no pending data, so do nothing for this flag
526      */
527     if ((adsh->fdwConvert & ACM_STREAMCONVERTF_START)) 
528     {
529         MPEG3_Reset(adsi, aad);
530     }
531
532     aad->convert(adsi, adsh->pbSrc, &nsrc, adsh->pbDst, &ndst);
533     adsh->cbSrcLengthUsed = nsrc;
534     adsh->cbDstLengthUsed = ndst;
535     
536     return MMSYSERR_NOERROR;
537 }
538
539 /**************************************************************************
540  *                      MPEG3_DriverProc                        [exported]
541  */
542 LRESULT CALLBACK        MPEG3_DriverProc(DWORD dwDevID, HDRVR hDriv, UINT wMsg, 
543                                          LPARAM dwParam1, LPARAM dwParam2)
544 {
545     TRACE("(%08lx %08lx %04x %08lx %08lx);\n", 
546           dwDevID, (DWORD)hDriv, wMsg, dwParam1, dwParam2);
547     
548     switch (wMsg) 
549     {
550     case DRV_LOAD:              return 1;
551     case DRV_FREE:              return 1;
552     case DRV_OPEN:              return MPEG3_drvOpen((LPSTR)dwParam1);
553     case DRV_CLOSE:             return MPEG3_drvClose(dwDevID);
554     case DRV_ENABLE:            return 1;       
555     case DRV_DISABLE:           return 1;
556     case DRV_QUERYCONFIGURE:    return 1;
557     case DRV_CONFIGURE:         MessageBoxA(0, "MPEG3 filter !", "Wine Driver", MB_OK); return 1;
558     case DRV_INSTALL:           return DRVCNF_RESTART;
559     case DRV_REMOVE:            return DRVCNF_RESTART;
560         
561     case ACMDM_DRIVER_NOTIFY:
562         /* no caching from other ACM drivers is done so far */
563         return MMSYSERR_NOERROR;
564         
565     case ACMDM_DRIVER_DETAILS:
566         return MPEG3_DriverDetails((PACMDRIVERDETAILSW)dwParam1);
567         
568     case ACMDM_FORMATTAG_DETAILS:
569         return MPEG3_FormatTagDetails((PACMFORMATTAGDETAILSW)dwParam1, dwParam2);
570         
571     case ACMDM_FORMAT_DETAILS:
572         return MPEG3_FormatDetails((PACMFORMATDETAILSW)dwParam1, dwParam2);
573         
574     case ACMDM_FORMAT_SUGGEST:
575         return MPEG3_FormatSuggest((PACMDRVFORMATSUGGEST)dwParam1);
576         
577     case ACMDM_STREAM_OPEN:
578         return MPEG3_StreamOpen((PACMDRVSTREAMINSTANCE)dwParam1);
579         
580     case ACMDM_STREAM_CLOSE:
581         return MPEG3_StreamClose((PACMDRVSTREAMINSTANCE)dwParam1);
582         
583     case ACMDM_STREAM_SIZE:
584         return MPEG3_StreamSize((PACMDRVSTREAMINSTANCE)dwParam1, (PACMDRVSTREAMSIZE)dwParam2);
585         
586     case ACMDM_STREAM_CONVERT:
587         return MPEG3_StreamConvert((PACMDRVSTREAMINSTANCE)dwParam1, (PACMDRVSTREAMHEADER)dwParam2);
588         
589     case ACMDM_HARDWARE_WAVE_CAPS_INPUT:
590     case ACMDM_HARDWARE_WAVE_CAPS_OUTPUT:
591         /* this converter is not a hardware driver */
592     case ACMDM_FILTERTAG_DETAILS:
593     case ACMDM_FILTER_DETAILS:
594         /* this converter is not a filter */
595     case ACMDM_STREAM_RESET:
596         /* only needed for asynchronous driver... we aren't, so just say it */
597         return MMSYSERR_NOTSUPPORTED;
598     case ACMDM_STREAM_PREPARE:
599     case ACMDM_STREAM_UNPREPARE:
600         /* nothing special to do here... so don't do anything */
601         return MMSYSERR_NOERROR;
602         
603     default:
604         return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
605     }
606     return 0;
607 }