mcicda: Access the first CD-ROM unless given a device letter.

This commit is contained in:
Jörg Höhle 2010-08-23 09:55:22 +02:00 committed by Alexandre Julliard
parent 5bff616faa
commit ecb02ec9b7
2 changed files with 13 additions and 12 deletions

View File

@ -161,6 +161,7 @@ static DWORD MCICDA_drvOpen(LPCWSTR str, LPMCI_OPEN_DRIVER_PARMSW modp)
WINE_MCICDAUDIO* wmcda; WINE_MCICDAUDIO* wmcda;
if (!modp) return 0xFFFFFFFF; if (!modp) return 0xFFFFFFFF;
/* FIXME: MCIERR_CANNOT_LOAD_DRIVER if there's no drive of type CD-ROM */
wmcda = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINE_MCICDAUDIO)); wmcda = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINE_MCICDAUDIO));
@ -400,11 +401,10 @@ static DWORD MCICDA_Stop(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms
*/ */
static DWORD MCICDA_Open(UINT wDevID, DWORD dwFlags, LPMCI_OPEN_PARMSW lpOpenParms) static DWORD MCICDA_Open(UINT wDevID, DWORD dwFlags, LPMCI_OPEN_PARMSW lpOpenParms)
{ {
DWORD dwDeviceID; MCIDEVICEID dwDeviceID;
DWORD ret = MCIERR_HARDWARE; DWORD ret;
WINE_MCICDAUDIO* wmcda = (WINE_MCICDAUDIO*)mciGetDriverData(wDevID); WINE_MCICDAUDIO* wmcda = (WINE_MCICDAUDIO*)mciGetDriverData(wDevID);
WCHAR root[7], drive = 0; WCHAR root[7], drive = 0;
unsigned int count;
TRACE("(%04X, %08X, %p);\n", wDevID, dwFlags, lpOpenParms); TRACE("(%04X, %08X, %p);\n", wDevID, dwFlags, lpOpenParms);
@ -450,11 +450,10 @@ static DWORD MCICDA_Open(UINT wDevID, DWORD dwFlags, LPMCI_OPEN_PARMSW lpOpenPar
} }
else else
{ {
/* drive letter isn't passed... get the dwDeviceID'th cdrom in the system */
root[0] = 'A'; root[1] = ':'; root[2] = '\\'; root[3] = '\0'; root[0] = 'A'; root[1] = ':'; root[2] = '\\'; root[3] = '\0';
for (count = 0; root[0] <= 'Z'; root[0]++) for ( ; root[0] <= 'Z'; root[0]++)
{ {
if (GetDriveTypeW(root) == DRIVE_CDROM && ++count >= dwDeviceID) if (GetDriveTypeW(root) == DRIVE_CDROM)
{ {
drive = root[0]; drive = root[0];
break; break;
@ -462,7 +461,7 @@ static DWORD MCICDA_Open(UINT wDevID, DWORD dwFlags, LPMCI_OPEN_PARMSW lpOpenPar
} }
if (!drive) if (!drive)
{ {
ret = MCIERR_INVALID_DEVICE_ID; ret = MCIERR_CANNOT_LOAD_DRIVER; /* drvOpen should return this */
goto the_error; goto the_error;
} }
} }
@ -474,7 +473,10 @@ static DWORD MCICDA_Open(UINT wDevID, DWORD dwFlags, LPMCI_OPEN_PARMSW lpOpenPar
root[0] = root[1] = '\\'; root[2] = '.'; root[3] = '\\'; root[4] = drive; root[5] = ':'; root[6] = '\0'; root[0] = root[1] = '\\'; root[2] = '.'; root[3] = '\\'; root[4] = drive; root[5] = ':'; root[6] = '\0';
wmcda->handle = CreateFileW(root, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); wmcda->handle = CreateFileW(root, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
if (wmcda->handle == INVALID_HANDLE_VALUE) if (wmcda->handle == INVALID_HANDLE_VALUE)
{
ret = MCIERR_MUST_USE_SHAREABLE;
goto the_error; goto the_error;
}
if (dwFlags & MCI_NOTIFY) { if (dwFlags & MCI_NOTIFY) {
mciDriverNotify(HWND_32(LOWORD(lpOpenParms->dwCallback)), mciDriverNotify(HWND_32(LOWORD(lpOpenParms->dwCallback)),

View File

@ -166,13 +166,12 @@ static void test_play(HWND hwnd)
parm.gen.dwCallback = (DWORD_PTR)hwnd; /* once to rule them all */ parm.gen.dwCallback = (DWORD_PTR)hwnd; /* once to rule them all */
err = mciSendString("open cdaudio alias c notify shareable", buf, sizeof(buf), hwnd); err = mciSendString("open cdaudio alias c notify shareable", buf, sizeof(buf), hwnd);
if (err == MCIERR_INVALID_DEVICE_ID) /* Wine special */ todo_wine ok(!err || err == MCIERR_CANNOT_LOAD_DRIVER || err == MCIERR_MUST_USE_SHAREABLE,
ok(!err, "open cdaudio must succeed even without CD-ROM drive\n"); else
ok(!err || broken(err == MCIERR_MUST_USE_SHAREABLE),
"mci open cdaudio notify returned %s\n", dbg_mcierr(err)); "mci open cdaudio notify returned %s\n", dbg_mcierr(err));
test_notification(hwnd, "open alias notify", err ? 0 : MCI_NOTIFY_SUCCESSFUL); test_notification(hwnd, "open alias notify", err ? 0 : MCI_NOTIFY_SUCCESSFUL);
/* Some machines return MUST_USE_SHAREABLE when there's trouble with the hardware /* Native returns MUST_USE_SHAREABLE when there's trouble with the hardware
* (e.g. unreadable disk), yet adding that flag does not help get past this error. */ * (e.g. unreadable disk) or when Media Player already has the device open,
* yet adding that flag does not help get past this error. */
if(err) { if(err) {
skip("Cannot open any cdaudio device, %s.\n", dbg_mcierr(err)); skip("Cannot open any cdaudio device, %s.\n", dbg_mcierr(err));