Removed last dependancies between MCI drivers and WINMM/MMSYSTEM
DLLs.
diff --git a/include/mmddk.h b/include/mmddk.h
index 000a8b9..6af547a 100644
--- a/include/mmddk.h
+++ b/include/mmddk.h
@@ -353,14 +353,6 @@
BOOL WINAPI DriverCallback(DWORD dwCallBack, UINT uFlags, HANDLE hDev,
UINT wMsg, DWORD dwUser, DWORD dwParam1, DWORD dwParam2);
-/* FIXME: the Wine builtin MCI drivers still use those winmm internal functions
- * remove them ASAP
- */
-extern DWORD MCI_WriteString(LPSTR lpDstStr, DWORD dstSize, LPCSTR lpSrcStr);
-extern const char* MCI_MessageToString(UINT16 wMsg);
-extern DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD dwParam1, DWORD dwParam2, UINT size);
-
-
#include "poppack.h"
#endif /* __MMDDK_H */
diff --git a/multimedia/mci.c b/multimedia/mci.c
index 5ada221..861fdeb 100644
--- a/multimedia/mci.c
+++ b/multimedia/mci.c
@@ -2362,82 +2362,6 @@
return dwRet;
}
-/* 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
- */
-
-struct SCA {
- UINT wDevID;
- UINT wMsg;
- DWORD dwParam1;
- DWORD dwParam2;
- BOOL allocatedCopy;
-};
-
-DWORD WINAPI mciSendCommandA(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;
-
- TRACE("In thread before async command (%08x,%s,%08lx,%08lx)\n",
- sca->wDevID, MCI_MessageToString(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,%s,%08lx,%08lx)\n",
- sca->wDevID, MCI_MessageToString(sca->wMsg), sca->dwParam1, sca->dwParam2);
- if (sca->allocatedCopy)
- HeapFree(GetProcessHeap(), 0, (LPVOID)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]
- */
-DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD dwParam1,
- DWORD dwParam2, UINT size)
-{
- struct SCA* sca = HeapAlloc(GetProcessHeap(), 0, sizeof(struct SCA));
-
- if (sca == 0)
- return MCIERR_OUT_OF_MEMORY;
-
- sca->wDevID = wDevID;
- sca->wMsg = wMsg;
- sca->dwParam1 = dwParam1;
-
- if (size) {
- sca->dwParam2 = (DWORD)HeapAlloc(GetProcessHeap(), 0, size);
- if (sca->dwParam2 == 0) {
- HeapFree(GetProcessHeap(), 0, sca);
- return MCIERR_OUT_OF_MEMORY;
- }
- sca->allocatedCopy = TRUE;
- /* copy structure passed by program in dwParam2 to be sure
- * we can still use it whatever the program does
- */
- memcpy((LPVOID)sca->dwParam2, (LPVOID)dwParam2, size);
- } else {
- sca->dwParam2 = dwParam2;
- sca->allocatedCopy = FALSE;
- }
-
- if (CreateThread(NULL, 0, MCI_SCAStarter, sca, 0, NULL) == 0) {
- WARN("Couldn't allocate thread for async command handling, sending synchonously\n");
- return MCI_SCAStarter(&sca);
- }
- return 0;
-}
-
/**************************************************************************
* MCI_CleanUp [internal]
*
diff --git a/multimedia/mcianim.c b/multimedia/mcianim.c
index 703b233..a94e979 100644
--- a/multimedia/mcianim.c
+++ b/multimedia/mcianim.c
@@ -325,6 +325,7 @@
{
WINE_MCIANIM* wma = ANIM_mciGetOpenDrv(wDevID);
LPSTR str = 0;
+ DWORD ret = 0;
TRACE("(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
@@ -351,7 +352,17 @@
return MCIERR_UNRECOGNIZED_COMMAND;
}
- return MCI_WriteString(lpParms->lpstrReturn, lpParms->dwRetSize, str);
+ if (str) {
+ if (lpParms->dwRetSize <= strlen(str)) {
+ lstrcpynA(lpParms->lpstrReturn, str, lpParms->dwRetSize - 1);
+ ret = MCIERR_PARAM_OVERFLOW;
+ } else {
+ strcpy(lpParms->lpstrReturn, str);
+ }
+ } else {
+ *lpParms->lpstrReturn = 0;
+ }
+ return ret;
}
/**************************************************************************
@@ -661,14 +672,14 @@
case MCI_CUT:
case MCI_DELETE:
case MCI_PASTE:
- FIXME("Unsupported message=%s\n", MCI_MessageToString(wMsg));
+ FIXME("Unsupported message [%lu]\n", wMsg);
break;
case MCI_OPEN:
case MCI_CLOSE:
ERR("Shouldn't receive a MCI_OPEN or CLOSE message\n");
break;
default:
- TRACE("Sending msg=%s to default driver proc\n", MCI_MessageToString(wMsg));
+ TRACE("Sending msg [%lu] to default driver proc\n", wMsg);
return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
}
return MCIERR_UNRECOGNIZED_COMMAND;
diff --git a/multimedia/mciavi.c b/multimedia/mciavi.c
index a108d7c..6903a04 100644
--- a/multimedia/mciavi.c
+++ b/multimedia/mciavi.c
@@ -502,7 +502,8 @@
{
LPSTR str = 0;
WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
-
+ DWORD ret = 0;
+
TRACE("(%04X, %08lX, %p) : stub;\n", wDevID, dwFlags, lpParms);
if (lpParms == NULL || lpParms->lpstrReturn == NULL)
@@ -529,7 +530,17 @@
WARN("Don't know this info command (%lu)\n", dwFlags);
return MCIERR_UNRECOGNIZED_COMMAND;
}
- return MCI_WriteString(lpParms->lpstrReturn, lpParms->dwRetSize, str);
+ if (str) {
+ if (lpParms->dwRetSize <= strlen(str)) {
+ lstrcpynA(lpParms->lpstrReturn, str, lpParms->dwRetSize - 1);
+ ret = MCIERR_PARAM_OVERFLOW;
+ } else {
+ strcpy(lpParms->lpstrReturn, str);
+ }
+ } else {
+ *lpParms->lpstrReturn = 0;
+ }
+ return ret;
}
/***************************************************************************
@@ -1025,14 +1036,14 @@
case MCI_SPIN:
case MCI_ESCAPE:
- WARN("Unsupported command=%s\n", MCI_MessageToString(wMsg));
+ WARN("Unsupported command [%lu]\n", wMsg);
break;
case MCI_OPEN:
case MCI_CLOSE:
FIXME("Shouldn't receive a MCI_OPEN or CLOSE message\n");
break;
default:
- TRACE("Sending msg=%s to default driver proc\n", MCI_MessageToString(wMsg));
+ TRACE("Sending msg [%lu] to default driver proc\n", wMsg);
return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
}
return MCIERR_UNRECOGNIZED_COMMAND;
diff --git a/multimedia/mcicda.c b/multimedia/mcicda.c
index 6c9529c..60ce5cd 100644
--- a/multimedia/mcicda.c
+++ b/multimedia/mcicda.c
@@ -338,7 +338,8 @@
{
LPSTR str = 0;
WINE_MCICDAUDIO* wmcda = CDAUDIO_mciGetOpenDrv(wDevID);
-
+ DWORD ret = 0;
+
TRACE("(%04X, %08lX, %p);\n", wDevID, dwFlags, lpParms);
if (lpParms == NULL || lpParms->lpstrReturn == NULL)
@@ -355,7 +356,17 @@
WARN("Don't know this info command (%lu)\n", dwFlags);
return MCIERR_UNRECOGNIZED_COMMAND;
}
- return MCI_WriteString(lpParms->lpstrReturn, lpParms->dwRetSize, str);
+ if (str) {
+ if (lpParms->dwRetSize <= strlen(str)) {
+ lstrcpynA(lpParms->lpstrReturn, str, lpParms->dwRetSize - 1);
+ ret = MCIERR_PARAM_OVERFLOW;
+ } else {
+ strcpy(lpParms->lpstrReturn, str);
+ }
+ } else {
+ *lpParms->lpstrReturn = 0;
+ }
+ return ret;
}
/**************************************************************************
@@ -417,7 +428,7 @@
return CDAUDIO_mciGetError(wmcda);
lpParms->dwReturn = (wmcda->wcda.nTracks == 0) ?
MAKEMCIRESOURCE(FALSE, MCI_FALSE) : MAKEMCIRESOURCE(TRUE, MCI_TRUE);
- TRACE("MCI_STATUS_MEDIA_PRESENT =%s!\n", LOWORD(lpParms->dwReturn) ? "Y" : "N");
+ TRACE("MCI_STATUS_MEDIA_PRESENT =%c!\n", LOWORD(lpParms->dwReturn) ? 'Y' : 'N');
ret = MCI_RESOURCE_RETURNED;
break;
case MCI_STATUS_NUMBER_OF_TRACKS:
@@ -751,18 +762,18 @@
case MCI_CUT:
case MCI_DELETE:
case MCI_PASTE:
- FIXME("Unsupported yet command=%s\n", MCI_MessageToString(wMsg));
+ FIXME("Unsupported yet command [%lu]\n", wMsg);
break;
/* commands that should report an error */
case MCI_WINDOW:
- FIXME("Unsupported command=%s\n", MCI_MessageToString(wMsg));
+ FIXME("Unsupported command [%lu]\n", wMsg);
break;
case MCI_OPEN:
case MCI_CLOSE:
ERR("Shouldn't receive a MCI_OPEN or CLOSE message\n");
break;
default:
- TRACE("Sending msg=%s to default driver proc\n", MCI_MessageToString(wMsg));
+ TRACE("Sending msg [%lu] to default driver proc\n", wMsg);
return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
}
return MCIERR_UNRECOGNIZED_COMMAND;
diff --git a/multimedia/mcimidi.c b/multimedia/mcimidi.c
index 87f3726..ec0cf33 100644
--- a/multimedia/mcimidi.c
+++ b/multimedia/mcimidi.c
@@ -61,6 +61,85 @@
DWORD dwStartTicks;
} WINE_MCIMIDI;
+/* ===================================================================
+ * ===================================================================
+ * 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
+ * ===================================================================
+ * =================================================================== */
+
+struct SCA {
+ UINT wDevID;
+ UINT wMsg;
+ DWORD dwParam1;
+ DWORD dwParam2;
+ BOOL allocatedCopy;
+};
+
+/* EPP DWORD WINAPI mciSendCommandA(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;
+
+ 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);
+ if (sca->allocatedCopy)
+ HeapFree(GetProcessHeap(), 0, (LPVOID)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]
+ */
+static DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD dwParam1,
+ DWORD dwParam2, UINT size)
+{
+ struct SCA* sca = HeapAlloc(GetProcessHeap(), 0, sizeof(struct SCA));
+
+ if (sca == 0)
+ return MCIERR_OUT_OF_MEMORY;
+
+ sca->wDevID = wDevID;
+ sca->wMsg = wMsg;
+ sca->dwParam1 = dwParam1;
+
+ if (size) {
+ sca->dwParam2 = (DWORD)HeapAlloc(GetProcessHeap(), 0, size);
+ if (sca->dwParam2 == 0) {
+ HeapFree(GetProcessHeap(), 0, sca);
+ return MCIERR_OUT_OF_MEMORY;
+ }
+ sca->allocatedCopy = TRUE;
+ /* copy structure passed by program in dwParam2 to be sure
+ * we can still use it whatever the program does
+ */
+ memcpy((LPVOID)sca->dwParam2, (LPVOID)dwParam2, size);
+ } else {
+ sca->dwParam2 = dwParam2;
+ sca->allocatedCopy = FALSE;
+ }
+
+ if (CreateThread(NULL, 0, MCI_SCAStarter, sca, 0, NULL) == 0) {
+ WARN("Couldn't allocate thread for async command handling, sending synchonously\n");
+ return MCI_SCAStarter(&sca);
+ }
+ return 0;
+}
+
/*======================================================================*
* MCI MIDI implemantation *
*======================================================================*/
@@ -835,7 +914,7 @@
doPlay = (wmm->dwPositionMS >= dwStartMS && wmm->dwPositionMS <= dwEndMS);
- TRACE("wmm->dwStatus=%d, doPlay=%s\n", wmm->dwStatus, doPlay ? "T" : "F");
+ TRACE("wmm->dwStatus=%d, doPlay=%c\n", wmm->dwStatus, doPlay ? 'T' : 'F');
if ((mmt = MIDI_mciFindNextEvent(wmm, &hiPulse)) == NULL)
break; /* no more event on tracks */
@@ -1416,7 +1495,8 @@
{
LPCSTR str = 0;
WINE_MCIMIDI* wmm = MIDI_mciGetOpenDev(wDevID);
-
+ DWORD ret = 0;
+
TRACE("(%04X, %08lX, %p);\n", wDevID, dwFlags, lpParms);
if (lpParms == NULL || lpParms->lpstrReturn == NULL)
@@ -1443,7 +1523,17 @@
WARN("Don't know this info command (%lu)\n", dwFlags);
return MCIERR_UNRECOGNIZED_COMMAND;
}
- return MCI_WriteString(lpParms->lpstrReturn, lpParms->dwRetSize, str);
+ if (str) {
+ if (lpParms->dwRetSize <= strlen(str)) {
+ lstrcpynA(lpParms->lpstrReturn, str, lpParms->dwRetSize - 1);
+ ret = MCIERR_PARAM_OVERFLOW;
+ } else {
+ strcpy(lpParms->lpstrReturn, str);
+ }
+ } else {
+ *lpParms->lpstrReturn = 0;
+ }
+ return ret;
}
/**************************************************************************
@@ -1534,18 +1624,18 @@
case MCI_CUT:
case MCI_DELETE:
case MCI_PASTE:
- WARN("Unsupported command=%s\n", MCI_MessageToString(wMsg));
+ WARN("Unsupported command [%lu]\n", wMsg);
break;
/* commands that should report an error */
case MCI_WINDOW:
- TRACE("Unsupported command=%s\n", MCI_MessageToString(wMsg));
+ TRACE("Unsupported command [%lu]\n", wMsg);
break;
case MCI_OPEN:
case MCI_CLOSE:
FIXME("Shouldn't receive a MCI_OPEN or CLOSE message\n");
break;
default:
- TRACE("Sending msg=%s to default driver proc\n", MCI_MessageToString(wMsg));
+ TRACE("Sending msg [%lu] to default driver proc\n", wMsg);
return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
}
return MCIERR_UNRECOGNIZED_COMMAND;
diff --git a/multimedia/mciwave.c b/multimedia/mciwave.c
index bc2ee7d..0ce91fd 100644
--- a/multimedia/mciwave.c
+++ b/multimedia/mciwave.c
@@ -39,6 +39,85 @@
DWORD dwPosition; /* position in bytes in chunk for playing */
} WINE_MCIWAVE;
+/* ===================================================================
+ * ===================================================================
+ * 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
+ * ===================================================================
+ * =================================================================== */
+
+struct SCA {
+ UINT wDevID;
+ UINT wMsg;
+ DWORD dwParam1;
+ DWORD dwParam2;
+ BOOL allocatedCopy;
+};
+
+/* EPP DWORD WINAPI mciSendCommandA(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;
+
+ 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);
+ if (sca->allocatedCopy)
+ HeapFree(GetProcessHeap(), 0, (LPVOID)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]
+ */
+static DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD dwParam1,
+ DWORD dwParam2, UINT size)
+{
+ struct SCA* sca = HeapAlloc(GetProcessHeap(), 0, sizeof(struct SCA));
+
+ if (sca == 0)
+ return MCIERR_OUT_OF_MEMORY;
+
+ sca->wDevID = wDevID;
+ sca->wMsg = wMsg;
+ sca->dwParam1 = dwParam1;
+
+ if (size) {
+ sca->dwParam2 = (DWORD)HeapAlloc(GetProcessHeap(), 0, size);
+ if (sca->dwParam2 == 0) {
+ HeapFree(GetProcessHeap(), 0, sca);
+ return MCIERR_OUT_OF_MEMORY;
+ }
+ sca->allocatedCopy = TRUE;
+ /* copy structure passed by program in dwParam2 to be sure
+ * we can still use it whatever the program does
+ */
+ memcpy((LPVOID)sca->dwParam2, (LPVOID)dwParam2, size);
+ } else {
+ sca->dwParam2 = dwParam2;
+ sca->allocatedCopy = FALSE;
+ }
+
+ if (CreateThread(NULL, 0, MCI_SCAStarter, sca, 0, NULL) == 0) {
+ WARN("Couldn't allocate thread for async command handling, sending synchonously\n");
+ return MCI_SCAStarter(&sca);
+ }
+ return 0;
+}
+
/*======================================================================*
* MCI WAVE implemantation *
*======================================================================*/
@@ -1009,17 +1088,17 @@
case MCI_CUT:
case MCI_DELETE:
case MCI_PASTE:
- FIXME("Unsupported yet command=%s\n", MCI_MessageToString(wMsg));
+ FIXME("Unsupported yet command [%lu]\n", wMsg);
break;
case MCI_WINDOW:
- TRACE("Unsupported command=%s\n", MCI_MessageToString(wMsg));
+ TRACE("Unsupported command [%lu]\n", wMsg);
break;
case MCI_OPEN:
case MCI_CLOSE:
ERR("Shouldn't receive a MCI_OPEN or CLOSE message\n");
break;
default:
- FIXME("is probably wrong msg=%s\n", MCI_MessageToString(wMsg));
+ FIXME("is probably wrong msg [%lu]\n", wMsg);
return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
}
return MCIERR_UNRECOGNIZED_COMMAND;