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