Changeset 10410 for trunk/src/winmm/mci.cpp
- Timestamp:
- Jan 20, 2004, 7:09:44 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/winmm/mci.cpp
r10173 r10410 1 /* $Id: mci.cpp,v 1. 9 2003-07-16 15:47:23sandervl Exp $ */1 /* $Id: mci.cpp,v 1.10 2004-01-20 18:09:42 sandervl Exp $ */ 2 2 3 3 /* … … 7 7 * Copyright 1998/1999 Eric Pouech 8 8 * Copyright 2000 Chris Wohlgemuth 9 * 10 * Contains portions of Wine (dlls\winmm\mci.c, winmm.c) 11 * Copyright 1998/1999 Eric Pouech 9 12 * 10 13 * Project Odin Software License can be found in LICENSE.TXT … … 46 49 UINT16 uMsg, 47 50 DWORD dwParam1, 48 DWORD dwParam2); 51 DWORD dwParam2); 49 52 50 53 static LPWINE_MCIDRIVER MCI_GetDriver(UINT16 wDevID) ; … … 244 247 245 248 246 MCIERROR WINAPI mciSendCommandW(MCIDEVICEID mciId, UINT uMsg, DWORD dwParam1, 247 DWORD dwParam2) 248 { 249 dprintf(("WINMM:mciSendCommandW - stub %X %X %X %X\n", mciId, uMsg, dwParam1, dwParam2)); 250 return(MMSYSERR_NODRIVER); 251 } 249 /************************************************************************** 250 * MCI_MessageToString [internal] 251 */ 252 const char* MCI_MessageToString(UINT16 wMsg) 253 { 254 static char buffer[100]; 255 256 #define CASE(s) case (s): return #s 257 258 switch (wMsg) { 259 CASE(MCI_BREAK); 260 CASE(MCI_CLOSE); 261 CASE(MCI_CLOSE_DRIVER); 262 CASE(MCI_COPY); 263 CASE(MCI_CUE); 264 CASE(MCI_CUT); 265 CASE(MCI_DELETE); 266 CASE(MCI_ESCAPE); 267 CASE(MCI_FREEZE); 268 CASE(MCI_PAUSE); 269 CASE(MCI_PLAY); 270 CASE(MCI_GETDEVCAPS); 271 CASE(MCI_INFO); 272 CASE(MCI_LOAD); 273 CASE(MCI_OPEN); 274 CASE(MCI_OPEN_DRIVER); 275 CASE(MCI_PASTE); 276 CASE(MCI_PUT); 277 CASE(MCI_REALIZE); 278 CASE(MCI_RECORD); 279 CASE(MCI_RESUME); 280 CASE(MCI_SAVE); 281 CASE(MCI_SEEK); 282 CASE(MCI_SET); 283 CASE(MCI_SPIN); 284 CASE(MCI_STATUS); 285 CASE(MCI_STEP); 286 CASE(MCI_STOP); 287 CASE(MCI_SYSINFO); 288 CASE(MCI_UNFREEZE); 289 CASE(MCI_UPDATE); 290 CASE(MCI_WHERE); 291 CASE(MCI_WINDOW); 292 /* constants for digital video */ 293 /* 294 CASE(MCI_CAPTURE); 295 CASE(MCI_MONITOR); 296 CASE(MCI_RESERVE); 297 CASE(MCI_SETAUDIO); 298 CASE(MCI_SIGNAL); 299 CASE(MCI_SETVIDEO); 300 CASE(MCI_QUALITY); 301 CASE(MCI_LIST); 302 CASE(MCI_UNDO); 303 CASE(MCI_CONFIGURE); 304 CASE(MCI_RESTORE); 305 */ 306 #undef CASE 307 default: 308 sprintf(buffer, "MCI_<<%04X>>", wMsg); 309 return buffer; 310 } 311 } 312 313 inline static LPSTR strdupWtoA( LPCWSTR str ) 314 { 315 LPSTR ret; 316 INT len; 317 318 if (!str) return NULL; 319 len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL ); 320 ret = (LPSTR)HeapAlloc( GetProcessHeap(), 0, len ); 321 if(ret) WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL ); 322 return ret; 323 } 324 325 static int MCI_MapMsgWtoA(UINT msg, DWORD dwParam1, DWORD *dwParam2) 326 { 327 switch(msg) 328 { 329 case MCI_CLOSE: 330 case MCI_PLAY: 331 case MCI_SEEK: 332 case MCI_STOP: 333 case MCI_PAUSE: 334 case MCI_GETDEVCAPS: 335 case MCI_SPIN: 336 case MCI_SET: 337 case MCI_STEP: 338 case MCI_RECORD: 339 case MCI_BREAK: 340 case MCI_SOUND: 341 case MCI_STATUS: 342 case MCI_CUE: 343 case MCI_REALIZE: 344 case MCI_PUT: 345 case MCI_WHERE: 346 case MCI_FREEZE: 347 case MCI_UNFREEZE: 348 case MCI_CUT: 349 case MCI_COPY: 350 case MCI_PASTE: 351 case MCI_UPDATE: 352 case MCI_RESUME: 353 case MCI_DELETE: 354 return 0; 355 356 case MCI_OPEN: 357 { 358 MCI_OPEN_PARMSW *mci_openW = (MCI_OPEN_PARMSW *)*dwParam2; 359 MCI_OPEN_PARMSA *mci_openA; 360 DWORD *ptr; 361 362 ptr = (DWORD *)HeapAlloc(GetProcessHeap(), 0, sizeof(*mci_openA) + sizeof(DWORD)); 363 if (!ptr) return -1; 364 365 *ptr++ = *dwParam2; /* save the previous pointer */ 366 *dwParam2 = (DWORD)ptr; 367 mci_openA = (MCI_OPEN_PARMSA *)ptr; 368 369 if (dwParam1 & MCI_NOTIFY) 370 mci_openA->dwCallback = mci_openW->dwCallback; 371 372 if (dwParam1 & MCI_OPEN_TYPE) 373 { 374 if (dwParam1 & MCI_OPEN_TYPE_ID) 375 mci_openA->lpstrDeviceType = (LPSTR)mci_openW->lpstrDeviceType; 376 else 377 mci_openA->lpstrDeviceType = strdupWtoA(mci_openW->lpstrDeviceType); 378 } 379 if (dwParam1 & MCI_OPEN_ELEMENT) 380 { 381 if (dwParam1 & MCI_OPEN_ELEMENT_ID) 382 mci_openA->lpstrElementName = (LPSTR)mci_openW->lpstrElementName; 383 else 384 mci_openA->lpstrElementName = strdupWtoA(mci_openW->lpstrElementName); 385 } 386 if (dwParam1 & MCI_OPEN_ALIAS) 387 mci_openA->lpstrAlias = strdupWtoA(mci_openW->lpstrAlias); 388 } 389 return 1; 390 391 case MCI_WINDOW: 392 if (dwParam1 & MCI_ANIM_WINDOW_TEXT) 393 { 394 MCI_ANIM_WINDOW_PARMSW *mci_windowW = (MCI_ANIM_WINDOW_PARMSW *)*dwParam2; 395 MCI_ANIM_WINDOW_PARMSA *mci_windowA; 396 397 mci_windowA = (MCI_ANIM_WINDOW_PARMSA *)HeapAlloc(GetProcessHeap(), 0, sizeof(*mci_windowA)); 398 if (!mci_windowA) return -1; 399 400 *dwParam2 = (DWORD)mci_windowA; 401 402 mci_windowA->lpstrText = strdupWtoA(mci_windowW->lpstrText); 403 404 if (dwParam1 & MCI_NOTIFY) 405 mci_windowA->dwCallback = mci_windowW->dwCallback; 406 if (dwParam1 & MCI_ANIM_WINDOW_HWND) 407 mci_windowA->hWnd = mci_windowW->hWnd; 408 if (dwParam1 & MCI_ANIM_WINDOW_STATE) 409 mci_windowA->nCmdShow = mci_windowW->nCmdShow; 410 411 return 1; 412 } 413 return 0; 414 415 case MCI_SYSINFO: 416 { 417 MCI_SYSINFO_PARMSW *mci_sysinfoW = (MCI_SYSINFO_PARMSW *)*dwParam2; 418 MCI_SYSINFO_PARMSA *mci_sysinfoA; 419 DWORD *ptr; 420 421 ptr = (DWORD *)HeapAlloc(GetProcessHeap(), 0, sizeof(*mci_sysinfoA) + sizeof(DWORD)); 422 if (!ptr) return -1; 423 424 *ptr++ = *dwParam2; /* save the previous pointer */ 425 *dwParam2 = (DWORD)ptr; 426 mci_sysinfoA = (MCI_SYSINFO_PARMSA *)ptr; 427 428 if (dwParam1 & MCI_NOTIFY) 429 mci_sysinfoA->dwCallback = mci_sysinfoW->dwCallback; 430 431 mci_sysinfoA->dwRetSize = mci_sysinfoW->dwRetSize; /* FIXME */ 432 mci_sysinfoA->lpstrReturn = (CHAR *)HeapAlloc(GetProcessHeap(), 0, mci_sysinfoA->dwRetSize); 433 434 return 1; 435 } 436 437 case MCI_INFO: 438 case MCI_SAVE: 439 case MCI_LOAD: 440 case MCI_ESCAPE: 441 default: 442 FIXME("Message 0x%04x needs translation\n", msg); 443 return -1; 444 } 445 return 0; 446 } 447 448 static DWORD MCI_UnmapMsgWtoA(UINT msg, DWORD dwParam1, DWORD dwParam2, 449 DWORD result) 450 { 451 switch(msg) 452 { 453 case MCI_OPEN: 454 { 455 DWORD *ptr = (DWORD *)dwParam2 - 1; 456 MCI_OPEN_PARMSW *mci_openW = (MCI_OPEN_PARMSW *)*ptr; 457 MCI_OPEN_PARMSA *mci_openA = (MCI_OPEN_PARMSA *)(ptr + 1); 458 459 mci_openW->wDeviceID = mci_openA->wDeviceID; 460 461 if (dwParam1 & MCI_OPEN_TYPE) 462 { 463 if (!(dwParam1 & MCI_OPEN_TYPE_ID)) 464 HeapFree(GetProcessHeap(), 0, (LPVOID)mci_openA->lpstrDeviceType); 465 } 466 if (dwParam1 & MCI_OPEN_ELEMENT) 467 { 468 if (!(dwParam1 & MCI_OPEN_ELEMENT_ID)) 469 HeapFree(GetProcessHeap(), 0, (LPVOID)mci_openA->lpstrElementName); 470 } 471 if (dwParam1 & MCI_OPEN_ALIAS) 472 HeapFree(GetProcessHeap(), 0, (LPVOID)mci_openA->lpstrAlias); 473 HeapFree(GetProcessHeap(), 0, ptr); 474 } 475 break; 476 477 case MCI_WINDOW: 478 if (dwParam1 & MCI_ANIM_WINDOW_TEXT) 479 { 480 MCI_ANIM_WINDOW_PARMSA *mci_windowA = (MCI_ANIM_WINDOW_PARMSA *)dwParam2; 481 482 HeapFree(GetProcessHeap(), 0, (void *)mci_windowA->lpstrText); 483 HeapFree(GetProcessHeap(), 0, mci_windowA); 484 } 485 break; 486 487 case MCI_SYSINFO: 488 { 489 DWORD *ptr = (DWORD *)dwParam2 - 1; 490 MCI_SYSINFO_PARMSW *mci_sysinfoW = (MCI_SYSINFO_PARMSW *)*ptr; 491 MCI_SYSINFO_PARMSA *mci_sysinfoA = (MCI_SYSINFO_PARMSA *)(ptr + 1); 492 493 if (!result) 494 { 495 mci_sysinfoW->dwNumber = mci_sysinfoA->dwNumber; 496 mci_sysinfoW->wDeviceType = mci_sysinfoA->wDeviceType; 497 MultiByteToWideChar(CP_ACP, 0, 498 mci_sysinfoA->lpstrReturn, mci_sysinfoA->dwRetSize, 499 mci_sysinfoW->lpstrReturn, mci_sysinfoW->dwRetSize); 500 } 501 502 HeapFree(GetProcessHeap(), 0, mci_sysinfoA->lpstrReturn); 503 HeapFree(GetProcessHeap(), 0, ptr); 504 } 505 break; 506 507 default: 508 FIXME("Message 0x%04x needs unmapping\n", msg); 509 break; 510 } 511 512 return result; 513 } 514 515 516 /************************************************************************** 517 * mciSendCommandW [WINMM.@] 518 * 519 * FIXME: we should do the things other way around, but since our 520 * MM subsystem is not unicode aware... 521 */ 522 DWORD WINAPI mciSendCommandW(MCIDEVICEID wDevID, UINT wMsg, DWORD dwParam1, DWORD dwParam2) 523 { 524 DWORD ret; 525 int mapped; 526 527 dprintf(("(%08x, %s, %08lx, %08lx)\n", wDevID, MCI_MessageToString(wMsg), dwParam1, dwParam2)); 528 529 mapped = MCI_MapMsgWtoA(wMsg, dwParam1, &dwParam2); 530 if (mapped == -1) 531 { 532 dprintf(("message %04x mapping failed\n", wMsg)); 533 return MMSYSERR_NOMEM; 534 } 535 ret = mciSendCommandA(wDevID, wMsg, dwParam1, dwParam2); 536 if (mapped) 537 MCI_UnmapMsgWtoA(wMsg, dwParam1, dwParam2, ret); 538 return ret; 539 } 540 252 541 253 542 MCIERROR WINAPI mciSendStringA(LPCSTR lpstrCommand, LPSTR lpstrReturnString, … … 770 1059 MCI_GetDevTypeFromFileName(lpParms->lpstrElementName, 771 1060 strDevTyp, sizeof(strDevTyp))) { 772 if (GetDriveTypeA(lpParms->lpstrElementName) != DRIVE_CDROM) { 1061 if (GetDriveTypeA(lpParms->lpstrElementName) == DRIVE_CDROM) { 1062 /* FIXME: this will not work if several CDROM drives are installed on the machine */ 1063 strcpy(strDevTyp, "CDAUDIO"); 1064 } 1065 else 1066 if (GetFileAttributesA(lpParms->lpstrElementName) != INVALID_FILE_ATTRIBUTES) { 1067 // TODO: Assuming wave file here 1068 strcpy(strDevTyp, "WAVEAUDIO"); 1069 } 1070 else { 773 1071 dwRet = MCIERR_EXTENSION_NOT_FOUND; 774 1072 goto errCleanUp; 775 1073 } 776 /* FIXME: this will not work if several CDROM drives are installed on the machine */777 strcpy(strDevTyp, "CDAUDIO");778 1074 } 779 1075 } … … 1071 1367 FIXME("Registry handling for mci drivers not changed for odin yet. Verbatim copy from WINE (line %d)",__LINE__); 1072 1368 } 1073 #endif1074 1369 FIXME("No Registry querying for mci drivers yet! (line %d)",__LINE__); 1075 1370 err=1; … … 1094 1389 } 1095 1390 //RegCloseKey(hWineConf); 1391 #else 1392 //Just used hardcoded names here 1393 strcpy(MCI_lpInstallNames, "CDAUDIO=MCICDA"); 1394 strcpy(MCI_lpInstallNames+strlen(MCI_lpInstallNames)+1, "WAVEAUDIO=MCIWAVE"); 1395 MCI_InstalledCount = 2; 1396 #endif 1096 1397 return TRUE; 1097 1398 }
Note:
See TracChangeset
for help on using the changeset viewer.