oleaut32: Return type mismatch errors in ITypeLibComp_fnBind.
[wine.git] / dlls / winemp3.acm / mpegl3.c
blob01697a7b333566990b28aee7ab491b5cab65a8c4
1 /*
2 * MPEG Layer 3 handling
4 * Copyright (C) 2002 Eric Pouech
5 * Copyright (C) 2009 CodeWeavers, Aric Stewart
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "config.h"
24 #include "wine/port.h"
26 #include <assert.h>
27 #include <stdarg.h>
28 #include <string.h>
29 #include "windef.h"
30 #include "winbase.h"
31 #include "wingdi.h"
32 #include "winuser.h"
33 #include "winnls.h"
34 #include "mmsystem.h"
35 #include "mmreg.h"
36 #include "msacm.h"
37 #include "msacmdrv.h"
39 #ifdef HAVE_MPG123_H
40 #include <mpg123.h>
41 #endif
43 #include "wine/debug.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(mpeg3);
47 /***********************************************************************
48 * MPEG3_drvOpen
50 static LRESULT MPEG3_drvOpen(LPCSTR str)
52 mpg123_init();
53 return 1;
56 /***********************************************************************
57 * MPEG3_drvClose
59 static LRESULT MPEG3_drvClose(DWORD_PTR dwDevID)
61 mpg123_exit();
62 return 1;
65 typedef struct tagAcmMpeg3Data
67 void (*convert)(PACMDRVSTREAMINSTANCE adsi,
68 const unsigned char*, LPDWORD, unsigned char*, LPDWORD);
69 mpg123_handle *mh;
70 } AcmMpeg3Data;
72 /* table to list all supported formats... those are the basic ones. this
73 * also helps given a unique index to each of the supported formats
75 typedef struct
77 int nChannels;
78 int nBits;
79 int rate;
80 } Format;
82 static const Format PCM_Formats[] =
84 {1, 8, 8000}, {2, 8, 8000}, {1, 16, 8000}, {2, 16, 8000},
85 {1, 8, 11025}, {2, 8, 11025}, {1, 16, 11025}, {2, 16, 11025},
86 {1, 8, 12000}, {2, 8, 12000}, {1, 16, 12000}, {2, 16, 12000},
87 {1, 8, 16000}, {2, 8, 16000}, {1, 16, 16000}, {2, 16, 16000},
88 {1, 8, 22050}, {2, 8, 22050}, {1, 16, 22050}, {2, 16, 22050},
89 {1, 8, 24000}, {2, 8, 24000}, {1, 16, 24000}, {2, 16, 24000},
90 {1, 8, 32000}, {2, 8, 32000}, {1, 16, 32000}, {2, 16, 32000},
91 {1, 8, 44100}, {2, 8, 44100}, {1, 16, 44100}, {2, 16, 44100},
92 {1, 8, 48000}, {2, 8, 48000}, {1, 16, 48000}, {2, 16, 48000}
95 static const Format MPEG3_Formats[] =
97 {1, 0, 8000}, {2, 0, 8000},
98 {1, 0, 11025}, {2, 0, 11025},
99 {1, 0, 12000}, {2, 0, 12000},
100 {1, 0, 16000}, {2, 0, 16000},
101 {1, 0, 22050}, {2, 0, 22050},
102 {1, 0, 24000}, {2, 0, 24000},
103 {1, 0, 32000}, {2, 0, 32000},
104 {1, 0, 44100}, {2, 0, 44100},
105 {1, 0, 48000}, {2, 0, 48000}
108 #define NUM_PCM_FORMATS (sizeof(PCM_Formats) / sizeof(PCM_Formats[0]))
109 #define NUM_MPEG3_FORMATS (sizeof(MPEG3_Formats) / sizeof(MPEG3_Formats[0]))
111 /***********************************************************************
112 * MPEG3_GetFormatIndex
114 static DWORD MPEG3_GetFormatIndex(LPWAVEFORMATEX wfx)
116 int i, hi;
117 const Format *fmts;
119 switch (wfx->wFormatTag)
121 case WAVE_FORMAT_PCM:
122 hi = NUM_PCM_FORMATS;
123 fmts = PCM_Formats;
124 break;
125 case WAVE_FORMAT_MPEGLAYER3:
126 hi = NUM_MPEG3_FORMATS;
127 fmts = MPEG3_Formats;
128 break;
129 default:
130 return 0xFFFFFFFF;
133 for (i = 0; i < hi; i++)
135 if (wfx->nChannels == fmts[i].nChannels &&
136 wfx->nSamplesPerSec == fmts[i].rate &&
137 (wfx->wBitsPerSample == fmts[i].nBits || !fmts[i].nBits))
138 return i;
141 return 0xFFFFFFFF;
144 static void mp3_horse(PACMDRVSTREAMINSTANCE adsi,
145 const unsigned char* src, LPDWORD nsrc,
146 unsigned char* dst, LPDWORD ndst)
148 AcmMpeg3Data* amd = (AcmMpeg3Data*)adsi->dwDriver;
149 int ret;
150 size_t size;
151 DWORD dpos = 0;
154 if (*nsrc > 0)
156 ret = mpg123_feed(amd->mh, src, *nsrc);
157 if (ret != MPG123_OK)
159 ERR("Error feeding data\n");
160 *ndst = *nsrc = 0;
161 return;
165 do {
166 size = 0;
167 ret = mpg123_read(amd->mh, dst + dpos, *ndst - dpos, &size);
168 if (ret == MPG123_ERR)
170 FIXME("Error occurred during decoding!\n");
171 *ndst = *nsrc = 0;
172 return;
175 if (ret == MPG123_NEW_FORMAT)
177 long rate;
178 int channels, enc;
179 mpg123_getformat(amd->mh, &rate, &channels, &enc);
180 TRACE("New format: %li Hz, %i channels, encoding value %i\n", rate, channels, enc);
182 dpos += size;
183 if (dpos > *ndst) break;
184 } while (ret != MPG123_ERR && ret != MPG123_NEED_MORE);
185 *ndst = dpos;
188 /***********************************************************************
189 * MPEG3_DriverDetails
192 static LRESULT MPEG3_DriverDetails(PACMDRIVERDETAILSW add)
194 add->fccType = ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC;
195 add->fccComp = ACMDRIVERDETAILS_FCCCOMP_UNDEFINED;
196 add->wMid = 0xFF;
197 add->wPid = 0x00;
198 add->vdwACM = 0x01000000;
199 add->vdwDriver = 0x01000000;
200 add->fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CODEC;
201 add->cFormatTags = 2; /* PCM, MPEG3 */
202 add->cFilterTags = 0;
203 add->hicon = NULL;
204 MultiByteToWideChar( CP_ACP, 0, "WINE-MPEG3", -1,
205 add->szShortName, sizeof(add->szShortName)/sizeof(WCHAR) );
206 MultiByteToWideChar( CP_ACP, 0, "Wine MPEG3 decoder", -1,
207 add->szLongName, sizeof(add->szLongName)/sizeof(WCHAR) );
208 MultiByteToWideChar( CP_ACP, 0, "Brought to you by the Wine team...", -1,
209 add->szCopyright, sizeof(add->szCopyright)/sizeof(WCHAR) );
210 MultiByteToWideChar( CP_ACP, 0, "Refer to LICENSE file", -1,
211 add->szLicensing, sizeof(add->szLicensing)/sizeof(WCHAR) );
212 add->szFeatures[0] = 0;
214 return MMSYSERR_NOERROR;
217 /***********************************************************************
218 * MPEG3_FormatTagDetails
221 static LRESULT MPEG3_FormatTagDetails(PACMFORMATTAGDETAILSW aftd, DWORD dwQuery)
223 static const WCHAR szPcm[]={'P','C','M',0};
224 static const WCHAR szMpeg3[]={'M','P','e','g','3',0};
226 switch (dwQuery)
228 case ACM_FORMATTAGDETAILSF_INDEX:
229 if (aftd->dwFormatTagIndex >= 2) return ACMERR_NOTPOSSIBLE;
230 break;
231 case ACM_FORMATTAGDETAILSF_LARGESTSIZE:
232 if (aftd->dwFormatTag == WAVE_FORMAT_UNKNOWN)
234 aftd->dwFormatTagIndex = 1; /* WAVE_FORMAT_MPEGLAYER3 is bigger than PCM */
235 break;
237 /* fall thru */
238 case ACM_FORMATTAGDETAILSF_FORMATTAG:
239 switch (aftd->dwFormatTag)
241 case WAVE_FORMAT_PCM: aftd->dwFormatTagIndex = 0; break;
242 case WAVE_FORMAT_MPEGLAYER3: aftd->dwFormatTagIndex = 1; break;
243 default: return ACMERR_NOTPOSSIBLE;
245 break;
246 default:
247 WARN("Unsupported query %08x\n", dwQuery);
248 return MMSYSERR_NOTSUPPORTED;
251 aftd->fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CODEC;
252 switch (aftd->dwFormatTagIndex)
254 case 0:
255 aftd->dwFormatTag = WAVE_FORMAT_PCM;
256 aftd->cbFormatSize = sizeof(PCMWAVEFORMAT);
257 aftd->cStandardFormats = NUM_PCM_FORMATS;
258 lstrcpyW(aftd->szFormatTag, szPcm);
259 break;
260 case 1:
261 aftd->dwFormatTag = WAVE_FORMAT_MPEGLAYER3;
262 aftd->cbFormatSize = sizeof(MPEGLAYER3WAVEFORMAT);
263 aftd->cStandardFormats = NUM_MPEG3_FORMATS;
264 lstrcpyW(aftd->szFormatTag, szMpeg3);
265 break;
267 return MMSYSERR_NOERROR;
270 static void fill_in_wfx(unsigned cbwfx, WAVEFORMATEX* wfx, unsigned bit_rate)
272 MPEGLAYER3WAVEFORMAT* mp3wfx = (MPEGLAYER3WAVEFORMAT*)wfx;
274 wfx->nAvgBytesPerSec = bit_rate / 8;
275 if (cbwfx >= sizeof(WAVEFORMATEX))
276 wfx->cbSize = sizeof(MPEGLAYER3WAVEFORMAT) - sizeof(WAVEFORMATEX);
277 if (cbwfx >= sizeof(MPEGLAYER3WAVEFORMAT))
279 mp3wfx->wID = MPEGLAYER3_ID_MPEG;
280 mp3wfx->fdwFlags = MPEGLAYER3_FLAG_PADDING_OFF;
281 mp3wfx->nBlockSize = (bit_rate * 144) / wfx->nSamplesPerSec;
282 mp3wfx->nFramesPerBlock = 1;
283 mp3wfx->nCodecDelay = 0x0571;
287 /***********************************************************************
288 * MPEG3_FormatDetails
291 static LRESULT MPEG3_FormatDetails(PACMFORMATDETAILSW afd, DWORD dwQuery)
293 switch (dwQuery)
295 case ACM_FORMATDETAILSF_FORMAT:
296 if (MPEG3_GetFormatIndex(afd->pwfx) == 0xFFFFFFFF) return ACMERR_NOTPOSSIBLE;
297 break;
298 case ACM_FORMATDETAILSF_INDEX:
299 afd->pwfx->wFormatTag = afd->dwFormatTag;
300 switch (afd->dwFormatTag)
302 case WAVE_FORMAT_PCM:
303 if (afd->dwFormatIndex >= NUM_PCM_FORMATS) return ACMERR_NOTPOSSIBLE;
304 afd->pwfx->nChannels = PCM_Formats[afd->dwFormatIndex].nChannels;
305 afd->pwfx->nSamplesPerSec = PCM_Formats[afd->dwFormatIndex].rate;
306 afd->pwfx->wBitsPerSample = PCM_Formats[afd->dwFormatIndex].nBits;
307 /* native MSACM uses a PCMWAVEFORMAT structure, so cbSize is not accessible
308 * afd->pwfx->cbSize = 0;
310 afd->pwfx->nBlockAlign =
311 (afd->pwfx->nChannels * afd->pwfx->wBitsPerSample) / 8;
312 afd->pwfx->nAvgBytesPerSec =
313 afd->pwfx->nSamplesPerSec * afd->pwfx->nBlockAlign;
314 break;
315 case WAVE_FORMAT_MPEGLAYER3:
316 if (afd->dwFormatIndex >= NUM_MPEG3_FORMATS) return ACMERR_NOTPOSSIBLE;
317 afd->pwfx->nChannels = MPEG3_Formats[afd->dwFormatIndex].nChannels;
318 afd->pwfx->nSamplesPerSec = MPEG3_Formats[afd->dwFormatIndex].rate;
319 afd->pwfx->wBitsPerSample = MPEG3_Formats[afd->dwFormatIndex].nBits;
320 afd->pwfx->nBlockAlign = 1;
321 fill_in_wfx(afd->cbwfx, afd->pwfx, 192000);
322 break;
323 default:
324 WARN("Unsupported tag %08x\n", afd->dwFormatTag);
325 return MMSYSERR_INVALPARAM;
327 break;
328 default:
329 WARN("Unsupported query %08x\n", dwQuery);
330 return MMSYSERR_NOTSUPPORTED;
332 afd->fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CODEC;
333 afd->szFormat[0] = 0; /* let MSACM format this for us... */
335 return MMSYSERR_NOERROR;
338 /***********************************************************************
339 * MPEG3_FormatSuggest
342 static LRESULT MPEG3_FormatSuggest(PACMDRVFORMATSUGGEST adfs)
344 /* some tests ... */
345 if (adfs->cbwfxSrc < sizeof(PCMWAVEFORMAT) ||
346 adfs->cbwfxDst < sizeof(PCMWAVEFORMAT) ||
347 MPEG3_GetFormatIndex(adfs->pwfxSrc) == 0xFFFFFFFF) return ACMERR_NOTPOSSIBLE;
348 /* FIXME: should do those tests against the real size (according to format tag */
350 /* If no suggestion for destination, then copy source value */
351 if (!(adfs->fdwSuggest & ACM_FORMATSUGGESTF_NCHANNELS))
352 adfs->pwfxDst->nChannels = adfs->pwfxSrc->nChannels;
353 if (!(adfs->fdwSuggest & ACM_FORMATSUGGESTF_NSAMPLESPERSEC))
354 adfs->pwfxDst->nSamplesPerSec = adfs->pwfxSrc->nSamplesPerSec;
356 if (!(adfs->fdwSuggest & ACM_FORMATSUGGESTF_WBITSPERSAMPLE))
358 if (adfs->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM)
359 adfs->pwfxDst->wBitsPerSample = 4;
360 else
361 adfs->pwfxDst->wBitsPerSample = 16;
363 if (!(adfs->fdwSuggest & ACM_FORMATSUGGESTF_WFORMATTAG))
365 if (adfs->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM)
366 adfs->pwfxDst->wFormatTag = WAVE_FORMAT_MPEGLAYER3;
367 else
368 adfs->pwfxDst->wFormatTag = WAVE_FORMAT_PCM;
371 /* check if result is ok */
372 if (MPEG3_GetFormatIndex(adfs->pwfxDst) == 0xFFFFFFFF) return ACMERR_NOTPOSSIBLE;
374 /* recompute other values */
375 switch (adfs->pwfxDst->wFormatTag)
377 case WAVE_FORMAT_PCM:
378 adfs->pwfxDst->nBlockAlign = (adfs->pwfxDst->nChannels * adfs->pwfxDst->wBitsPerSample) / 8;
379 adfs->pwfxDst->nAvgBytesPerSec = adfs->pwfxDst->nSamplesPerSec * adfs->pwfxDst->nBlockAlign;
380 break;
381 case WAVE_FORMAT_MPEGLAYER3:
382 adfs->pwfxDst->nBlockAlign = 1;
383 fill_in_wfx(adfs->cbwfxDst, adfs->pwfxDst, 192000);
384 break;
385 default:
386 FIXME("\n");
387 break;
390 return MMSYSERR_NOERROR;
393 /***********************************************************************
394 * MPEG3_Reset
397 static void MPEG3_Reset(PACMDRVSTREAMINSTANCE adsi, AcmMpeg3Data* aad)
399 mpg123_feedseek(aad->mh, 0, SEEK_SET, NULL);
400 mpg123_close(aad->mh);
401 mpg123_open_feed(aad->mh);
404 /***********************************************************************
405 * MPEG3_StreamOpen
408 static LRESULT MPEG3_StreamOpen(PACMDRVSTREAMINSTANCE adsi)
410 AcmMpeg3Data* aad;
411 int err;
413 assert(!(adsi->fdwOpen & ACM_STREAMOPENF_ASYNC));
415 if (MPEG3_GetFormatIndex(adsi->pwfxSrc) == 0xFFFFFFFF ||
416 MPEG3_GetFormatIndex(adsi->pwfxDst) == 0xFFFFFFFF)
417 return ACMERR_NOTPOSSIBLE;
419 aad = HeapAlloc(GetProcessHeap(), 0, sizeof(AcmMpeg3Data));
420 if (aad == 0) return MMSYSERR_NOMEM;
422 adsi->dwDriver = (DWORD_PTR)aad;
424 if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM &&
425 adsi->pwfxDst->wFormatTag == WAVE_FORMAT_PCM)
427 goto theEnd;
429 else if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_MPEGLAYER3 &&
430 adsi->pwfxDst->wFormatTag == WAVE_FORMAT_PCM)
432 /* resampling or mono <=> stereo not available
433 * MPEG3 algo only define 16 bit per sample output
435 if (adsi->pwfxSrc->nSamplesPerSec != adsi->pwfxDst->nSamplesPerSec ||
436 adsi->pwfxSrc->nChannels != adsi->pwfxDst->nChannels ||
437 adsi->pwfxDst->wBitsPerSample != 16)
438 goto theEnd;
439 aad->convert = mp3_horse;
440 aad->mh = mpg123_new(NULL,&err);
441 mpg123_open_feed(aad->mh);
443 /* no encoding yet
444 else if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM &&
445 adsi->pwfxDst->wFormatTag == WAVE_FORMAT_MPEGLAYER3)
447 else goto theEnd;
448 MPEG3_Reset(adsi, aad);
450 return MMSYSERR_NOERROR;
452 theEnd:
453 HeapFree(GetProcessHeap(), 0, aad);
454 adsi->dwDriver = 0L;
455 return MMSYSERR_NOTSUPPORTED;
458 /***********************************************************************
459 * MPEG3_StreamClose
462 static LRESULT MPEG3_StreamClose(PACMDRVSTREAMINSTANCE adsi)
464 mpg123_close(((AcmMpeg3Data*)adsi->dwDriver)->mh);
465 mpg123_delete(((AcmMpeg3Data*)adsi->dwDriver)->mh);
466 HeapFree(GetProcessHeap(), 0, (void*)adsi->dwDriver);
467 return MMSYSERR_NOERROR;
470 /***********************************************************************
471 * MPEG3_StreamSize
474 static LRESULT MPEG3_StreamSize(PACMDRVSTREAMINSTANCE adsi, PACMDRVSTREAMSIZE adss)
476 DWORD nblocks;
478 switch (adss->fdwSize)
480 case ACM_STREAMSIZEF_DESTINATION:
481 /* cbDstLength => cbSrcLength */
482 if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM &&
483 adsi->pwfxDst->wFormatTag == WAVE_FORMAT_MPEGLAYER3)
485 nblocks = (adss->cbDstLength - 3000) / (DWORD)(adsi->pwfxDst->nAvgBytesPerSec * 1152 / adsi->pwfxDst->nSamplesPerSec + 0.5);
486 if (nblocks == 0)
487 return ACMERR_NOTPOSSIBLE;
488 adss->cbSrcLength = nblocks * 1152 * adsi->pwfxSrc->nBlockAlign;
490 else if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_MPEGLAYER3 &&
491 adsi->pwfxDst->wFormatTag == WAVE_FORMAT_PCM)
493 nblocks = adss->cbDstLength / (adsi->pwfxDst->nBlockAlign * 1152);
494 if (nblocks == 0)
495 return ACMERR_NOTPOSSIBLE;
496 adss->cbSrcLength = nblocks * (DWORD)(adsi->pwfxSrc->nAvgBytesPerSec * 1152 / adsi->pwfxSrc->nSamplesPerSec);
498 else
500 return MMSYSERR_NOTSUPPORTED;
502 break;
503 case ACM_STREAMSIZEF_SOURCE:
504 /* cbSrcLength => cbDstLength */
505 if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM &&
506 adsi->pwfxDst->wFormatTag == WAVE_FORMAT_MPEGLAYER3)
508 nblocks = adss->cbSrcLength / (adsi->pwfxSrc->nBlockAlign * 1152);
509 if (nblocks == 0)
510 return ACMERR_NOTPOSSIBLE;
511 if (adss->cbSrcLength % (DWORD)(adsi->pwfxSrc->nBlockAlign * 1152))
512 /* Round block count up. */
513 nblocks++;
514 adss->cbDstLength = 3000 + nblocks * (DWORD)(adsi->pwfxDst->nAvgBytesPerSec * 1152 / adsi->pwfxDst->nSamplesPerSec + 0.5);
516 else if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_MPEGLAYER3 &&
517 adsi->pwfxDst->wFormatTag == WAVE_FORMAT_PCM)
519 nblocks = adss->cbSrcLength / (DWORD)(adsi->pwfxSrc->nAvgBytesPerSec * 1152 / adsi->pwfxSrc->nSamplesPerSec);
520 if (nblocks == 0)
521 return ACMERR_NOTPOSSIBLE;
522 if (adss->cbSrcLength % (DWORD)(adsi->pwfxSrc->nAvgBytesPerSec * 1152 / adsi->pwfxSrc->nSamplesPerSec))
523 /* Round block count up. */
524 nblocks++;
525 adss->cbDstLength = nblocks * 1152 * adsi->pwfxDst->nBlockAlign;
527 else
529 return MMSYSERR_NOTSUPPORTED;
531 break;
532 default:
533 WARN("Unsupported query %08x\n", adss->fdwSize);
534 return MMSYSERR_NOTSUPPORTED;
536 return MMSYSERR_NOERROR;
539 /***********************************************************************
540 * MPEG3_StreamConvert
543 static LRESULT MPEG3_StreamConvert(PACMDRVSTREAMINSTANCE adsi, PACMDRVSTREAMHEADER adsh)
545 AcmMpeg3Data* aad = (AcmMpeg3Data*)adsi->dwDriver;
546 DWORD nsrc = adsh->cbSrcLength;
547 DWORD ndst = adsh->cbDstLength;
549 if (adsh->fdwConvert &
550 ~(ACM_STREAMCONVERTF_BLOCKALIGN|
551 ACM_STREAMCONVERTF_END|
552 ACM_STREAMCONVERTF_START))
554 FIXME("Unsupported fdwConvert (%08x), ignoring it\n", adsh->fdwConvert);
556 /* ACM_STREAMCONVERTF_BLOCKALIGN
557 * currently all conversions are block aligned, so do nothing for this flag
558 * ACM_STREAMCONVERTF_END
559 * no pending data, so do nothing for this flag
561 if ((adsh->fdwConvert & ACM_STREAMCONVERTF_START))
563 MPEG3_Reset(adsi, aad);
566 aad->convert(adsi, adsh->pbSrc, &nsrc, adsh->pbDst, &ndst);
567 adsh->cbSrcLengthUsed = nsrc;
568 adsh->cbDstLengthUsed = ndst;
570 return MMSYSERR_NOERROR;
573 /**************************************************************************
574 * MPEG3_DriverProc [exported]
576 LRESULT CALLBACK MPEG3_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg,
577 LPARAM dwParam1, LPARAM dwParam2)
579 TRACE("(%08lx %p %04x %08lx %08lx);\n",
580 dwDevID, hDriv, wMsg, dwParam1, dwParam2);
582 switch (wMsg)
584 case DRV_LOAD: return 1;
585 case DRV_FREE: return 1;
586 case DRV_OPEN: return MPEG3_drvOpen((LPSTR)dwParam1);
587 case DRV_CLOSE: return MPEG3_drvClose(dwDevID);
588 case DRV_ENABLE: return 1;
589 case DRV_DISABLE: return 1;
590 case DRV_QUERYCONFIGURE: return 1;
591 case DRV_CONFIGURE: MessageBoxA(0, "MPEG3 filter !", "Wine Driver", MB_OK); return 1;
592 case DRV_INSTALL: return DRVCNF_RESTART;
593 case DRV_REMOVE: return DRVCNF_RESTART;
595 case ACMDM_DRIVER_NOTIFY:
596 /* no caching from other ACM drivers is done so far */
597 return MMSYSERR_NOERROR;
599 case ACMDM_DRIVER_DETAILS:
600 return MPEG3_DriverDetails((PACMDRIVERDETAILSW)dwParam1);
602 case ACMDM_FORMATTAG_DETAILS:
603 return MPEG3_FormatTagDetails((PACMFORMATTAGDETAILSW)dwParam1, dwParam2);
605 case ACMDM_FORMAT_DETAILS:
606 return MPEG3_FormatDetails((PACMFORMATDETAILSW)dwParam1, dwParam2);
608 case ACMDM_FORMAT_SUGGEST:
609 return MPEG3_FormatSuggest((PACMDRVFORMATSUGGEST)dwParam1);
611 case ACMDM_STREAM_OPEN:
612 return MPEG3_StreamOpen((PACMDRVSTREAMINSTANCE)dwParam1);
614 case ACMDM_STREAM_CLOSE:
615 return MPEG3_StreamClose((PACMDRVSTREAMINSTANCE)dwParam1);
617 case ACMDM_STREAM_SIZE:
618 return MPEG3_StreamSize((PACMDRVSTREAMINSTANCE)dwParam1, (PACMDRVSTREAMSIZE)dwParam2);
620 case ACMDM_STREAM_CONVERT:
621 return MPEG3_StreamConvert((PACMDRVSTREAMINSTANCE)dwParam1, (PACMDRVSTREAMHEADER)dwParam2);
623 case ACMDM_HARDWARE_WAVE_CAPS_INPUT:
624 case ACMDM_HARDWARE_WAVE_CAPS_OUTPUT:
625 /* this converter is not a hardware driver */
626 case ACMDM_FILTERTAG_DETAILS:
627 case ACMDM_FILTER_DETAILS:
628 /* this converter is not a filter */
629 case ACMDM_STREAM_RESET:
630 /* only needed for asynchronous driver... we aren't, so just say it */
631 return MMSYSERR_NOTSUPPORTED;
632 case ACMDM_STREAM_PREPARE:
633 case ACMDM_STREAM_UNPREPARE:
634 /* nothing special to do here... so don't do anything */
635 return MMSYSERR_NOERROR;
637 default:
638 return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);