mciavi.c 33.7 KB
Newer Older
1 2
/* -*- tab-width: 8; c-basic-offset: 4 -*- */

3 4 5
/*
 * Digital video MCI Wine Driver
 *
6
 * Copyright 1999, 2000 Eric POUECH
7 8 9 10 11 12 13 14 15 16 17 18 19 20
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21 22 23 24 25 26 27 28 29 30 31 32 33
 */

/* TODO list :
 *	- handling of palettes
 *	- recording (which input devices ?), a cam recorder ?
 *	- lots of messages still need to be handled (cf FIXME)
 *	- synchronization between audio and video (especially for interleaved
 *	  files)
 *	- synchronization (as in all the Wine MCI drivers (MCI_WAIT) messages)
 *	- robustness when reading file can be enhanced
 *	- better move the AVI handling part to avifile DLL and make use of it
 *	- some files appear to have more than one audio stream (we only play the
 *	  first one)
34
 *	- some files contain an index of audio/video frame. Better use it,
35 36 37 38
 *	  instead of rebuilding it
 *	- mciWindow (for setting the hWnd) is broken with media player
 *	- stopping while playing a file with sound blocks until all buffered
 *        audio is played... still should be stopped ASAP
39 40
 */

41
#include <string.h>
42
#include "private_mciavi.h"
43
#include "wine/debug.h"
44

45
WINE_DEFAULT_DEBUG_CHANNEL(mciavi);
46

47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
/* ===================================================================
 * ===================================================================
 * FIXME: should be using the new mmThreadXXXX functions from WINMM
 * instead of those
 * it would require to add a wine internal flag to mmThreadCreate
 * in order to pass a 32 bit function instead of a 16 bit one
 * ===================================================================
 * =================================================================== */

struct SCA {
    UINT 	wDevID;
    UINT 	wMsg;
    DWORD 	dwParam1;
    DWORD 	dwParam2;
};

/**************************************************************************
 * 				MCI_SCAStarter			[internal]
 */
static DWORD CALLBACK	MCI_SCAStarter(LPVOID arg)
{
    struct SCA*	sca = (struct SCA*)arg;
    DWORD	ret;
70

71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
    TRACE("In thread before async command (%08x,%u,%08lx,%08lx)\n",
	  sca->wDevID, sca->wMsg, sca->dwParam1, sca->dwParam2);
    ret = mciSendCommandA(sca->wDevID, sca->wMsg, sca->dwParam1 | MCI_WAIT, sca->dwParam2);
    TRACE("In thread after async command (%08x,%u,%08lx,%08lx)\n",
	  sca->wDevID, sca->wMsg, sca->dwParam1, sca->dwParam2);
    HeapFree(GetProcessHeap(), 0, sca);
    ExitThread(ret);
    WARN("Should not happen ? what's wrong \n");
    /* should not go after this point */
    return ret;
}

/**************************************************************************
 * 				MCI_SendCommandAsync		[internal]
 */
86
static	DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD dwParam1,
87 88 89
				   DWORD dwParam2, UINT size)
{
    struct SCA*	sca = HeapAlloc(GetProcessHeap(), 0, sizeof(struct SCA) + size);
90

91 92
    if (sca == 0)
	return MCIERR_OUT_OF_MEMORY;
93

94 95 96
    sca->wDevID   = wDevID;
    sca->wMsg     = wMsg;
    sca->dwParam1 = dwParam1;
97

98 99
    if (size && dwParam2) {
	sca->dwParam2 = (DWORD)sca + sizeof(struct SCA);
100 101
	/* copy structure passed by program in dwParam2 to be sure
	 * we can still use it whatever the program does
102 103 104 105 106
	 */
	memcpy((LPVOID)sca->dwParam2, (LPVOID)dwParam2, size);
    } else {
	sca->dwParam2 = dwParam2;
    }
107

108 109 110 111 112 113
    if (CreateThread(NULL, 0, MCI_SCAStarter, sca, 0, NULL) == 0) {
	WARN("Couldn't allocate thread for async command handling, sending synchronously\n");
	return MCI_SCAStarter(&sca);
    }
    return 0;
}
114 115 116 117 118

/*======================================================================*
 *                  	    MCI AVI implemantation			*
 *======================================================================*/

119 120
HINSTANCE MCIAVI_hInstance = 0;

121
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad)
122 123 124
{
    switch (fdwReason) {
    case DLL_PROCESS_ATTACH:
125
        DisableThreadLibraryCalls(hInstDLL);
126 127 128 129 130 131
	MCIAVI_hInstance = hInstDLL;
	break;
    }
    return TRUE;
}

132
/**************************************************************************
133
 * 				MCIAVI_drvOpen			[internal]
134
 */
135
static	DWORD	MCIAVI_drvOpen(LPSTR str, LPMCI_OPEN_DRIVER_PARMSA modp)
136
{
137
    WINE_MCIAVI*	wma;
138
    static WCHAR	mciAviWStr[] = {'M','C','I','A','V','I',0};
139

140 141 142
    if (!modp) return 0xFFFFFFFF;

    wma = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINE_MCIAVI));
143 144
    if (!wma)
	return 0;
145

146 147
    wma->wDevID = modp->wDeviceID;
    mciSetDriverData(wma->wDevID, (DWORD)wma);
148 149
    wma->wCommandTable = mciLoadCommandResource(MCIAVI_hInstance, mciAviWStr, 0);
    modp->wCustomCommandTable = wma->wCommandTable;
150
    modp->wType = MCI_DEVTYPE_DIGITAL_VIDEO;
151
    return modp->wDeviceID;
152 153 154
}

/**************************************************************************
155
 * 				MCIAVI_drvClose		[internal]
156
 */
157
static	DWORD	MCIAVI_drvClose(DWORD dwDevID)
158
{
159
    WINE_MCIAVI*  wma = (WINE_MCIAVI*)mciGetDriverData(dwDevID);
160

161
    if (wma) {
162
	mciSetDriverData(dwDevID, 0);
163
	mciFreeCommandResource(wma->wCommandTable);
164
	HeapFree(GetProcessHeap(), 0, wma);
165 166
	return 1;
    }
167
    return (dwDevID == 0xFFFFFFFF) ? 1 : 0;
168 169 170
}

/**************************************************************************
171
 * 				MCIAVI_drvConfigure		[internal]
172 173 174 175 176 177
 */
static	DWORD	MCIAVI_drvConfigure(DWORD dwDevID)
{
    WINE_MCIAVI*  wma = (WINE_MCIAVI*)mciGetDriverData(dwDevID);

    if (wma) {
178
	MessageBoxA(0, "Sample AVI Wine Driver !", "MM-Wine Driver", MB_OK);
179 180 181 182 183
	return 1;
    }
    return 0;
}

184
/**************************************************************************
185
 * 				MCIAVI_mciGetOpenDev		[internal]
186
 */
187
WINE_MCIAVI*  MCIAVI_mciGetOpenDev(UINT wDevID)
188
{
189
    WINE_MCIAVI*	wma = (WINE_MCIAVI*)mciGetDriverData(wDevID);
190

191
    if (wma == NULL || wma->nUseCount == 0) {
192
	WARN("Invalid wDevID=%u\n", wDevID);
193 194
	return 0;
    }
195
    return wma;
196 197
}

198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
static void MCIAVI_CleanUp(WINE_MCIAVI* wma)
{
    /* to prevent handling in WindowProc */
    wma->dwStatus = MCI_MODE_NOT_READY;
    if (wma->hFile) {
	mmioClose(wma->hFile, 0);
	wma->hFile = 0;
	if (wma->lpVideoIndex)	HeapFree(GetProcessHeap(), 0, wma->lpVideoIndex);
	wma->lpVideoIndex = NULL;
	if (wma->lpAudioIndex)	HeapFree(GetProcessHeap(), 0, wma->lpAudioIndex);
	wma->lpAudioIndex = NULL;
	if (wma->hic)		ICClose(wma->hic);
	wma->hic = 0;
	if (wma->inbih)		HeapFree(GetProcessHeap(), 0, wma->inbih);
	wma->inbih = NULL;
	if (wma->outbih)	HeapFree(GetProcessHeap(), 0, wma->outbih);
	wma->outbih = NULL;
        if (wma->indata)	HeapFree(GetProcessHeap(), 0, wma->indata);
	wma->indata = NULL;
    	if (wma->outdata)	HeapFree(GetProcessHeap(), 0, wma->outdata);
	wma->outdata = NULL;
    	if (wma->hbmFrame)	DeleteObject(wma->hbmFrame);
	wma->hbmFrame = 0;
	if (wma->hWnd)		DestroyWindow(wma->hWnd);
	wma->hWnd = 0;
223

224 225 226 227 228 229 230 231 232 233 234
	if (wma->lpWaveFormat)	HeapFree(GetProcessHeap(), 0, wma->lpWaveFormat);
	wma->lpWaveFormat = 0;

	memset(&wma->mah, 0, sizeof(wma->mah));
	memset(&wma->ash_video, 0, sizeof(wma->ash_video));
	memset(&wma->ash_audio, 0, sizeof(wma->ash_audio));
	wma->dwCurrVideoFrame = wma->dwCurrAudioBlock = 0;
    }
}

static	DWORD	MCIAVI_mciStop(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms);
235

236
/***************************************************************************
237
 * 				MCIAVI_mciOpen			[internal]
238
 */
239
static	DWORD	MCIAVI_mciOpen(UINT wDevID, DWORD dwFlags,
240
			    LPMCI_DGV_OPEN_PARMSA lpOpenParms)
241
{
242
    WINE_MCIAVI*	wma = (WINE_MCIAVI*)mciGetDriverData(wDevID);
243
    LRESULT		dwRet = 0;
244

245
    TRACE("(%04x, %08lX, %p)\n", wDevID, dwFlags, lpOpenParms);
246

247
    if (lpOpenParms == NULL) 		return MCIERR_NULL_PARAMETER_BLOCK;
248
    if (wma == NULL)			return MCIERR_INVALID_DEVICE_ID;
249

250 251 252 253 254 255 256 257 258 259 260 261
    if (wma->nUseCount > 0) {
	/* The driver is already open on this channel */
	/* If the driver was opened shareable before and this open specifies */
	/* shareable then increment the use count */
	if (wma->fShareable && (dwFlags & MCI_OPEN_SHAREABLE))
	    ++wma->nUseCount;
	else
	    return MCIERR_MUST_USE_SHAREABLE;
    } else {
	wma->nUseCount = 1;
	wma->fShareable = dwFlags & MCI_OPEN_SHAREABLE;
    }
262 263

    wma->dwStatus = MCI_MODE_NOT_READY;
264
    InitializeCriticalSection(&wma->cs);
265

266
    if (dwFlags & MCI_OPEN_ELEMENT) {
267
	if (dwFlags & MCI_OPEN_ELEMENT_ID) {
268 269
	    /* could it be that (DWORD)lpOpenParms->lpstrElementName
	     * contains the hFile value ?
270 271 272 273 274
	     */
	    dwRet = MCIERR_UNRECOGNIZED_COMMAND;
	} else if (strlen(lpOpenParms->lpstrElementName) > 0) {
	    /* FIXME : what should be done id wma->hFile is already != 0, or the driver is playin' */
	    TRACE("MCI_OPEN_ELEMENT '%s' !\n", lpOpenParms->lpstrElementName);
275

276
	    if (lpOpenParms->lpstrElementName && (strlen(lpOpenParms->lpstrElementName) > 0)) {
277
		wma->hFile = mmioOpenA(lpOpenParms->lpstrElementName, NULL,
278
				       MMIO_ALLOCBUF | MMIO_DENYWRITE | MMIO_READWRITE);
279

280 281 282 283
		if (wma->hFile == 0) {
		    WARN("can't find file='%s' !\n", lpOpenParms->lpstrElementName);
		    dwRet = MCIERR_FILE_NOT_FOUND;
		} else {
284
		    if (!MCIAVI_GetInfo(wma))
285 286 287 288 289
			dwRet = MCIERR_INVALID_FILE;
		    else if (!MCIAVI_OpenVideo(wma))
			dwRet = MCIERR_CANNOT_LOAD_DRIVER;
		    else if (!MCIAVI_CreateWindow(wma, dwFlags, lpOpenParms))
			dwRet = MCIERR_CREATEWINDOW;
290
		}
291 292 293 294 295
	    }
	} else {
	    FIXME("Don't record yet\n");
	    dwRet = MCIERR_UNSUPPORTED_FUNCTION;
	}
296
    }
297

298
    memcpy(&wma->openParms, lpOpenParms, sizeof(MCI_WAVE_OPEN_PARMSA));
299

300 301 302 303 304 305 306
    if (dwRet == 0) {
	wma->dwStatus = MCI_MODE_STOP;
	wma->dwMciTimeFormat = MCI_FORMAT_FRAMES;
    } else {
	MCIAVI_CleanUp(wma);
    }
    return dwRet;
307

308 309
}

310
/***************************************************************************
311
 * 				MCIAVI_mciClose			[internal]
312
 */
313
static	DWORD	MCIAVI_mciClose(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
314
{
315 316
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
    DWORD		dwRet = 0;
317 318 319

    TRACE("(%04x, %08lX, %p)\n", wDevID, dwFlags, lpParms);

320
    if (wma == NULL) 	return MCIERR_INVALID_DEVICE_ID;
321

322
    if (wma->nUseCount == 1) {
323 324 325
	if (wma->dwStatus != MCI_MODE_STOP)
	    dwRet = MCIAVI_mciStop(wDevID, MCI_WAIT, lpParms);
    	MCIAVI_CleanUp(wma);
326

327
	if ((dwFlags & MCI_NOTIFY) && lpParms) {
328
	    mciDriverNotify(HWND_32(LOWORD(lpParms->dwCallback)),
329 330 331 332 333
			    wma->openParms.wDeviceID,
			    MCI_NOTIFY_SUCCESSFUL);
	}
	HeapFree(GetProcessHeap(), 0, wma);
	return dwRet;
334 335
    }
    wma->nUseCount--;
336
    return dwRet;
337 338
}

339
/***************************************************************************
340
 * 				MCIAVI_mciPlay			[internal]
341
 */
342
static	DWORD	MCIAVI_mciPlay(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms)
343
{
344 345 346 347 348 349 350 351
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
    DWORD		tc;
    DWORD		frameTime;
    DWORD		delta;
    DWORD		dwRet;
    LPWAVEHDR		waveHdr = NULL;
    unsigned		i, nHdr = 0;
    DWORD		dwFromFrame, dwToFrame;
352

353
    TRACE("(%04x, %08lX, %p)\n", wDevID, dwFlags, lpParms);
354

355 356
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
357

358 359
    if (!wma->hFile)		return MCIERR_FILE_NOT_FOUND;
    if (!wma->hWnd) 		return MCIERR_NO_WINDOW;
360

361
    wma->dwStatus = MCI_MODE_PLAY;
362

363
    if (!(dwFlags & MCI_WAIT)) {
364
	return MCI_SendCommandAsync(wma->openParms.wDeviceID, MCI_PLAY, dwFlags,
365 366
				    (DWORD)lpParms, sizeof(MCI_PLAY_PARMS));
    }
367

368
    ShowWindow(wma->hWnd, SW_SHOW);
369

370 371
    dwFromFrame = wma->dwCurrVideoFrame;
    dwToFrame = wma->dwPlayableVideoFrames - 1;
372

373
    if (lpParms && (dwFlags & MCI_FROM)) {
374
	dwFromFrame = MCIAVI_ConvertTimeFormatToFrame(wma, lpParms->dwFrom);
375 376 377 378 379 380
    }
    if (lpParms && (dwFlags & MCI_TO)) {
	dwToFrame = MCIAVI_ConvertTimeFormatToFrame(wma, lpParms->dwTo);
    }
    if (dwToFrame >= wma->dwPlayableVideoFrames)
	dwToFrame = wma->dwPlayableVideoFrames - 1;
381

382
    TRACE("Playing from frame=%lu to frame=%lu\n", dwFromFrame, dwToFrame);
383

384 385 386
    if (dwToFrame <= wma->dwCurrVideoFrame)
	return TRUE;
    wma->dwCurrVideoFrame = dwFromFrame;
387

388 389
    if (dwFlags & (MCI_DGV_PLAY_REPEAT|MCI_DGV_PLAY_REVERSE|MCI_MCIAVI_PLAY_WINDOW|MCI_MCIAVI_PLAY_FULLSCREEN))
	FIXME("Unsupported flag %08lx\n", dwFlags);
390

391 392
    /* time is in microseconds, we should convert it to milliseconds */
    frameTime = (wma->mah.dwMicroSecPerFrame + 500) / 1000;
393

394 395 396 397 398
    if (wma->lpWaveFormat) {
	if ((dwRet = MCIAVI_OpenAudio(wma, &nHdr, &waveHdr)) != 0)
	    goto cleanUp;
	/* fill the queue with as many wave headers as possible */
	MCIAVI_PlayAudioBlocks(wma, nHdr, waveHdr);
399
    }
400 401 402

    while (wma->dwStatus != MCI_MODE_STOP && wma->dwStatus != MCI_MODE_NOT_READY) {
	tc = GetTickCount();
403

404 405 406 407 408 409
	MCIAVI_DrawFrame(wma);

	if (wma->lpWaveFormat) {
	    MCIAVI_PlayAudioBlocks(wma, nHdr, waveHdr);
	    delta = GetTickCount() - tc;
	    WaitForSingleObject(wma->hEvent, (delta >= frameTime) ? 0 : frameTime - delta);
410
	}
411 412 413 414 415 416 417 418

	delta = GetTickCount() - tc;
	if (delta < frameTime)
	    Sleep(frameTime - delta);

	if (wma->dwCurrVideoFrame++ >= dwToFrame) {
	    wma->dwCurrVideoFrame--;
	    wma->dwStatus = MCI_MODE_STOP;
419 420
	}
    }
421 422 423 424

    if (wma->lpWaveFormat) {
	while (*(volatile DWORD*)&wma->dwEventCount != nHdr - 1) {
	    Sleep(100);
425
	}
426

427 428 429 430 431
	/* just to get rid of some race conditions between play, stop and pause */
	waveOutReset(wma->hWave);

	for (i = 0; i < nHdr; i++)
	    waveOutUnprepareHeader(wma->hWave, &waveHdr[i], sizeof(WAVEHDR));
432
    }
433

434 435 436 437
    dwRet = 0;
cleanUp:
    if (wma->lpWaveFormat) {
	HeapFree(GetProcessHeap(), 0, waveHdr);
438

439 440 441
	if (wma->hWave) {
	    waveOutClose(wma->hWave);
	    wma->hWave = 0;
442
	}
443
	CloseHandle(wma->hEvent);
444
    }
445 446

    if (lpParms && (dwFlags & MCI_NOTIFY)) {
447
	TRACE("MCI_NOTIFY_SUCCESSFUL %08lX !\n", lpParms->dwCallback);
448
	mciDriverNotify(HWND_32(LOWORD(lpParms->dwCallback)),
449
			wma->openParms.wDeviceID, MCI_NOTIFY_SUCCESSFUL);
450
    }
451

452
    wma->dwStatus = MCI_MODE_STOP;
453

454
    return dwRet;
455 456
}

457
/***************************************************************************
458
 * 				MCIAVI_mciRecord			[internal]
459
 */
460
static	DWORD	MCIAVI_mciRecord(UINT wDevID, DWORD dwFlags, LPMCI_DGV_RECORD_PARMS lpParms)
461
{
462
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
463

464
    FIXME("(%04x, %08lX, %p) : stub\n", wDevID, dwFlags, lpParms);
465

466
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
467
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
468

469 470
    wma->dwStatus = MCI_MODE_RECORD;
    return 0;
471 472
}

473
/***************************************************************************
474
 * 				MCIAVI_mciStop			[internal]
475
 */
476
static	DWORD	MCIAVI_mciStop(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
477
{
478 479
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
    DWORD		dwRet = 0;
480

481
    TRACE("(%04x, %08lX, %p)\n", wDevID, dwFlags, lpParms);
482

483 484
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
485

486 487 488 489 490 491 492 493 494 495 496 497
    switch (wma->dwStatus) {
    case MCI_MODE_PAUSE:
    case MCI_MODE_PLAY:
    case MCI_MODE_RECORD:
	{
	    int oldStat = wma->dwStatus;
	    wma->dwStatus = MCI_MODE_NOT_READY;
	    if (oldStat == MCI_MODE_PAUSE)
		dwRet = waveOutReset(wma->hWave);
	}
	while (wma->dwStatus != MCI_MODE_STOP)
	    Sleep(10);
498 499
	break;
    default:
500 501
	wma->dwStatus = MCI_MODE_STOP;
	break;
502
    }
503

504
    if ((dwFlags & MCI_NOTIFY) && lpParms) {
505
	mciDriverNotify(HWND_32(LOWORD(lpParms->dwCallback)),
506
			wma->openParms.wDeviceID, MCI_NOTIFY_SUCCESSFUL);
507
    }
508

509
    return dwRet;
510 511
}

512
/***************************************************************************
513
 * 				MCIAVI_mciPause			[internal]
514
 */
515
static	DWORD	MCIAVI_mciPause(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
516
{
517
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
518

519 520
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
521

522 523 524 525
    if (wma->dwStatus == MCI_MODE_PLAY)
	wma->dwStatus = MCI_MODE_PAUSE;

    return (wma->lpWaveFormat) ? waveOutPause(wma->hWave) : 0;
526 527 528
}

/***************************************************************************
529
 * 				MCIAVI_mciResume			[internal]
530
 */
531
static	DWORD	MCIAVI_mciResume(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
532
{
533
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
534

535
    FIXME("(%04x, %08lX, %p) : stub\n", wDevID, dwFlags, lpParms);
536

537 538
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
539

540 541 542 543
    if (wma->dwStatus == MCI_MODE_PAUSE)
	wma->dwStatus = MCI_MODE_PLAY;

    return (wma->lpWaveFormat) ? waveOutRestart(wma->hWave) : 0;
544 545
}

546 547
/***************************************************************************
 * 				MCIAVI_mciSeek			[internal]
548
 */
549
static	DWORD	MCIAVI_mciSeek(UINT wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms)
550
{
551
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
552

553
    TRACE("(%04x, %08lX, %p)\n", wDevID, dwFlags, lpParms);
554

555 556
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
557

558
    EnterCriticalSection(&wma->cs);
559

560
    MCIAVI_mciStop(wDevID, MCI_WAIT, 0);
561

562 563 564 565 566 567 568 569
    if (dwFlags & MCI_SEEK_TO_START) {
	wma->dwCurrVideoFrame = 0;
    } else if (dwFlags & MCI_SEEK_TO_END) {
	wma->dwCurrVideoFrame = wma->dwPlayableVideoFrames - 1;
    } else if (dwFlags & MCI_TO) {
	wma->dwCurrVideoFrame = MCIAVI_ConvertTimeFormatToFrame(wma, lpParms->dwTo);
    } else {
	WARN("dwFlag doesn't tell where to seek to...\n");
570
	LeaveCriticalSection(&wma->cs);
571 572
	return MCIERR_MISSING_PARAMETER;
    }
573

574
    TRACE("Seeking to frame=%lu bytes\n", wma->dwCurrVideoFrame);
575

576
    if (dwFlags & MCI_NOTIFY) {
577
	mciDriverNotify(HWND_32(LOWORD(lpParms->dwCallback)),
578 579 580 581 582
			wma->openParms.wDeviceID, MCI_NOTIFY_SUCCESSFUL);
    }

    LeaveCriticalSection(&wma->cs);

583 584 585
    return 0;
}

586 587
/*****************************************************************************
 * 				MCIAVI_mciLoad			[internal]
588
 */
589
static DWORD	MCIAVI_mciLoad(UINT wDevID, DWORD dwFlags, LPMCI_DGV_LOAD_PARMSA lpParms)
590
{
591
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
592

593
    FIXME("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
594

595 596
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
597

598 599 600 601
    return 0;
}

/******************************************************************************
602
 * 				MCIAVI_mciSave			[internal]
603
 */
604
static	DWORD	MCIAVI_mciSave(UINT wDevID, DWORD dwFlags, LPMCI_DGV_SAVE_PARMSA lpParms)
605
{
606
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
607

608
    FIXME("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
609

610 611
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
612

613 614 615 616
    return 0;
}

/******************************************************************************
617
 * 				MCIAVI_mciFreeze			[internal]
618
 */
619
static	DWORD	MCIAVI_mciFreeze(UINT wDevID, DWORD dwFlags, LPMCI_DGV_RECT_PARMS lpParms)
620
{
621
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
622

623
    FIXME("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
624

625 626
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
627

628 629 630 631
    return 0;
}

/******************************************************************************
632
 * 				MCIAVI_mciRealize			[internal]
633
 */
634
static	DWORD	MCIAVI_mciRealize(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
635
{
636
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
637

638
    FIXME("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
639

640 641
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
642

643 644 645 646
    return 0;
}

/******************************************************************************
647
 * 				MCIAVI_mciUnFreeze			[internal]
648
 */
649
static	DWORD	MCIAVI_mciUnFreeze(UINT wDevID, DWORD dwFlags, LPMCI_DGV_RECT_PARMS lpParms)
650
{
651
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
652

653
    FIXME("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
654

655 656
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
657

658 659 660 661
    return 0;
}

/******************************************************************************
662
 * 				MCIAVI_mciUpdate			[internal]
663
 */
664
static	DWORD	MCIAVI_mciUpdate(UINT wDevID, DWORD dwFlags, LPMCI_DGV_UPDATE_PARMS lpParms)
665
{
666 667 668
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);

    FIXME("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
669

670 671
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
672

673 674 675 676
    return 0;
}

/******************************************************************************
677
 * 				MCIAVI_mciStep			[internal]
678
 */
679
static	DWORD	MCIAVI_mciStep(UINT wDevID, DWORD dwFlags, LPMCI_DGV_STEP_PARMS lpParms)
680
{
681
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
682

683
    FIXME("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
684

685 686
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
687

688 689 690 691
    return 0;
}

/******************************************************************************
692
 * 				MCIAVI_mciCopy			[internal]
693
 */
694
static	DWORD	MCIAVI_mciCopy(UINT wDevID, DWORD dwFlags, LPMCI_DGV_COPY_PARMS lpParms)
695
{
696
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
697

698
    FIXME("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
699

700 701
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
702

703 704 705 706
    return 0;
}

/******************************************************************************
707
 * 				MCIAVI_mciCut			[internal]
708
 */
709
static	DWORD	MCIAVI_mciCut(UINT wDevID, DWORD dwFlags, LPMCI_DGV_CUT_PARMS lpParms)
710
{
711
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
712

713
    FIXME("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
714

715 716
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
717

718 719 720 721
    return 0;
}

/******************************************************************************
722
 * 				MCIAVI_mciDelete			[internal]
723
 */
724
static	DWORD	MCIAVI_mciDelete(UINT wDevID, DWORD dwFlags, LPMCI_DGV_DELETE_PARMS lpParms)
725
{
726
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
727

728
    FIXME("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
729

730 731
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
732

733 734 735 736
    return 0;
}

/******************************************************************************
737
 * 				MCIAVI_mciPaste			[internal]
738
 */
739
static	DWORD	MCIAVI_mciPaste(UINT wDevID, DWORD dwFlags, LPMCI_DGV_PASTE_PARMS lpParms)
740
{
741
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
742

743
    FIXME("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
744

745 746
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
747

748 749 750 751
    return 0;
}

/******************************************************************************
752
 * 				MCIAVI_mciCue			[internal]
753
 */
754
static	DWORD	MCIAVI_mciCue(UINT wDevID, DWORD dwFlags, LPMCI_DGV_CUE_PARMS lpParms)
755
{
756
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
757

758
    FIXME("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
759

760 761
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
762

763 764 765 766
    return 0;
}

/******************************************************************************
767
 * 				MCIAVI_mciCapture			[internal]
768
 */
769
static	DWORD	MCIAVI_mciCapture(UINT wDevID, DWORD dwFlags, LPMCI_DGV_CAPTURE_PARMSA lpParms)
770
{
771
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
772

773
    FIXME("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
774

775 776
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
777

778 779 780
    return 0;
}

781
/******************************************************************************
782
 * 				MCIAVI_mciMonitor			[internal]
783
 */
784
static	DWORD	MCIAVI_mciMonitor(UINT wDevID, DWORD dwFlags, LPMCI_DGV_MONITOR_PARMS lpParms)
785
{
786
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
787

788
    FIXME("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
789

790 791
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
792

793 794 795 796
    return 0;
}

/******************************************************************************
797
 * 				MCIAVI_mciReserve			[internal]
798
 */
799
static	DWORD	MCIAVI_mciReserve(UINT wDevID, DWORD dwFlags, LPMCI_DGV_RESERVE_PARMSA lpParms)
800
{
801
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
802

803
    FIXME("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
804

805 806
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
807

808 809 810 811
    return 0;
}

/******************************************************************************
812
 * 				MCIAVI_mciSetAudio			[internal]
813
 */
814
static	DWORD	MCIAVI_mciSetAudio(UINT wDevID, DWORD dwFlags, LPMCI_DGV_SETAUDIO_PARMSA lpParms)
815
{
816
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
817

818
    FIXME("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
819

820 821
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
822

823 824 825 826
    return 0;
}

/******************************************************************************
827
 * 				MCIAVI_mciSignal			[internal]
828
 */
829
static	DWORD	MCIAVI_mciSignal(UINT wDevID, DWORD dwFlags, LPMCI_DGV_SIGNAL_PARMS lpParms)
830
{
831
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
832

833
    FIXME("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
834

835 836
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
837

838 839 840 841
    return 0;
}

/******************************************************************************
842
 * 				MCIAVI_mciSetVideo			[internal]
843
 */
844
static	DWORD	MCIAVI_mciSetVideo(UINT wDevID, DWORD dwFlags, LPMCI_DGV_SETVIDEO_PARMSA lpParms)
845
{
846
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
847

848
    FIXME("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
849

850 851
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
852

853 854 855 856
    return 0;
}

/******************************************************************************
857
 * 				MCIAVI_mciQuality			[internal]
858
 */
859
static	DWORD	MCIAVI_mciQuality(UINT wDevID, DWORD dwFlags, LPMCI_DGV_QUALITY_PARMSA lpParms)
860
{
861
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
862

863
    FIXME("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
864

865 866
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
867

868 869 870 871
    return 0;
}

/******************************************************************************
872
 * 				MCIAVI_mciList			[internal]
873
 */
874
static	DWORD	MCIAVI_mciList(UINT wDevID, DWORD dwFlags, LPMCI_DGV_LIST_PARMSA lpParms)
875
{
876
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
877

878
    FIXME("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
879

880 881
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
882

883 884 885 886
    return 0;
}

/******************************************************************************
887
 * 				MCIAVI_mciUndo			[internal]
888
 */
889
static	DWORD	MCIAVI_mciUndo(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
890
{
891
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
892

893
    FIXME("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
894

895 896
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
897

898 899 900 901
    return 0;
}

/******************************************************************************
902
 * 				MCIAVI_mciConfigure			[internal]
903
 */
904
static	DWORD	MCIAVI_mciConfigure(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
905
{
906
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
907

908
    FIXME("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
909

910 911
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
912

913 914 915 916
    return 0;
}

/******************************************************************************
917
 * 				MCIAVI_mciRestore			[internal]
918
 */
919
static	DWORD	MCIAVI_mciRestore(UINT wDevID, DWORD dwFlags, LPMCI_DGV_RESTORE_PARMSA lpParms)
920
{
921
    WINE_MCIAVI*	wma = MCIAVI_mciGetOpenDev(wDevID);
922

923
    FIXME("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
924

925 926
    if (lpParms == NULL)	return MCIERR_NULL_PARAMETER_BLOCK;
    if (wma == NULL)		return MCIERR_INVALID_DEVICE_ID;
927

928 929
    return 0;
}
930 931 932 933 934 935

/*======================================================================*
 *                  	    MCI AVI entry points			*
 *======================================================================*/

/**************************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
936
 * 				DriverProc (MCIAVI.@)
937
 */
938
LONG CALLBACK	MCIAVI_DriverProc(DWORD dwDevID, HDRVR hDriv, DWORD wMsg,
939
				  DWORD dwParam1, DWORD dwParam2)
940
{
941
    TRACE("(%08lX, %p, %08lX, %08lX, %08lX)\n",
942
	  dwDevID, hDriv, wMsg, dwParam1, dwParam2);
943

944 945 946
    switch (wMsg) {
    case DRV_LOAD:		return 1;
    case DRV_FREE:		return 1;
947 948
    case DRV_OPEN:		return MCIAVI_drvOpen((LPSTR)dwParam1, (LPMCI_OPEN_DRIVER_PARMSA)dwParam2);
    case DRV_CLOSE:		return MCIAVI_drvClose(dwDevID);
949 950 951
    case DRV_ENABLE:		return 1;
    case DRV_DISABLE:		return 1;
    case DRV_QUERYCONFIGURE:	return 1;
952
    case DRV_CONFIGURE:		return MCIAVI_drvConfigure(dwDevID);
953 954
    case DRV_INSTALL:		return DRVCNF_RESTART;
    case DRV_REMOVE:		return DRVCNF_RESTART;
955
    }
956

957 958 959
    if (dwDevID == 0xFFFFFFFF) return MCIERR_UNSUPPORTED_FUNCTION;

    switch (wMsg) {
960 961 962 963 964 965 966 967 968 969 970 971
    case MCI_OPEN_DRIVER:	return MCIAVI_mciOpen      (dwDevID, dwParam1, (LPMCI_DGV_OPEN_PARMSA)     dwParam2);
    case MCI_CLOSE_DRIVER:	return MCIAVI_mciClose     (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)       dwParam2);
    case MCI_PLAY:		return MCIAVI_mciPlay      (dwDevID, dwParam1, (LPMCI_PLAY_PARMS)          dwParam2);
    case MCI_RECORD:		return MCIAVI_mciRecord    (dwDevID, dwParam1, (LPMCI_DGV_RECORD_PARMS)    dwParam2);
    case MCI_STOP:		return MCIAVI_mciStop      (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)       dwParam2);
    case MCI_SET:		return MCIAVI_mciSet       (dwDevID, dwParam1, (LPMCI_DGV_SET_PARMS)       dwParam2);
    case MCI_PAUSE:		return MCIAVI_mciPause     (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)       dwParam2);
    case MCI_RESUME:		return MCIAVI_mciResume    (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)       dwParam2);
    case MCI_STATUS:		return MCIAVI_mciStatus    (dwDevID, dwParam1, (LPMCI_DGV_STATUS_PARMSA)   dwParam2);
    case MCI_GETDEVCAPS:	return MCIAVI_mciGetDevCaps(dwDevID, dwParam1, (LPMCI_GETDEVCAPS_PARMS)    dwParam2);
    case MCI_INFO:		return MCIAVI_mciInfo      (dwDevID, dwParam1, (LPMCI_DGV_INFO_PARMSA)     dwParam2);
    case MCI_SEEK:		return MCIAVI_mciSeek      (dwDevID, dwParam1, (LPMCI_SEEK_PARMS)          dwParam2);
972 973 974 975
    case MCI_PUT:		return MCIAVI_mciPut	   (dwDevID, dwParam1, (LPMCI_DGV_PUT_PARMS)       dwParam2);
    case MCI_WINDOW:		return MCIAVI_mciWindow	   (dwDevID, dwParam1, (LPMCI_DGV_WINDOW_PARMSA)   dwParam2);
    case MCI_LOAD:		return MCIAVI_mciLoad      (dwDevID, dwParam1, (LPMCI_DGV_LOAD_PARMSA)     dwParam2);
    case MCI_SAVE:		return MCIAVI_mciSave      (dwDevID, dwParam1, (LPMCI_DGV_SAVE_PARMSA)     dwParam2);
976 977 978 979 980 981
    case MCI_FREEZE:		return MCIAVI_mciFreeze	   (dwDevID, dwParam1, (LPMCI_DGV_RECT_PARMS)      dwParam2);
    case MCI_REALIZE:		return MCIAVI_mciRealize   (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)       dwParam2);
    case MCI_UNFREEZE:		return MCIAVI_mciUnFreeze  (dwDevID, dwParam1, (LPMCI_DGV_RECT_PARMS)      dwParam2);
    case MCI_UPDATE:		return MCIAVI_mciUpdate    (dwDevID, dwParam1, (LPMCI_DGV_UPDATE_PARMS)    dwParam2);
    case MCI_WHERE:		return MCIAVI_mciWhere	   (dwDevID, dwParam1, (LPMCI_DGV_RECT_PARMS)      dwParam2);
    case MCI_STEP:		return MCIAVI_mciStep      (dwDevID, dwParam1, (LPMCI_DGV_STEP_PARMS)      dwParam2);
982 983 984 985
    case MCI_COPY:		return MCIAVI_mciCopy      (dwDevID, dwParam1, (LPMCI_DGV_COPY_PARMS)      dwParam2);
    case MCI_CUT:		return MCIAVI_mciCut       (dwDevID, dwParam1, (LPMCI_DGV_CUT_PARMS)       dwParam2);
    case MCI_DELETE:		return MCIAVI_mciDelete    (dwDevID, dwParam1, (LPMCI_DGV_DELETE_PARMS)    dwParam2);
    case MCI_PASTE:		return MCIAVI_mciPaste     (dwDevID, dwParam1, (LPMCI_DGV_PASTE_PARMS)     dwParam2);
986
    case MCI_CUE:		return MCIAVI_mciCue       (dwDevID, dwParam1, (LPMCI_DGV_CUE_PARMS)       dwParam2);
987
	/* Digital Video specific */
988 989 990 991 992 993 994 995 996 997 998
    case MCI_CAPTURE:		return MCIAVI_mciCapture   (dwDevID, dwParam1, (LPMCI_DGV_CAPTURE_PARMSA)  dwParam2);
    case MCI_MONITOR:		return MCIAVI_mciMonitor   (dwDevID, dwParam1, (LPMCI_DGV_MONITOR_PARMS)   dwParam2);
    case MCI_RESERVE:		return MCIAVI_mciReserve   (dwDevID, dwParam1, (LPMCI_DGV_RESERVE_PARMSA)  dwParam2);
    case MCI_SETAUDIO:		return MCIAVI_mciSetAudio  (dwDevID, dwParam1, (LPMCI_DGV_SETAUDIO_PARMSA) dwParam2);
    case MCI_SIGNAL:		return MCIAVI_mciSignal    (dwDevID, dwParam1, (LPMCI_DGV_SIGNAL_PARMS)    dwParam2);
    case MCI_SETVIDEO:		return MCIAVI_mciSetVideo  (dwDevID, dwParam1, (LPMCI_DGV_SETVIDEO_PARMSA) dwParam2);
    case MCI_QUALITY:		return MCIAVI_mciQuality   (dwDevID, dwParam1, (LPMCI_DGV_QUALITY_PARMSA)  dwParam2);
    case MCI_LIST:		return MCIAVI_mciList      (dwDevID, dwParam1, (LPMCI_DGV_LIST_PARMSA)     dwParam2);
    case MCI_UNDO:		return MCIAVI_mciUndo      (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)       dwParam2);
    case MCI_CONFIGURE:		return MCIAVI_mciConfigure (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)       dwParam2);
    case MCI_RESTORE:		return MCIAVI_mciRestore   (dwDevID, dwParam1, (LPMCI_DGV_RESTORE_PARMSA)  dwParam2);
999

1000
    case MCI_SPIN:
1001
    case MCI_ESCAPE:
1002
	WARN("Unsupported command [%lu]\n", wMsg);
1003 1004 1005
	break;
    case MCI_OPEN:
    case MCI_CLOSE:
1006
	FIXME("Shouldn't receive a MCI_OPEN or CLOSE message\n");
1007
	break;
1008
    default:
1009
	TRACE("Sending msg [%lu] to default driver proc\n", wMsg);
1010
	return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
1011 1012 1013
    }
    return MCIERR_UNRECOGNIZED_COMMAND;
}