Commit d7cc0025 authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

winmm: Restrict some MCI actions to the creating thread.

This reverts commit 46d59739 and fixes bug 38241 another way. Signed-off-by: 's avatarAndrew Eikum <aeikum@codeweavers.com> Signed-off-by: 's avatarAkihiro Sagawa <sagawa.aki@gmail.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 3d73f62f
......@@ -26,17 +26,6 @@
#include "dshow.h"
typedef struct {
HANDLE thread;
HANDLE notify;
HANDLE done;
DWORD msg;
DWORD_PTR devid;
DWORD flags;
DWORD_PTR parms;
LRESULT res;
} WINE_MCIQTZ_TASK;
typedef struct {
MCIDEVICEID wDevID;
BOOL opened;
BOOL uninit;
......@@ -54,8 +43,6 @@ typedef struct {
HANDLE callback;
HANDLE thread;
HANDLE stop_event;
CRITICAL_SECTION cs;
WINE_MCIQTZ_TASK task;
} WINE_MCIQTZ;
#endif /* __WINE_PRIVATE_MCIQTZ_H */
......@@ -891,6 +891,9 @@ static DWORD MCI_SendCommandFrom32(MCIDEVICEID wDevID, UINT16 wMsg, DWORD_PTR dw
LPWINE_MCIDRIVER wmd = MCI_GetDriver(wDevID);
if (wmd) {
if(wmd->CreatorThread != GetCurrentThreadId())
return MCIERR_INVALID_DEVICE_NAME;
dwRet = SendDriverMessage(wmd->hDriver, wMsg, dwParam1, dwParam2);
}
return dwRet;
......@@ -1872,6 +1875,9 @@ static DWORD MCI_Close(UINT wDevID, DWORD dwParam, LPMCI_GENERIC_PARMS lpParms)
return MCIERR_INVALID_DEVICE_ID;
}
if(wmd->CreatorThread != GetCurrentThreadId())
return MCIERR_INVALID_DEVICE_NAME;
dwRet = MCI_SendCommandFrom32(wDevID, MCI_CLOSE_DRIVER, dwParam, (DWORD_PTR)lpParms);
MCI_UnLoadMciDriver(wmd);
......
......@@ -1391,6 +1391,46 @@ static void test_asyncWaveTypeMpegvideo(HWND hwnd)
test_notification(hwnd,"play (aborted by close)",MCI_NOTIFY_ABORTED);
}
static DWORD CALLBACK thread_cb(void *p)
{
HANDLE evt = p;
MCIERROR mr;
mr = mciSendStringA("play x", NULL, 0, NULL);
ok(mr == MCIERR_INVALID_DEVICE_NAME, "play gave: 0x%x\n", mr);
mr = mciSendStringA("close x", NULL, 0, NULL);
ok(mr == MCIERR_INVALID_DEVICE_NAME, "close gave: 0x%x\n", mr);
SetEvent(evt);
return 0;
}
static void test_threads(void)
{
MCIERROR mr;
HANDLE evt;
mr = mciSendStringA("open tempfile.wav alias x", NULL, 0, NULL);
ok(mr == 0 || mr == ok_saved, "open gave: 0x%x\n", mr);
if(mr){
skip("Cannot open tempfile.wav for playing (%s), skipping\n", dbg_mcierr(mr));
return;
}
evt = CreateEventW( NULL, TRUE, FALSE, NULL );
CloseHandle(CreateThread(NULL, 0, &thread_cb, evt, 0, NULL));
WaitForSingleObject(evt, INFINITE);
CloseHandle(evt);
mr = mciSendStringA("close x", NULL, 0, NULL);
ok(mr == 0, "close gave: 0x%x\n", mr);
}
START_TEST(mci)
{
char curdir[MAX_PATH], tmpdir[MAX_PATH];
......@@ -1407,6 +1447,7 @@ START_TEST(mci)
test_openCloseWAVE(hwnd);
test_recordWAVE(hwnd);
if(waveOutGetNumDevs()){
test_threads();
test_playWAVE(hwnd);
test_asyncWAVE(hwnd);
test_AutoOpenWAVE(hwnd);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment