Simplified memory allocation for asynchronous MCI message handling.
This commit is contained in:
parent
15a3d774b0
commit
2251fbc3c4
|
@ -81,7 +81,6 @@ struct SCA {
|
|||
UINT wMsg;
|
||||
DWORD dwParam1;
|
||||
DWORD dwParam2;
|
||||
BOOL allocatedCopy;
|
||||
};
|
||||
|
||||
/* EPP DWORD WINAPI mciSendCommandA(UINT wDevID, UINT wMsg, DWORD dwParam1, DWORD dwParam2); */
|
||||
|
@ -99,8 +98,6 @@ static DWORD CALLBACK MCI_SCAStarter(LPVOID arg)
|
|||
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");
|
||||
|
@ -114,7 +111,7 @@ static DWORD CALLBACK MCI_SCAStarter(LPVOID arg)
|
|||
static DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD dwParam1,
|
||||
DWORD dwParam2, UINT size)
|
||||
{
|
||||
struct SCA* sca = HeapAlloc(GetProcessHeap(), 0, sizeof(struct SCA));
|
||||
struct SCA* sca = HeapAlloc(GetProcessHeap(), 0, sizeof(struct SCA) + size);
|
||||
|
||||
if (sca == 0)
|
||||
return MCIERR_OUT_OF_MEMORY;
|
||||
|
@ -123,20 +120,14 @@ static DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD dwParam1,
|
|||
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;
|
||||
if (size && dwParam2) {
|
||||
sca->dwParam2 = (DWORD)sca + sizeof(struct SCA);
|
||||
/* 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) {
|
||||
|
@ -403,7 +394,7 @@ static DWORD MIDI_mciReadMTrk(WINE_MCIMIDI* wmm, MCI_MIDITRACK* mmt)
|
|||
}
|
||||
break;
|
||||
case 0x03:
|
||||
if (wmm->lpstrCopyright) {
|
||||
if (wmm->lpstrName) {
|
||||
WARN("Two names (%s|%s)\n", wmm->lpstrName, buf);
|
||||
} else {
|
||||
wmm->lpstrName = HeapAlloc( GetProcessHeap(), 0, strlen(buf)+1 );
|
||||
|
|
|
@ -53,7 +53,6 @@ struct SCA {
|
|||
UINT wMsg;
|
||||
DWORD dwParam1;
|
||||
DWORD dwParam2;
|
||||
BOOL allocatedCopy;
|
||||
};
|
||||
|
||||
/**************************************************************************
|
||||
|
@ -69,8 +68,6 @@ static DWORD CALLBACK MCI_SCAStarter(LPVOID arg)
|
|||
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");
|
||||
|
@ -84,7 +81,7 @@ static DWORD CALLBACK MCI_SCAStarter(LPVOID arg)
|
|||
static DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD dwParam1,
|
||||
DWORD dwParam2, UINT size)
|
||||
{
|
||||
struct SCA* sca = HeapAlloc(GetProcessHeap(), 0, sizeof(struct SCA));
|
||||
struct SCA* sca = HeapAlloc(GetProcessHeap(), 0, sizeof(struct SCA) + size);
|
||||
|
||||
if (sca == 0)
|
||||
return MCIERR_OUT_OF_MEMORY;
|
||||
|
@ -93,20 +90,14 @@ static DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD dwParam1,
|
|||
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;
|
||||
if (size && dwParam2) {
|
||||
sca->dwParam2 = (DWORD)sca + sizeof(struct SCA);
|
||||
/* 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) {
|
||||
|
|
Loading…
Reference in New Issue