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