Added some error checking ; made use of new 16/32 MCI message handling

in mmsystem.c ; fixed bug in MCI_INFO command.
This commit is contained in:
Eric Pouech 1998-11-24 14:34:29 +00:00 committed by Alexandre Julliard
parent dd49344e58
commit 210ef5f67d
1 changed files with 201 additions and 168 deletions

View File

@ -15,6 +15,7 @@
#include "driver.h" #include "driver.h"
#include "mmsystem.h" #include "mmsystem.h"
#include "debug.h" #include "debug.h"
#include "multimedia.h"
#define MAX_ANIMDRV 2 #define MAX_ANIMDRV 2
@ -27,7 +28,7 @@ typedef struct {
BOOL16 fShareable; /* TRUE if first open was shareable */ BOOL16 fShareable; /* TRUE if first open was shareable */
WORD wNotifyDeviceID; /* MCI device ID with a pending notification */ WORD wNotifyDeviceID; /* MCI device ID with a pending notification */
HANDLE16 hCallback; /* Callback handle for pending notification */ HANDLE16 hCallback; /* Callback handle for pending notification */
MCI_OPEN_PARMS16 openParms; MCI_OPEN_PARMS32A openParms;
DWORD dwTimeFormat; DWORD dwTimeFormat;
int mode; int mode;
UINT16 nCurTrack; UINT16 nCurTrack;
@ -36,65 +37,74 @@ typedef struct {
DWORD dwTotalLen; DWORD dwTotalLen;
LPDWORD lpdwTrackLen; LPDWORD lpdwTrackLen;
LPDWORD lpdwTrackPos; LPDWORD lpdwTrackPos;
} WINE_ANIM; } WINE_MCIANIM;
static WINE_ANIM AnimDev[MAX_ANIMDRV];
static WINE_MCIANIM AnimDev[MAX_ANIMDRV];
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/**************************************************************************
* ANIM_mciGetOpenDrv [internal]
*/
static WINE_MCIANIM* ANIM_mciGetOpenDrv(UINT16 wDevID)
{
if (wDevID >= MAX_ANIMDRV || AnimDev[wDevID].nUseCount == 0) {
WARN(mcianim, "Invalid wDevID=%u\n", wDevID);
return 0;
}
return &AnimDev[wDevID];
}
/************************************************************************** /**************************************************************************
* ANIM_mciOpen [internal] * ANIM_mciOpen [internal]
*/ */
static DWORD ANIM_mciOpen(UINT16 wDevID, DWORD dwFlags, void* lp, BOOL32 is32) static DWORD ANIM_mciOpen(UINT16 wDevID, DWORD dwFlags, LPMCI_OPEN_PARMS32A lpOpenParms)
{ {
DWORD dwDeviceID; DWORD dwDeviceID;
WINE_MCIANIM* wma;
TRACE(mcianim,"(%04X, %08lX, %p);\n", wDevID, dwFlags, lp); TRACE(mcianim,"(%04X, %08lX, %p);\n", wDevID, dwFlags, lpOpenParms);
if (lp == NULL) return MCIERR_INTERNAL;
if (AnimDev[wDevID].nUseCount > 0) { if (lpOpenParms == NULL) return MCIERR_INTERNAL;
if (wDevID >= MAX_ANIMDRV) return MCIERR_INVALID_DEVICE_ID;
wma = &AnimDev[wDevID];
if (wma->nUseCount > 0) {
/* The driver already open on this channel */ /* The driver already open on this channel */
/* If the driver was opened shareable before and this open specifies */ /* If the driver was opened shareable before and this open specifies */
/* shareable then increment the use count */ /* shareable then increment the use count */
if (AnimDev[wDevID].fShareable && (dwFlags & MCI_OPEN_SHAREABLE)) if (wma->fShareable && (dwFlags & MCI_OPEN_SHAREABLE))
++AnimDev[wDevID].nUseCount; ++wma->nUseCount;
else else
return MCIERR_MUST_USE_SHAREABLE; return MCIERR_MUST_USE_SHAREABLE;
} } else {
else { wma->nUseCount = 1;
AnimDev[wDevID].nUseCount = 1; wma->fShareable = dwFlags & MCI_OPEN_SHAREABLE;
AnimDev[wDevID].fShareable = dwFlags & MCI_OPEN_SHAREABLE;
} }
if (is32) dwDeviceID = ((LPMCI_OPEN_PARMS32A)lp)->wDeviceID; dwDeviceID = lpOpenParms->wDeviceID;
else dwDeviceID = ((LPMCI_OPEN_PARMS16)lp)->wDeviceID;
TRACE(mcianim,"wDevID=%04X\n", wDevID); TRACE(mcianim,"wDevID=%04X\n", wDevID);
/* FIXME this is not consistent with other implementations */ /* FIXME this is not consistent with other implementations */
if (is32) ((LPMCI_OPEN_PARMS32A)lp)->wDeviceID = wDevID; lpOpenParms->wDeviceID = wDevID;
else ((LPMCI_OPEN_PARMS16)lp)->wDeviceID = wDevID;
/*TRACE(mcianim,"lpParms->wDevID=%04X\n", lpParms->wDeviceID);*/ /*TRACE(mcianim,"lpParms->wDevID=%04X\n", lpParms->wDeviceID);*/
if (dwFlags & MCI_OPEN_ELEMENT) { if (dwFlags & MCI_OPEN_ELEMENT) {
LPSTR lpstrElementName; TRACE(mcianim,"MCI_OPEN_ELEMENT '%s' !\n", lpOpenParms->lpstrElementName);
if (lpOpenParms->lpstrElementName && strlen(lpOpenParms->lpstrElementName) > 0) {
if (is32) lpstrElementName = ((LPMCI_OPEN_PARMS32A)lp)->lpstrElementName;
else lpstrElementName = (LPSTR)PTR_SEG_TO_LIN(((LPMCI_OPEN_PARMS16)lp)->lpstrElementName);
TRACE(mcianim,"MCI_OPEN_ELEMENT '%s' !\n", lpstrElementName);
if (lpstrElementName && strlen(lpstrElementName) > 0) {
} }
FIXME(mcianim, "element is not opened\n"); FIXME(mcianim, "element is not opened\n");
} }
memcpy(&AnimDev[wDevID].openParms, lp, sizeof(MCI_OPEN_PARMS16)); memcpy(&wma->openParms, lpOpenParms, sizeof(MCI_OPEN_PARMS32A));
AnimDev[wDevID].wNotifyDeviceID = dwDeviceID; wma->wNotifyDeviceID = dwDeviceID;
AnimDev[wDevID].mode = 0; wma->mode = 0;
AnimDev[wDevID].dwTimeFormat = MCI_FORMAT_TMSF; wma->dwTimeFormat = MCI_FORMAT_TMSF;
AnimDev[wDevID].nCurTrack = 0; wma->nCurTrack = 0;
AnimDev[wDevID].nTracks = 0; wma->nTracks = 0;
AnimDev[wDevID].dwTotalLen = 0; wma->dwTotalLen = 0;
AnimDev[wDevID].lpdwTrackLen = NULL; wma->lpdwTrackLen = NULL;
AnimDev[wDevID].lpdwTrackPos = NULL; wma->lpdwTrackPos = NULL;
/* /*
Moved to mmsystem.c mciOpen routine Moved to mmsystem.c mciOpen routine
@ -102,7 +112,7 @@ static DWORD ANIM_mciOpen(UINT16 wDevID, DWORD dwFlags, void* lp, BOOL32 is32)
TRACE(mcianim, "MCI_NOTIFY_SUCCESSFUL %08lX !\n", TRACE(mcianim, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback); lpParms->dwCallback);
mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback),
AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL); wma->wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
} }
*/ */
return 0; return 0;
@ -113,10 +123,16 @@ static DWORD ANIM_mciOpen(UINT16 wDevID, DWORD dwFlags, void* lp, BOOL32 is32)
*/ */
static DWORD ANIM_mciClose(UINT16 wDevID, DWORD dwParam, LPMCI_GENERIC_PARMS lpParms) static DWORD ANIM_mciClose(UINT16 wDevID, DWORD dwParam, LPMCI_GENERIC_PARMS lpParms)
{ {
TRACE(mcianim,"(%u, %08lX, %p);\n", WINE_MCIANIM* wma = ANIM_mciGetOpenDrv(wDevID);
wDevID, dwParam, lpParms);
if (AnimDev[wDevID].lpdwTrackLen != NULL) free(AnimDev[wDevID].lpdwTrackLen); TRACE(mcianim,"(%u, %08lX, %p);\n", wDevID, dwParam, lpParms);
if (AnimDev[wDevID].lpdwTrackPos != NULL) free(AnimDev[wDevID].lpdwTrackPos);
if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
if (--wma->nUseCount == 0) {
if (wma->lpdwTrackLen != NULL) free(wma->lpdwTrackLen);
if (wma->lpdwTrackPos != NULL) free(wma->lpdwTrackPos);
}
return 0; return 0;
} }
@ -126,12 +142,15 @@ static DWORD ANIM_mciClose(UINT16 wDevID, DWORD dwParam, LPMCI_GENERIC_PARMS lpP
static DWORD ANIM_mciGetDevCaps(UINT16 wDevID, DWORD dwFlags, static DWORD ANIM_mciGetDevCaps(UINT16 wDevID, DWORD dwFlags,
LPMCI_GETDEVCAPS_PARMS lpParms) LPMCI_GETDEVCAPS_PARMS lpParms)
{ {
TRACE(mcianim,"(%u, %08lX, %p);\n", WINE_MCIANIM* wma = ANIM_mciGetOpenDrv(wDevID);
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL; TRACE(mcianim,"(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
if (dwFlags & MCI_GETDEVCAPS_ITEM) { if (dwFlags & MCI_GETDEVCAPS_ITEM) {
TRACE(mcianim, "MCI_GETDEVCAPS_ITEM dwItem=%08lX;\n", TRACE(mcianim, "MCI_GETDEVCAPS_ITEM dwItem=%08lX;\n", lpParms->dwItem);
lpParms->dwItem);
switch(lpParms->dwItem) { switch(lpParms->dwItem) {
case MCI_GETDEVCAPS_CAN_RECORD: case MCI_GETDEVCAPS_CAN_RECORD:
lpParms->dwReturn = FALSE; lpParms->dwReturn = FALSE;
@ -164,8 +183,7 @@ static DWORD ANIM_mciGetDevCaps(UINT16 wDevID, DWORD dwFlags,
return MCIERR_UNRECOGNIZED_COMMAND; return MCIERR_UNRECOGNIZED_COMMAND;
} }
} }
TRACE(mcianim, "lpParms->dwReturn=%08lX;\n", TRACE(mcianim, "lpParms->dwReturn=%08lX;\n", lpParms->dwReturn);
lpParms->dwReturn);
return 0; return 0;
} }
@ -173,15 +191,15 @@ static DWORD ANIM_mciGetDevCaps(UINT16 wDevID, DWORD dwFlags,
/************************************************************************** /**************************************************************************
* ANIM_CalcTime [internal] * ANIM_CalcTime [internal]
*/ */
static DWORD ANIM_CalcTime(UINT16 wDevID, DWORD dwFormatType, DWORD dwFrame) static DWORD ANIM_CalcTime(WINE_MCIANIM* wma, DWORD dwFormatType, DWORD dwFrame)
{ {
DWORD dwTime = 0; DWORD dwTime = 0;
UINT16 wTrack; UINT16 wTrack;
UINT16 wMinutes; UINT16 wMinutes;
UINT16 wSeconds; UINT16 wSeconds;
UINT16 wFrames; UINT16 wFrames;
TRACE(mcianim,"(%u, %08lX, %lu);\n",
wDevID, dwFormatType, dwFrame); TRACE(mcianim,"(%p, %08lX, %lu);\n", wma, dwFormatType, dwFrame);
switch (dwFormatType) { switch (dwFormatType) {
case MCI_FORMAT_MILLISECONDS: case MCI_FORMAT_MILLISECONDS:
@ -201,11 +219,11 @@ static DWORD ANIM_CalcTime(UINT16 wDevID, DWORD dwFormatType, DWORD dwFrame)
/* unknown format ! force TMSF ! ... */ /* unknown format ! force TMSF ! ... */
dwFormatType = MCI_FORMAT_TMSF; dwFormatType = MCI_FORMAT_TMSF;
case MCI_FORMAT_TMSF: case MCI_FORMAT_TMSF:
for (wTrack = 0; wTrack < AnimDev[wDevID].nTracks; wTrack++) { for (wTrack = 0; wTrack < wma->nTracks; wTrack++) {
/* dwTime += AnimDev[wDevID].lpdwTrackLen[wTrack - 1]; /* dwTime += wma->lpdwTrackLen[wTrack - 1];
TRACE(mcianim, "Adding trk#%u curpos=%u \n", dwTime); TRACE(mcianim, "Adding trk#%u curpos=%u \n", dwTime);
if (dwTime >= dwFrame) break; */ if (dwTime >= dwFrame) break; */
if (AnimDev[wDevID].lpdwTrackPos[wTrack - 1] >= dwFrame) break; if (wma->lpdwTrackPos[wTrack - 1] >= dwFrame) break;
} }
wMinutes = dwFrame / ANIMFRAMES_PERMIN; wMinutes = dwFrame / ANIMFRAMES_PERMIN;
wSeconds = (dwFrame - ANIMFRAMES_PERMIN * wMinutes) / ANIMFRAMES_PERSEC; wSeconds = (dwFrame - ANIMFRAMES_PERMIN * wMinutes) / ANIMFRAMES_PERSEC;
@ -223,12 +241,12 @@ static DWORD ANIM_CalcTime(UINT16 wDevID, DWORD dwFormatType, DWORD dwFrame)
/************************************************************************** /**************************************************************************
* ANIM_CalcFrame [internal] * ANIM_CalcFrame [internal]
*/ */
static DWORD ANIM_CalcFrame(UINT16 wDevID, DWORD dwFormatType, DWORD dwTime) static DWORD ANIM_CalcFrame(WINE_MCIANIM* wma, DWORD dwFormatType, DWORD dwTime)
{ {
DWORD dwFrame = 0; DWORD dwFrame = 0;
UINT16 wTrack; UINT16 wTrack;
TRACE(mcianim,"(%u, %08lX, %lu);\n",
wDevID, dwFormatType, dwTime); TRACE(mcianim,"(%p, %08lX, %lu);\n", wma, dwFormatType, dwTime);
switch (dwFormatType) { switch (dwFormatType) {
case MCI_FORMAT_MILLISECONDS: case MCI_FORMAT_MILLISECONDS:
@ -252,8 +270,8 @@ static DWORD ANIM_CalcFrame(UINT16 wDevID, DWORD dwFormatType, DWORD dwTime)
MCI_TMSF_TRACK(dwTime), MCI_TMSF_MINUTE(dwTime), MCI_TMSF_TRACK(dwTime), MCI_TMSF_MINUTE(dwTime),
MCI_TMSF_SECOND(dwTime), MCI_TMSF_FRAME(dwTime)); MCI_TMSF_SECOND(dwTime), MCI_TMSF_FRAME(dwTime));
TRACE(mcianim, "TMSF trackpos[%u]=%lu\n", TRACE(mcianim, "TMSF trackpos[%u]=%lu\n",
wTrack, AnimDev[wDevID].lpdwTrackPos[wTrack - 1]); wTrack, wma->lpdwTrackPos[wTrack - 1]);
dwFrame = AnimDev[wDevID].lpdwTrackPos[wTrack - 1]; dwFrame = wma->lpdwTrackPos[wTrack - 1];
dwFrame += ANIMFRAMES_PERMIN * MCI_TMSF_MINUTE(dwTime); dwFrame += ANIMFRAMES_PERMIN * MCI_TMSF_MINUTE(dwTime);
dwFrame += ANIMFRAMES_PERSEC * MCI_TMSF_SECOND(dwTime); dwFrame += ANIMFRAMES_PERSEC * MCI_TMSF_SECOND(dwTime);
dwFrame += MCI_TMSF_FRAME(dwTime); dwFrame += MCI_TMSF_FRAME(dwTime);
@ -268,29 +286,41 @@ static DWORD ANIM_CalcFrame(UINT16 wDevID, DWORD dwFormatType, DWORD dwTime)
*/ */
static DWORD ANIM_mciInfo(UINT16 wDevID, DWORD dwFlags, LPMCI_INFO_PARMS16 lpParms) static DWORD ANIM_mciInfo(UINT16 wDevID, DWORD dwFlags, LPMCI_INFO_PARMS16 lpParms)
{ {
TRACE(mcianim,"(%u, %08lX, %p);\n", WINE_MCIANIM* wma = ANIM_mciGetOpenDrv(wDevID);
wDevID, dwFlags, lpParms); DWORD ret = 0;
if (lpParms == NULL) return MCIERR_INTERNAL; LPSTR str = 0;
lpParms->lpstrReturn = NULL;
TRACE(mcianim,"(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
if (lpParms == NULL || lpParms->lpstrReturn == NULL) {
ret = MCIERR_NULL_PARAMETER_BLOCK;
} else if (wma == NULL) {
ret = MCIERR_INVALID_DEVICE_ID;
} else {
TRACE(mcianim, "buf=%p, len=%lu\n", lpParms->lpstrReturn, lpParms->dwRetSize);
switch(dwFlags) { switch(dwFlags) {
case MCI_INFO_PRODUCT: case MCI_INFO_PRODUCT:
lpParms->lpstrReturn = "Linux ANIMATION 0.5"; str = "Wine's animation";
break; break;
case MCI_INFO_FILE: case MCI_INFO_FILE:
lpParms->lpstrReturn = str = wma->openParms.lpstrElementName;
(LPSTR)AnimDev[wDevID].openParms.lpstrElementName;
break; break;
case MCI_ANIM_INFO_TEXT: case MCI_ANIM_INFO_TEXT:
lpParms->lpstrReturn = "Animation Window"; str = "Animation Window";
break; break;
default: default:
return MCIERR_UNRECOGNIZED_COMMAND; WARN(mcianim, "Don't know this info command (%lu)\n", dwFlags);
ret = MCIERR_UNRECOGNIZED_COMMAND;
} }
if (lpParms->lpstrReturn != NULL) }
lpParms->dwRetSize = strlen(lpParms->lpstrReturn); if (str) {
else ret = MCI_WriteString(lpParms->lpstrReturn, lpParms->dwRetSize, str);
lpParms->dwRetSize = 0; } else {
return 0; lpParms->lpstrReturn[0] = 0;
}
return ret;
} }
/************************************************************************** /**************************************************************************
@ -298,37 +328,40 @@ static DWORD ANIM_mciInfo(UINT16 wDevID, DWORD dwFlags, LPMCI_INFO_PARMS16 lpPar
*/ */
static DWORD ANIM_mciStatus(UINT16 wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParms) static DWORD ANIM_mciStatus(UINT16 wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParms)
{ {
TRACE(mcianim,"(%u, %08lX, %p);\n", WINE_MCIANIM* wma = ANIM_mciGetOpenDrv(wDevID);
wDevID, dwFlags, lpParms);
TRACE(mcianim,"(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL; if (lpParms == NULL) return MCIERR_INTERNAL;
if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
if (dwFlags & MCI_NOTIFY) { if (dwFlags & MCI_NOTIFY) {
TRACE(mcianim, "MCI_NOTIFY_SUCCESSFUL %08lX !\n", TRACE(mcianim, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback); lpParms->dwCallback);
mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), mciDriverNotify16((HWND16)LOWORD(lpParms->dwCallback),
AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL); wma->wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
} }
if (dwFlags & MCI_STATUS_ITEM) { if (dwFlags & MCI_STATUS_ITEM) {
switch(lpParms->dwItem) { switch(lpParms->dwItem) {
case MCI_STATUS_CURRENT_TRACK: case MCI_STATUS_CURRENT_TRACK:
lpParms->dwReturn = AnimDev[wDevID].nCurTrack; lpParms->dwReturn = wma->nCurTrack;
TRACE(mcianim,"CURRENT_TRACK=%lu!\n", lpParms->dwReturn); TRACE(mcianim,"CURRENT_TRACK=%lu!\n", lpParms->dwReturn);
return 0; return 0;
case MCI_STATUS_LENGTH: case MCI_STATUS_LENGTH:
if (dwFlags & MCI_TRACK) { if (dwFlags & MCI_TRACK) {
TRACE(mcianim,"MCI_TRACK #%lu LENGTH=??? !\n", TRACE(mcianim,"MCI_TRACK #%lu LENGTH=??? !\n",
lpParms->dwTrack); lpParms->dwTrack);
if (lpParms->dwTrack > AnimDev[wDevID].nTracks) if (lpParms->dwTrack > wma->nTracks)
return MCIERR_OUTOFRANGE; return MCIERR_OUTOFRANGE;
lpParms->dwReturn = AnimDev[wDevID].lpdwTrackLen[lpParms->dwTrack]; lpParms->dwReturn = wma->lpdwTrackLen[lpParms->dwTrack];
} }
else else
lpParms->dwReturn = AnimDev[wDevID].dwTotalLen; lpParms->dwReturn = wma->dwTotalLen;
lpParms->dwReturn = ANIM_CalcTime(wDevID, lpParms->dwReturn = ANIM_CalcTime(wma, wma->dwTimeFormat, lpParms->dwReturn);
AnimDev[wDevID].dwTimeFormat, lpParms->dwReturn);
TRACE(mcianim,"LENGTH=%lu !\n", lpParms->dwReturn); TRACE(mcianim,"LENGTH=%lu !\n", lpParms->dwReturn);
return 0; return 0;
case MCI_STATUS_MODE: case MCI_STATUS_MODE:
lpParms->dwReturn = AnimDev[wDevID].mode; lpParms->dwReturn = wma->mode;
TRACE(mcianim,"MCI_STATUS_MODE=%08lX !\n", TRACE(mcianim,"MCI_STATUS_MODE=%08lX !\n",
lpParms->dwReturn); lpParms->dwReturn);
return 0; return 0;
@ -343,19 +376,18 @@ static DWORD ANIM_mciStatus(UINT16 wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpP
if (lpParms->dwReturn == (WORD)-1) return MCIERR_INTERNAL; if (lpParms->dwReturn == (WORD)-1) return MCIERR_INTERNAL;
return 0; return 0;
case MCI_STATUS_POSITION: case MCI_STATUS_POSITION:
lpParms->dwReturn = AnimDev[wDevID].dwCurFrame; lpParms->dwReturn = wma->dwCurFrame;
if (dwFlags & MCI_STATUS_START) { if (dwFlags & MCI_STATUS_START) {
lpParms->dwReturn = 0; lpParms->dwReturn = 0;
TRACE(mcianim,"get MCI_STATUS_START !\n"); TRACE(mcianim,"get MCI_STATUS_START !\n");
} }
if (dwFlags & MCI_TRACK) { if (dwFlags & MCI_TRACK) {
if (lpParms->dwTrack > AnimDev[wDevID].nTracks) if (lpParms->dwTrack > wma->nTracks)
return MCIERR_OUTOFRANGE; return MCIERR_OUTOFRANGE;
lpParms->dwReturn = AnimDev[wDevID].lpdwTrackPos[lpParms->dwTrack - 1]; lpParms->dwReturn = wma->lpdwTrackPos[lpParms->dwTrack - 1];
TRACE(mcianim,"get MCI_TRACK #%lu !\n", lpParms->dwTrack); TRACE(mcianim,"get MCI_TRACK #%lu !\n", lpParms->dwTrack);
} }
lpParms->dwReturn = ANIM_CalcTime(wDevID, lpParms->dwReturn = ANIM_CalcTime(wma, wma->dwTimeFormat, lpParms->dwReturn);
AnimDev[wDevID].dwTimeFormat, lpParms->dwReturn);
TRACE(mcianim,"MCI_STATUS_POSITION=%08lX !\n", TRACE(mcianim,"MCI_STATUS_POSITION=%08lX !\n",
lpParms->dwReturn); lpParms->dwReturn);
return 0; return 0;
@ -382,30 +414,30 @@ static DWORD ANIM_mciStatus(UINT16 wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpP
*/ */
static DWORD ANIM_mciPlay(UINT16 wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms) static DWORD ANIM_mciPlay(UINT16 wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms)
{ {
WINE_MCIANIM* wma = ANIM_mciGetOpenDrv(wDevID);
int start, end; int start, end;
TRACE(mcianim,"(%u, %08lX, %p);\n",
wDevID, dwFlags, lpParms); TRACE(mcianim,"(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL; if (lpParms == NULL) return MCIERR_INTERNAL;
start = 0; end = AnimDev[wDevID].dwTotalLen; if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
AnimDev[wDevID].nCurTrack = 1;
start = 0; end = wma->dwTotalLen;
wma->nCurTrack = 1;
if (dwFlags & MCI_FROM) { if (dwFlags & MCI_FROM) {
start = ANIM_CalcFrame(wDevID, start = ANIM_CalcFrame(wma, wma->dwTimeFormat, lpParms->dwFrom);
AnimDev[wDevID].dwTimeFormat, lpParms->dwFrom); TRACE(mcianim,"MCI_FROM=%08lX -> %u \n", lpParms->dwFrom, start);
TRACE(mcianim,"MCI_FROM=%08lX -> %u \n",
lpParms->dwFrom, start);
} }
if (dwFlags & MCI_TO) { if (dwFlags & MCI_TO) {
end = ANIM_CalcFrame(wDevID, end = ANIM_CalcFrame(wma, wma->dwTimeFormat, lpParms->dwTo);
AnimDev[wDevID].dwTimeFormat, lpParms->dwTo); TRACE(mcianim, "MCI_TO=%08lX -> %u \n", lpParms->dwTo, end);
TRACE(mcianim, "MCI_TO=%08lX -> %u \n",
lpParms->dwTo, end);
} }
AnimDev[wDevID].mode = MCI_MODE_PLAY; wma->mode = MCI_MODE_PLAY;
if (dwFlags & MCI_NOTIFY) { if (dwFlags & MCI_NOTIFY) {
TRACE(mcianim, "MCI_NOTIFY_SUCCESSFUL %08lX !\n", TRACE(mcianim, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback); lpParms->dwCallback);
mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), mciDriverNotify16((HWND16)LOWORD(lpParms->dwCallback),
AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL); wma->wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
} }
return 0; return 0;
} }
@ -415,15 +447,19 @@ static DWORD ANIM_mciPlay(UINT16 wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms
*/ */
static DWORD ANIM_mciStop(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms) static DWORD ANIM_mciStop(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
{ {
TRACE(mcianim,"(%u, %08lX, %p);\n", WINE_MCIANIM* wma = ANIM_mciGetOpenDrv(wDevID);
wDevID, dwFlags, lpParms);
TRACE(mcianim,"(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL; if (lpParms == NULL) return MCIERR_INTERNAL;
AnimDev[wDevID].mode = MCI_MODE_STOP; if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
wma->mode = MCI_MODE_STOP;
if (dwFlags & MCI_NOTIFY) { if (dwFlags & MCI_NOTIFY) {
TRACE(mcianim, "MCI_NOTIFY_SUCCESSFUL %08lX !\n", TRACE(mcianim, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback); lpParms->dwCallback);
mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), mciDriverNotify16((HWND16)LOWORD(lpParms->dwCallback),
AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL); wma->wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
} }
return 0; return 0;
} }
@ -433,15 +469,16 @@ static DWORD ANIM_mciStop(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpPa
*/ */
static DWORD ANIM_mciPause(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms) static DWORD ANIM_mciPause(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
{ {
TRACE(mcianim,"(%u, %08lX, %p);\n", WINE_MCIANIM* wma = ANIM_mciGetOpenDrv(wDevID);
wDevID, dwFlags, lpParms);
TRACE(mcianim,"(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL; if (lpParms == NULL) return MCIERR_INTERNAL;
AnimDev[wDevID].mode = MCI_MODE_PAUSE; wma->mode = MCI_MODE_PAUSE;
if (dwFlags & MCI_NOTIFY) { if (dwFlags & MCI_NOTIFY) {
TRACE(mcianim, "MCI_NOTIFY_SUCCESSFUL %08lX !\n", TRACE(mcianim, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback); lpParms->dwCallback);
mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), mciDriverNotify16((HWND16)LOWORD(lpParms->dwCallback),
AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL); wma->wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
} }
return 0; return 0;
} }
@ -451,15 +488,16 @@ static DWORD ANIM_mciPause(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpP
*/ */
static DWORD ANIM_mciResume(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms) static DWORD ANIM_mciResume(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
{ {
TRACE(mcianim,"(%u, %08lX, %p);\n", WINE_MCIANIM* wma = ANIM_mciGetOpenDrv(wDevID);
wDevID, dwFlags, lpParms);
TRACE(mcianim,"(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL; if (lpParms == NULL) return MCIERR_INTERNAL;
AnimDev[wDevID].mode = MCI_MODE_STOP; wma->mode = MCI_MODE_STOP;
if (dwFlags & MCI_NOTIFY) { if (dwFlags & MCI_NOTIFY) {
TRACE(mcianim, "MCI_NOTIFY_SUCCESSFUL %08lX !\n", TRACE(mcianim, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback); lpParms->dwCallback);
mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), mciDriverNotify16((HWND16)LOWORD(lpParms->dwCallback),
AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL); wma->wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
} }
return 0; return 0;
} }
@ -469,18 +507,20 @@ static DWORD ANIM_mciResume(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lp
*/ */
static DWORD ANIM_mciSeek(UINT16 wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms) static DWORD ANIM_mciSeek(UINT16 wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms)
{ {
WINE_MCIANIM* wma = ANIM_mciGetOpenDrv(wDevID);
DWORD dwRet; DWORD dwRet;
MCI_PLAY_PARMS PlayParms; MCI_PLAY_PARMS PlayParms;
TRACE(mcianim,"(%u, %08lX, %p);\n",
wDevID, dwFlags, lpParms); TRACE(mcianim,"(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL; if (lpParms == NULL) return MCIERR_INTERNAL;
AnimDev[wDevID].mode = MCI_MODE_SEEK; wma->mode = MCI_MODE_SEEK;
switch(dwFlags) { switch(dwFlags) {
case MCI_SEEK_TO_START: case MCI_SEEK_TO_START:
PlayParms.dwFrom = 0; PlayParms.dwFrom = 0;
break; break;
case MCI_SEEK_TO_END: case MCI_SEEK_TO_END:
PlayParms.dwFrom = AnimDev[wDevID].dwTotalLen; PlayParms.dwFrom = wma->dwTotalLen;
break; break;
case MCI_TO: case MCI_TO:
PlayParms.dwFrom = lpParms->dwTo; PlayParms.dwFrom = lpParms->dwTo;
@ -492,8 +532,8 @@ static DWORD ANIM_mciSeek(UINT16 wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms
if (dwFlags & MCI_NOTIFY) { if (dwFlags & MCI_NOTIFY) {
TRACE(mcianim, "MCI_NOTIFY_SUCCESSFUL %08lX !\n", TRACE(mcianim, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback); lpParms->dwCallback);
mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), mciDriverNotify16((HWND16)LOWORD(lpParms->dwCallback),
AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL); wma->wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
} }
return dwRet; return dwRet;
} }
@ -504,8 +544,11 @@ static DWORD ANIM_mciSeek(UINT16 wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms
*/ */
static DWORD ANIM_mciSet(UINT16 wDevID, DWORD dwFlags, LPMCI_SET_PARMS lpParms) static DWORD ANIM_mciSet(UINT16 wDevID, DWORD dwFlags, LPMCI_SET_PARMS lpParms)
{ {
WINE_MCIANIM* wma = ANIM_mciGetOpenDrv(wDevID);
TRACE(mcianim,"(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms); TRACE(mcianim,"(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL; if (lpParms == NULL) return MCIERR_INTERNAL;
if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
/* /*
TRACE(mcianim,"(dwTimeFormat=%08lX)\n", lpParms->dwTimeFormat); TRACE(mcianim,"(dwTimeFormat=%08lX)\n", lpParms->dwTimeFormat);
TRACE(mcianim,"(dwAudio=%08lX)\n", lpParms->dwAudio); TRACE(mcianim,"(dwAudio=%08lX)\n", lpParms->dwAudio);
@ -525,7 +568,7 @@ static DWORD ANIM_mciSet(UINT16 wDevID, DWORD dwFlags, LPMCI_SET_PARMS lpParms)
WARN(mcianim,"Bad time format !\n"); WARN(mcianim,"Bad time format !\n");
return MCIERR_BAD_TIME_FORMAT; return MCIERR_BAD_TIME_FORMAT;
} }
AnimDev[wDevID].dwTimeFormat = lpParms->dwTimeFormat; wma->dwTimeFormat = lpParms->dwTimeFormat;
} }
if (dwFlags & MCI_SET_VIDEO) return MCIERR_UNSUPPORTED_FUNCTION; if (dwFlags & MCI_SET_VIDEO) return MCIERR_UNSUPPORTED_FUNCTION;
if (dwFlags & MCI_SET_ON) return MCIERR_UNSUPPORTED_FUNCTION; if (dwFlags & MCI_SET_ON) return MCIERR_UNSUPPORTED_FUNCTION;
@ -533,67 +576,32 @@ static DWORD ANIM_mciSet(UINT16 wDevID, DWORD dwFlags, LPMCI_SET_PARMS lpParms)
if (dwFlags & MCI_NOTIFY) { if (dwFlags & MCI_NOTIFY) {
TRACE(mcianim, "MCI_NOTIFY_SUCCESSFUL %08lX !\n", TRACE(mcianim, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback); lpParms->dwCallback);
mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), mciDriverNotify16((HWND16)LOWORD(lpParms->dwCallback),
AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL); wma->wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
} }
return 0; return 0;
} }
/**************************************************************************
* ANIM_DriverProc16 [sample driver]
*/
LONG ANIM_DriverProc16(DWORD dwDevID, HDRVR16 hDriv, WORD wMsg,
DWORD dwParam1, DWORD dwParam2)
{
switch(wMsg) {
case DRV_LOAD: return 1;
case DRV_FREE: return 1;
case DRV_OPEN:
case MCI_OPEN_DRIVER:
case MCI_OPEN: return ANIM_mciOpen(dwDevID, dwParam1, (LPMCI_OPEN_PARMS16)PTR_SEG_TO_LIN(dwParam2), FALSE);
case DRV_CLOSE:
case MCI_CLOSE_DRIVER:
case MCI_CLOSE: return ANIM_mciClose(dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)PTR_SEG_TO_LIN(dwParam2));
case DRV_ENABLE: return 1;
case DRV_DISABLE: return 1;
case DRV_QUERYCONFIGURE: return 1;
case DRV_CONFIGURE: MessageBox16(0, "Sample MultiMedia Linux Driver !", "MMLinux Driver", MB_OK); return 1;
case DRV_INSTALL: return DRVCNF_RESTART;
case DRV_REMOVE: return DRVCNF_RESTART;
case MCI_GETDEVCAPS: return ANIM_mciGetDevCaps(dwDevID, dwParam1, (LPMCI_GETDEVCAPS_PARMS)PTR_SEG_TO_LIN(dwParam2));
case MCI_INFO: return ANIM_mciInfo(dwDevID, dwParam1, (LPMCI_INFO_PARMS16)PTR_SEG_TO_LIN(dwParam2));
case MCI_STATUS: return ANIM_mciStatus(dwDevID, dwParam1, (LPMCI_STATUS_PARMS)PTR_SEG_TO_LIN(dwParam2));
case MCI_SET: return ANIM_mciSet(dwDevID, dwParam1, (LPMCI_SET_PARMS)PTR_SEG_TO_LIN(dwParam2));
case MCI_PLAY: return ANIM_mciPlay(dwDevID, dwParam1, (LPMCI_PLAY_PARMS)PTR_SEG_TO_LIN(dwParam2));
case MCI_STOP: return ANIM_mciStop(dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)PTR_SEG_TO_LIN(dwParam2));
case MCI_PAUSE: return ANIM_mciPause(dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)PTR_SEG_TO_LIN(dwParam2));
case MCI_RESUME: return ANIM_mciResume(dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)PTR_SEG_TO_LIN(dwParam2));
case MCI_SEEK: return ANIM_mciSeek(dwDevID, dwParam1, (LPMCI_SEEK_PARMS)PTR_SEG_TO_LIN(dwParam2));
default: return DefDriverProc16(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
}
}
/************************************************************************** /**************************************************************************
* ANIM_DriverProc32 [sample driver] * ANIM_DriverProc32 [sample driver]
*/ */
LONG ANIM_DriverProc32(DWORD dwDevID, HDRVR16 hDriv, DWORD wMsg, LONG MCIANIM_DriverProc32(DWORD dwDevID, HDRVR16 hDriv, DWORD wMsg,
DWORD dwParam1, DWORD dwParam2) DWORD dwParam1, DWORD dwParam2)
{ {
switch(wMsg) { switch(wMsg) {
case DRV_LOAD: return 1; case DRV_LOAD: return 1;
case DRV_FREE: return 1; case DRV_FREE: return 1;
case DRV_OPEN: case DRV_OPEN: return 1;
case MCI_OPEN_DRIVER: case DRV_CLOSE: return 1;
case MCI_OPEN: return ANIM_mciOpen(dwDevID, dwParam1, (LPMCI_OPEN_PARMS32A)dwParam2, TRUE);
case DRV_CLOSE:
case MCI_CLOSE_DRIVER:
case MCI_CLOSE: return ANIM_mciClose(dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2);
case DRV_ENABLE: return 1; case DRV_ENABLE: return 1;
case DRV_DISABLE: return 1; case DRV_DISABLE: return 1;
case DRV_QUERYCONFIGURE: return 1; case DRV_QUERYCONFIGURE: return 1;
case DRV_CONFIGURE: MessageBox16(0, "Sample MultiMedia Linux Driver !", "MMLinux Driver", MB_OK); return 1; case DRV_CONFIGURE: MessageBox16(0, "Sample MultiMedia Linux Driver !", "MMLinux Driver", MB_OK); return 1;
case DRV_INSTALL: return DRVCNF_RESTART; case DRV_INSTALL: return DRVCNF_RESTART;
case DRV_REMOVE: return DRVCNF_RESTART; case DRV_REMOVE: return DRVCNF_RESTART;
case MCI_OPEN_DRIVER: return ANIM_mciOpen(dwDevID, dwParam1, (LPMCI_OPEN_PARMS32A)dwParam2);
case MCI_CLOSE_DRIVER: return ANIM_mciClose(dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2);
case MCI_GETDEVCAPS: return ANIM_mciGetDevCaps(dwDevID, dwParam1, (LPMCI_GETDEVCAPS_PARMS)dwParam2); case MCI_GETDEVCAPS: return ANIM_mciGetDevCaps(dwDevID, dwParam1, (LPMCI_GETDEVCAPS_PARMS)dwParam2);
case MCI_INFO: return ANIM_mciInfo(dwDevID, dwParam1, (LPMCI_INFO_PARMS16)dwParam2); case MCI_INFO: return ANIM_mciInfo(dwDevID, dwParam1, (LPMCI_INFO_PARMS16)dwParam2);
case MCI_STATUS: return ANIM_mciStatus(dwDevID, dwParam1, (LPMCI_STATUS_PARMS)dwParam2); case MCI_STATUS: return ANIM_mciStatus(dwDevID, dwParam1, (LPMCI_STATUS_PARMS)dwParam2);
@ -603,8 +611,33 @@ LONG ANIM_DriverProc32(DWORD dwDevID, HDRVR16 hDriv, DWORD wMsg,
case MCI_PAUSE: return ANIM_mciPause(dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2); case MCI_PAUSE: return ANIM_mciPause(dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2);
case MCI_RESUME: return ANIM_mciResume(dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2); case MCI_RESUME: return ANIM_mciResume(dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2);
case MCI_SEEK: return ANIM_mciSeek(dwDevID, dwParam1, (LPMCI_SEEK_PARMS)dwParam2); case MCI_SEEK: return ANIM_mciSeek(dwDevID, dwParam1, (LPMCI_SEEK_PARMS)dwParam2);
default: return DefDriverProc32(dwDevID, hDriv, wMsg, dwParam1, dwParam2); case MCI_LOAD:
case MCI_SAVE:
case MCI_FREEZE:
case MCI_PUT:
case MCI_REALIZE:
case MCI_UNFREEZE:
case MCI_UPDATE:
case MCI_WHERE:
case MCI_WINDOW:
case MCI_STEP:
case MCI_SPIN:
case MCI_ESCAPE:
case MCI_COPY:
case MCI_CUT:
case MCI_DELETE:
case MCI_PASTE:
WARN(mcianim, "Unsupported command=%s\n", MCI_CommandToString(wMsg));
break;
case MCI_OPEN:
case MCI_CLOSE:
FIXME(mcianim, "Shouldn't receive a MCI_OPEN or CLOSE message\n");
break;
default:
TRACE(mcianim, "Sending msg=%s to default driver proc\n", MCI_CommandToString(wMsg));
return DefDriverProc32(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
} }
return MCIERR_UNRECOGNIZED_COMMAND;
} }