1 | /* $Id: mci.cpp,v 1.7 2001-04-04 09:02:16 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * MCI functions
|
---|
5 | *
|
---|
6 | * Copyright 1998 Joel Troster
|
---|
7 | * Copyright 1998/1999 Eric Pouech
|
---|
8 | * Copyright 2000 Chris Wohlgemuth
|
---|
9 | *
|
---|
10 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
11 | *
|
---|
12 | */
|
---|
13 |
|
---|
14 |
|
---|
15 | /****************************************************************************
|
---|
16 | * Includes *
|
---|
17 | ****************************************************************************/
|
---|
18 |
|
---|
19 | #define INCL_BASE
|
---|
20 | #define INCL_OS2MM
|
---|
21 |
|
---|
22 | #include <os2win.h>
|
---|
23 | #include <mmsystem.h>
|
---|
24 | #include <odinwrap.h>
|
---|
25 | #include <string.h>
|
---|
26 | #include <stdio.h>
|
---|
27 | #include "debugtools.h"
|
---|
28 |
|
---|
29 | #include <misc.h>
|
---|
30 | #include <unicode.h>
|
---|
31 |
|
---|
32 | #include "mcimm.h"
|
---|
33 |
|
---|
34 | #include "winmm.h"
|
---|
35 |
|
---|
36 | #define DBG_LOCALLOG DBG_mci
|
---|
37 |
|
---|
38 | #include "dbglocal.h"
|
---|
39 |
|
---|
40 |
|
---|
41 | /****************************************************************************
|
---|
42 | * Local functions *
|
---|
43 | ****************************************************************************/
|
---|
44 |
|
---|
45 | /* forward declaration */
|
---|
46 | static DWORD MCI_SendCommand(UINT mciId,
|
---|
47 | UINT16 uMsg,
|
---|
48 | DWORD dwParam1,
|
---|
49 | DWORD dwParam2);
|
---|
50 |
|
---|
51 | static LPWINE_MCIDRIVER MCI_GetDriver(UINT16 wDevID) ;
|
---|
52 | static UINT MCI_GetDriverFromString(LPCSTR lpstrName);
|
---|
53 |
|
---|
54 | /****************************************************************************/
|
---|
55 |
|
---|
56 | ODINDEBUGCHANNEL(WINMM-MCI)
|
---|
57 |
|
---|
58 |
|
---|
59 | ODINFUNCTION3(BOOL, mciDriverNotify,
|
---|
60 | HWND, hwndCallback,
|
---|
61 | UINT, uDeviceID,
|
---|
62 | UINT, uStatus)
|
---|
63 | {
|
---|
64 | TRACE("Entering mciDriverNotify (%08X, %04x, %04X)\n", hwndCallback, uDeviceID, uStatus);
|
---|
65 |
|
---|
66 | if (!IsWindow(hwndCallback)) {
|
---|
67 | WARN("bad hwnd for call back (0x%04x)\n", hwndCallback);
|
---|
68 | return FALSE;
|
---|
69 | }
|
---|
70 | TRACE("before PostMessage\n");
|
---|
71 | PostMessageA(hwndCallback, MM_MCINOTIFY, uStatus, uDeviceID);
|
---|
72 | return TRUE;
|
---|
73 | }
|
---|
74 |
|
---|
75 | ODINFUNCTION1(UINT, mciDriverYield,
|
---|
76 | UINT, uDeviceID)
|
---|
77 | {
|
---|
78 | dprintf(("WINMM:mciDriverYield - stub\n"));
|
---|
79 | return 0;
|
---|
80 | }
|
---|
81 |
|
---|
82 | ODINFUNCTION1(BOOL, mciExecute,
|
---|
83 | LPCSTR, pszCommand)
|
---|
84 | {
|
---|
85 | dprintf(("WINMM:mciExecute(%s) - stub\n", pszCommand));
|
---|
86 | return FALSE;
|
---|
87 | }
|
---|
88 |
|
---|
89 | ODINFUNCTION1(BOOL, mciFreeCommandResource,
|
---|
90 | UINT, uTable)
|
---|
91 | {
|
---|
92 | dprintf(("WINMM:mciFreeCommandResource - stub\n"));
|
---|
93 | return FALSE;
|
---|
94 | }
|
---|
95 |
|
---|
96 | ODINFUNCTION1(HTASK, mciGetCreatorTask,
|
---|
97 | MCIDEVICEID, mciId)
|
---|
98 | {
|
---|
99 | dprintf(("WINMM:mciGetCreatorTask - stub\n"));
|
---|
100 | return 0;
|
---|
101 | }
|
---|
102 |
|
---|
103 | ODINFUNCTION1(MCIDEVICEID, mciGetDeviceIDA,
|
---|
104 | LPCSTR, pszDevice)
|
---|
105 | {
|
---|
106 | WARN(("WINMM:mciGetDeviceIDA - untested\n"));
|
---|
107 | return MCI_GetDriverFromString(pszDevice);
|
---|
108 | }
|
---|
109 |
|
---|
110 | ODINFUNCTION1(MCIDEVICEID, mciGetDeviceIDW,
|
---|
111 | LPCWSTR, pszDevice)
|
---|
112 | {
|
---|
113 | dprintf(("WINMM:mciGetDeviceIDW - stub\n"));
|
---|
114 | return 0;
|
---|
115 | }
|
---|
116 |
|
---|
117 | ODINFUNCTION2(MCIDEVICEID, mciGetDeviceIDFromElementIDA,
|
---|
118 | DWORD, dwElementID,
|
---|
119 | LPCSTR, lpstrType)
|
---|
120 | {
|
---|
121 | dprintf(("WINMM:mciGetDeviceIDFromElementIDA - stub\n"));
|
---|
122 | return 0;
|
---|
123 | }
|
---|
124 |
|
---|
125 | ODINFUNCTION2(MCIDEVICEID, mciGetDeviceIDFromElementIDW,
|
---|
126 | DWORD, dwElementID,
|
---|
127 | LPCWSTR, lpstrType)
|
---|
128 | {
|
---|
129 | dprintf(("WINMM:mciGetDeviceIDFromElementIDW - stub\n"));
|
---|
130 | return 0;
|
---|
131 | }
|
---|
132 |
|
---|
133 | /*****************************************************************************
|
---|
134 | * Queries driver data
|
---|
135 | * Parameters: UINT uDeviceID
|
---|
136 | * Variables :
|
---|
137 | * @return : Pointer to driver data (as a DWORD)
|
---|
138 | * Remark :
|
---|
139 | * @status : Completely
|
---|
140 | *
|
---|
141 | * @author : Chris Wohlgemuth [Sun, 2000/11/19]
|
---|
142 | *****************************************************************************/
|
---|
143 | ODINFUNCTION1(DWORD, mciGetDriverData,
|
---|
144 | UINT, uDeviceID)
|
---|
145 | {
|
---|
146 | LPWINE_MCIDRIVER wmd;
|
---|
147 |
|
---|
148 | wmd = MCI_GetDriver(uDeviceID);
|
---|
149 |
|
---|
150 | if (!wmd) {
|
---|
151 | dprintf(("WARNING: Bad uDeviceID (mciGetDriverData (mci.cpp line %d)\n",__LINE__));
|
---|
152 | return 0L; /* Error */
|
---|
153 | }
|
---|
154 |
|
---|
155 | return wmd->dwPrivate;
|
---|
156 | }
|
---|
157 |
|
---|
158 | /*****************************************************************************
|
---|
159 | * Converts an error to an error string
|
---|
160 | * Parameters: MCIERROR mcierr,
|
---|
161 | * LPSTR pszText,
|
---|
162 | * UINT cchText
|
---|
163 | * Variables :
|
---|
164 | * @return : API returncode (TRUE/FALSE)
|
---|
165 | * Remark :
|
---|
166 | * @status : Completely
|
---|
167 | *
|
---|
168 | * @author : Wine
|
---|
169 | *****************************************************************************/
|
---|
170 | ODINFUNCTION3(BOOL, mciGetErrorStringA,
|
---|
171 | MCIERROR, mcierr,
|
---|
172 | LPSTR, pszText,
|
---|
173 | UINT, cchText)
|
---|
174 | {
|
---|
175 | dprintf(("WINMM:mciGetErrorStringA(%d)\n", mcierr ));
|
---|
176 | char * theMsg = getWinmmMsg( mcierr );
|
---|
177 | if ( theMsg )
|
---|
178 | strncpy( pszText, theMsg, cchText );
|
---|
179 | else
|
---|
180 | {
|
---|
181 | char errMsg[100];
|
---|
182 | sprintf( errMsg, "Unknown error number %d", mcierr );
|
---|
183 | strncpy( pszText, errMsg, cchText );
|
---|
184 | }
|
---|
185 | return TRUE;
|
---|
186 | }
|
---|
187 |
|
---|
188 | /*****************************************************************************
|
---|
189 | * Converts an error to an error string
|
---|
190 | * Parameters: MCIERROR mcierr,
|
---|
191 | * LPSTR pszText,
|
---|
192 | * UINT cchText
|
---|
193 | * Variables :
|
---|
194 | * @return : API returncode (TRUE/FALSE)
|
---|
195 | * Remark :
|
---|
196 | * @status : Completely
|
---|
197 | *
|
---|
198 | * @author : Wine
|
---|
199 | *****************************************************************************/
|
---|
200 | ODINFUNCTION3(BOOL, mciGetErrorStringW,
|
---|
201 | MCIERROR, mcierr,
|
---|
202 | LPWSTR, pszText,
|
---|
203 | UINT, cchText)
|
---|
204 | {
|
---|
205 | dprintf(("WINMM:mciGetErrorStringW(%d)\n", mcierr ));
|
---|
206 | char * theMsg = getWinmmMsg( mcierr );
|
---|
207 | if ( theMsg )
|
---|
208 | AsciiToUnicode( theMsg, pszText );
|
---|
209 | else
|
---|
210 | {
|
---|
211 | char errMsg[100];
|
---|
212 | sprintf( errMsg, "Unknown error number %d", mcierr );
|
---|
213 | AsciiToUnicode( errMsg, pszText );
|
---|
214 | }
|
---|
215 | return TRUE;
|
---|
216 | }
|
---|
217 |
|
---|
218 | /*****************************************************************************
|
---|
219 | * Converts an error to an error string
|
---|
220 | * Parameters: MCIERROR mcierr,
|
---|
221 | * LPSTR pszText,
|
---|
222 | * UINT cchText
|
---|
223 | * Variables :
|
---|
224 | * @return : API returncode
|
---|
225 | * Remark :
|
---|
226 | * @status : Completely
|
---|
227 | *
|
---|
228 | * @author : Wine
|
---|
229 | *****************************************************************************/
|
---|
230 | ODINFUNCTION2(YIELDPROC, mciGetYieldProc,
|
---|
231 | MCIDEVICEID, mciId,
|
---|
232 | LPDWORD, pdwYieldData)
|
---|
233 | {
|
---|
234 | LPWINE_MCIDRIVER wmd;
|
---|
235 |
|
---|
236 | TRACE("Entering mciGetYieldProc (%u, %p) - untested\n", mciId, pdwYieldData);
|
---|
237 |
|
---|
238 | if (!(wmd = MCI_GetDriver(mciId))) {
|
---|
239 | WARN("Bad uDeviceID\n");
|
---|
240 | return NULL;
|
---|
241 | }
|
---|
242 | if (!wmd->lpfnYieldProc) {
|
---|
243 | WARN("No proc set\n");
|
---|
244 | return NULL;
|
---|
245 | }
|
---|
246 | if (!wmd->bIs32) {
|
---|
247 | WARN("Proc is 32 bit\n");
|
---|
248 | return NULL;
|
---|
249 | }
|
---|
250 | return wmd->lpfnYieldProc;
|
---|
251 | }
|
---|
252 |
|
---|
253 | ODINFUNCTION3(UINT, mciLoadCommandResource,
|
---|
254 | HINSTANCE, hInstance,
|
---|
255 | LPCWSTR, lpResName,
|
---|
256 | UINT, uType)
|
---|
257 | {
|
---|
258 | dprintf(("WINMM:mciLoadCOmmandResource - stub\n"));
|
---|
259 | return 0;
|
---|
260 | }
|
---|
261 |
|
---|
262 |
|
---|
263 | ODINFUNCTION4(MCIERROR, mciSendCommandA,
|
---|
264 | MCIDEVICEID, mciId,
|
---|
265 | UINT, uMsg,
|
---|
266 | DWORD, dwParam1,
|
---|
267 | DWORD, dwParam2)
|
---|
268 | {
|
---|
269 | DWORD dwRet;
|
---|
270 | // dprintf(("WINMM:mciSendCommandA - entering %X %X %X %X\n", mciId, uMsg, dwParam1, dwParam2));
|
---|
271 | dwRet= MCI_SendCommand((UINT) mciId, uMsg, dwParam1, dwParam2) & 0xFFFF;
|
---|
272 | return(dwRet);
|
---|
273 | }
|
---|
274 |
|
---|
275 |
|
---|
276 | ODINFUNCTION4(MCIERROR, mciSendCommandW,
|
---|
277 | MCIDEVICEID, mciId,
|
---|
278 | UINT, uMsg,
|
---|
279 | DWORD, dwParam1,
|
---|
280 | DWORD, dwParam2)
|
---|
281 | {
|
---|
282 | dprintf(("WINMM:mciSendCommandW - stub %X %X %X %X\n", mciId, uMsg, dwParam1, dwParam2));
|
---|
283 | return(MMSYSERR_NODRIVER);
|
---|
284 | }
|
---|
285 |
|
---|
286 | ODINFUNCTION4(MCIERROR, mciSendStringA,
|
---|
287 | LPCSTR, lpstrCommand,
|
---|
288 | LPSTR, lpstrReturnString,
|
---|
289 | UINT, uReturnLength,
|
---|
290 | HWND, hwndCallback)
|
---|
291 | {
|
---|
292 | dprintf(("WINMM:mciSendStringA - stub\n"));
|
---|
293 | if(lpstrCommand)
|
---|
294 | dprintf(("WINMM:mciSendStringA command: %s\n",lpstrCommand));
|
---|
295 | return(MMSYSERR_NODRIVER);
|
---|
296 | }
|
---|
297 |
|
---|
298 | ODINFUNCTION4(MCIERROR, mciSendStringW,
|
---|
299 | LPCWSTR, lpstrCommand,
|
---|
300 | LPWSTR, lpstrReturnString,
|
---|
301 | UINT, uReturnLength,
|
---|
302 | HWND, hwndCallback)
|
---|
303 | {
|
---|
304 | dprintf(("WINMM:mciSendStringW - stub\n"));
|
---|
305 | return(MMSYSERR_NODRIVER);
|
---|
306 | }
|
---|
307 |
|
---|
308 | ODINFUNCTION2(BOOL, mciSetDriverData,
|
---|
309 | UINT, uDeviceID,
|
---|
310 | DWORD, dwData)
|
---|
311 | {
|
---|
312 | LPWINE_MCIDRIVER wmd;
|
---|
313 |
|
---|
314 | wmd = MCI_GetDriver(uDeviceID);
|
---|
315 |
|
---|
316 | if (!wmd) {
|
---|
317 | dprintf(("WARNING: Bad uDeviceID (mciSetDriverData line %d)\n",__LINE__));
|
---|
318 | return FALSE;
|
---|
319 | }
|
---|
320 |
|
---|
321 | wmd->dwPrivate = dwData;
|
---|
322 | return TRUE;
|
---|
323 | }
|
---|
324 |
|
---|
325 |
|
---|
326 | ODINFUNCTION3(BOOL, mciSetYieldProc,
|
---|
327 | MCIDEVICEID, mciId,
|
---|
328 | YIELDPROC, fpYieldProc,
|
---|
329 | DWORD, dwYieldData)
|
---|
330 | {
|
---|
331 | LPWINE_MCIDRIVER wmd;
|
---|
332 |
|
---|
333 | TRACE("WINMM:mciSetYieldProc (%u, %p, %08lx) - untested\n", mciId, fpYieldProc, dwYieldData);
|
---|
334 |
|
---|
335 | if (!(wmd = MCI_GetDriver(mciId))) {
|
---|
336 | WARN("Bad uDeviceID\n");
|
---|
337 | return FALSE;
|
---|
338 | }
|
---|
339 |
|
---|
340 | wmd->lpfnYieldProc = fpYieldProc;
|
---|
341 | wmd->dwYieldData = dwYieldData;
|
---|
342 | wmd->bIs32 = TRUE;
|
---|
343 |
|
---|
344 | return TRUE;
|
---|
345 | }
|
---|
346 |
|
---|
347 |
|
---|
348 | /**************************************************************************/
|
---|
349 | /* heap.c */
|
---|
350 | /**************************************************************************/
|
---|
351 |
|
---|
352 | #ifdef __GNUC__
|
---|
353 | #define GET_EIP() (__builtin_return_address(0))
|
---|
354 | #define SET_EIP(ptr) ((ARENA_INUSE*)(ptr) - 1)->callerEIP = GET_EIP()
|
---|
355 | #else
|
---|
356 | #define GET_EIP() 0
|
---|
357 | #define SET_EIP(ptr) /* nothing */
|
---|
358 | #endif /* __GNUC__ */
|
---|
359 |
|
---|
360 |
|
---|
361 | /**************************************************************************/
|
---|
362 | /* mmmsystem.c */
|
---|
363 | /**************************************************************************/
|
---|
364 |
|
---|
365 | static LPWINE_MM_IDATA lpFirstIData = NULL;
|
---|
366 |
|
---|
367 | static LPWINE_MM_IDATA MULTIMEDIA_GetIDataNoCheck(void)
|
---|
368 | {
|
---|
369 | DWORD pid = GetCurrentProcessId();
|
---|
370 | LPWINE_MM_IDATA iData;
|
---|
371 |
|
---|
372 | for (iData = lpFirstIData; iData; iData = iData->lpNextIData) {
|
---|
373 | if (iData->dwThisProcess == pid)
|
---|
374 | break;
|
---|
375 | }
|
---|
376 | return iData;
|
---|
377 | }
|
---|
378 |
|
---|
379 | /**************************************************************************
|
---|
380 | * MULTIMEDIA_GetIData [internal]
|
---|
381 | */
|
---|
382 | LPWINE_MM_IDATA MULTIMEDIA_GetIData(void)
|
---|
383 | {
|
---|
384 | LPWINE_MM_IDATA iData = MULTIMEDIA_GetIDataNoCheck();
|
---|
385 |
|
---|
386 | if (!iData) {
|
---|
387 | dprintf(("MULTIMEDIA_GetIData: IData not found for pid=%08lx. Suicide !!!\n", GetCurrentProcessId()));
|
---|
388 | ExitProcess(0);
|
---|
389 | }
|
---|
390 | return iData;
|
---|
391 | }
|
---|
392 |
|
---|
393 |
|
---|
394 | /**************************************************************************
|
---|
395 | * MULTIMEDIA_CreateIData [internal]
|
---|
396 | */
|
---|
397 | BOOL MULTIMEDIA_CreateIData(HINSTANCE hInstDLL)
|
---|
398 | {
|
---|
399 | LPWINE_MM_IDATA iData;
|
---|
400 |
|
---|
401 | iData = (LPWINE_MM_IDATA) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINE_MM_IDATA));
|
---|
402 |
|
---|
403 | if (!iData)
|
---|
404 | return FALSE;
|
---|
405 | iData->hWinMM32Instance = hInstDLL;
|
---|
406 | iData->dwThisProcess = GetCurrentProcessId();
|
---|
407 | iData->lpNextIData = lpFirstIData;
|
---|
408 | lpFirstIData = iData;
|
---|
409 | InitializeCriticalSection(&iData->cs);
|
---|
410 | dprintf(("Created IData (%p) for pid %08lx\n", iData, iData->dwThisProcess));
|
---|
411 | return TRUE;
|
---|
412 | }
|
---|
413 |
|
---|
414 |
|
---|
415 | /**************************************************************************
|
---|
416 | * MULTIMEDIA_DeleteIData [internal]
|
---|
417 | */
|
---|
418 | void MULTIMEDIA_DeleteIData(void)
|
---|
419 | {
|
---|
420 | LPWINE_MM_IDATA iData = MULTIMEDIA_GetIDataNoCheck();
|
---|
421 | LPWINE_MM_IDATA* ppid;
|
---|
422 |
|
---|
423 | if (iData) {
|
---|
424 | for (ppid = &lpFirstIData; *ppid; ppid = &(*ppid)->lpNextIData) {
|
---|
425 | if (*ppid == iData) {
|
---|
426 | *ppid = iData->lpNextIData;
|
---|
427 | break;
|
---|
428 | }
|
---|
429 | }
|
---|
430 | /* FIXME: should also free content and resources allocated
|
---|
431 | * inside iData */
|
---|
432 | HeapFree(GetProcessHeap(), 0, iData);
|
---|
433 | }
|
---|
434 | }
|
---|
435 |
|
---|
436 |
|
---|
437 | /**************************************************************************/
|
---|
438 | /* mmmsystem.c */
|
---|
439 | /**************************************************************************/
|
---|
440 |
|
---|
441 |
|
---|
442 | static int MCI_InstalledCount;
|
---|
443 | static LPSTR MCI_lpInstallNames = NULL;
|
---|
444 |
|
---|
445 |
|
---|
446 | /* First MCI valid device ID (0 means error) */
|
---|
447 | #define MCI_MAGIC 0x0001
|
---|
448 |
|
---|
449 |
|
---|
450 | /**************************************************************************
|
---|
451 | * MCI_GetDriver [internal]
|
---|
452 | */
|
---|
453 | static LPWINE_MCIDRIVER MCI_GetDriver(UINT16 wDevID)
|
---|
454 | {
|
---|
455 | LPWINE_MCIDRIVER wmd = 0;
|
---|
456 | LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
|
---|
457 |
|
---|
458 | EnterCriticalSection(&iData->cs);
|
---|
459 | for (wmd = iData->lpMciDrvs; wmd; wmd = wmd->lpNext) {
|
---|
460 | if (wmd->wDeviceID == wDevID)
|
---|
461 | break;
|
---|
462 | }
|
---|
463 | LeaveCriticalSection(&iData->cs);
|
---|
464 | return wmd;
|
---|
465 | }
|
---|
466 |
|
---|
467 | /**************************************************************************
|
---|
468 | * MCI_GetDriverFromString [internal]
|
---|
469 | */
|
---|
470 | static UINT MCI_GetDriverFromString(LPCSTR lpstrName)
|
---|
471 | {
|
---|
472 | LPWINE_MCIDRIVER wmd;
|
---|
473 | LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
|
---|
474 | UINT ret = 0;
|
---|
475 |
|
---|
476 | if (!lpstrName)
|
---|
477 | return 0;
|
---|
478 |
|
---|
479 | if (!lstrcmpiA(lpstrName, "ALL"))
|
---|
480 | return MCI_ALL_DEVICE_ID;
|
---|
481 |
|
---|
482 | EnterCriticalSection(&iData->cs);
|
---|
483 | for (wmd = iData->lpMciDrvs; wmd; wmd = wmd->lpNext) {
|
---|
484 | if (wmd->lpstrElementName && strcmp(wmd->lpstrElementName, lpstrName) == 0) {
|
---|
485 | ret = wmd->wDeviceID;
|
---|
486 | break;
|
---|
487 | }
|
---|
488 |
|
---|
489 | if (wmd->lpstrDeviceType && strcmp(wmd->lpstrDeviceType, lpstrName) == 0) {
|
---|
490 | ret = wmd->wDeviceID;
|
---|
491 | break;
|
---|
492 | }
|
---|
493 |
|
---|
494 | if (wmd->lpstrAlias && strcmp(wmd->lpstrAlias, lpstrName) == 0) {
|
---|
495 | ret = wmd->wDeviceID;
|
---|
496 | break;
|
---|
497 | }
|
---|
498 | }
|
---|
499 | LeaveCriticalSection(&iData->cs);
|
---|
500 |
|
---|
501 | return ret;
|
---|
502 | }
|
---|
503 |
|
---|
504 |
|
---|
505 | /**************************************************************************
|
---|
506 | * MCI_GetDevTypeFromFileName [internal]
|
---|
507 | */
|
---|
508 | static DWORD MCI_GetDevTypeFromFileName(LPCSTR fileName, LPSTR buf, UINT len)
|
---|
509 | {
|
---|
510 | LPSTR tmp;
|
---|
511 |
|
---|
512 | if ((tmp = strrchr(fileName, '.'))) {
|
---|
513 | GetProfileStringA("mci extensions", tmp + 1, "*", buf, len);
|
---|
514 | if (strcmp(buf, "*") != 0) {
|
---|
515 | return 0;
|
---|
516 | }
|
---|
517 | dprintf(("No [mci extensions] entry for '%s' found. MCI_GetDevTypeFromFileName: line %d, file 'mci.cpp'\n", tmp, __LINE__));
|
---|
518 | }
|
---|
519 | return MCIERR_EXTENSION_NOT_FOUND;
|
---|
520 | }
|
---|
521 |
|
---|
522 |
|
---|
523 | #define MAX_MCICMDTABLE 20
|
---|
524 | #define MCI_COMMAND_TABLE_NOT_LOADED 0xFFFE
|
---|
525 |
|
---|
526 |
|
---|
527 |
|
---|
528 | /**************************************************************************
|
---|
529 | * MCI_DefYieldProc [internal]
|
---|
530 | */
|
---|
531 | //UINT WINAPI MCI_DefYieldProc(MCIDEVICEID wDevID, DWORD data)
|
---|
532 |
|
---|
533 | UINT16 WINAPI MCI_DefYieldProc(UINT16 wDevID, DWORD data)
|
---|
534 | {
|
---|
535 | INT16 ret;
|
---|
536 |
|
---|
537 | #if 0
|
---|
538 | dprintf(("(0x%04x, 0x%08lx)\n", wDevID, data));
|
---|
539 | #endif
|
---|
540 | if ((HIWORD(data) != 0 && GetActiveWindow() != HIWORD(data)) ||
|
---|
541 | (GetAsyncKeyState(LOWORD(data)) & 1) == 0) {
|
---|
542 | /* WINE stuff removed: UserYield16();*/
|
---|
543 | ret = 0;
|
---|
544 | } else {
|
---|
545 | MSG msg;
|
---|
546 |
|
---|
547 | msg.hwnd = HIWORD(data);
|
---|
548 | while (!PeekMessageA(&msg, HIWORD(data), WM_KEYFIRST, WM_KEYLAST, PM_REMOVE));
|
---|
549 | ret = -1;
|
---|
550 | }
|
---|
551 | return ret;
|
---|
552 | }
|
---|
553 |
|
---|
554 |
|
---|
555 | /**************************************************************************
|
---|
556 | * MCI_UnLoadMciDriver [internal]
|
---|
557 | */
|
---|
558 | static BOOL MCI_UnLoadMciDriver(LPWINE_MM_IDATA iData, LPWINE_MCIDRIVER wmd)
|
---|
559 | {
|
---|
560 | LPWINE_MCIDRIVER* tmp;
|
---|
561 |
|
---|
562 | #if 0
|
---|
563 | dprintf(("Entering MCI_UnLoadMciDriver...\n"));
|
---|
564 | #endif
|
---|
565 | if (!wmd)
|
---|
566 | return TRUE;
|
---|
567 |
|
---|
568 | if (wmd->hDrv)
|
---|
569 | CloseDriver(wmd->hDrv, 0, 0);
|
---|
570 |
|
---|
571 | if (wmd->dwPrivate != 0)
|
---|
572 | dprintf(("Unloading mci driver with non nul dwPrivate field\n"));
|
---|
573 |
|
---|
574 | EnterCriticalSection(&iData->cs);
|
---|
575 | for (tmp = &iData->lpMciDrvs; *tmp; tmp = &(*tmp)->lpNext) {
|
---|
576 | if (*tmp == wmd) {
|
---|
577 | *tmp = wmd->lpNext;
|
---|
578 | break;
|
---|
579 | }
|
---|
580 | }
|
---|
581 | LeaveCriticalSection(&iData->cs);
|
---|
582 |
|
---|
583 | HeapFree(GetProcessHeap(), 0, wmd->lpstrDeviceType);
|
---|
584 | HeapFree(GetProcessHeap(), 0, wmd->lpstrAlias);
|
---|
585 | HeapFree(GetProcessHeap(), 0, wmd->lpstrElementName);
|
---|
586 |
|
---|
587 | HeapFree(GetProcessHeap(), 0, wmd);
|
---|
588 | //dprintf(("Leaving MCI_UnLoadMciDriver...\n"));
|
---|
589 | return TRUE;
|
---|
590 | }
|
---|
591 |
|
---|
592 | /**************************************************************************
|
---|
593 | * MCI_LoadMciDriver [internal]
|
---|
594 | */
|
---|
595 | static DWORD MCI_LoadMciDriver(LPWINE_MM_IDATA iData, LPCSTR _strDevTyp,
|
---|
596 | LPWINE_MCIDRIVER* lpwmd)
|
---|
597 | {
|
---|
598 | LPSTR strDevTyp = CharUpperA(HEAP_strdupA(GetProcessHeap(), 0, _strDevTyp));
|
---|
599 | LPWINE_MCIDRIVER wmd = (LPWINE_MCIDRIVER)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wmd));
|
---|
600 | MCI_OPEN_DRIVER_PARMSA modp;
|
---|
601 | DWORD dwRet = 0;
|
---|
602 | HDRVR hDrv = 0;
|
---|
603 |
|
---|
604 |
|
---|
605 | dprintf(("Entering MCI_LoadMciDriver...\n"));
|
---|
606 |
|
---|
607 | if (!wmd || !strDevTyp) {
|
---|
608 | dwRet = MCIERR_OUT_OF_MEMORY;
|
---|
609 | goto errCleanUp;
|
---|
610 | }
|
---|
611 |
|
---|
612 | wmd->lpstrDeviceType = strDevTyp;
|
---|
613 | wmd->lpfnYieldProc = MCI_DefYieldProc;
|
---|
614 | wmd->dwYieldData = VK_CANCEL;
|
---|
615 | wmd->hCreatorTask = NULL;
|
---|
616 |
|
---|
617 |
|
---|
618 | EnterCriticalSection(&iData->cs);
|
---|
619 | /* wmd must be inserted in list before sending opening the driver, coz' it
|
---|
620 | * may want to lookup at wDevID
|
---|
621 | */
|
---|
622 | wmd->lpNext = iData->lpMciDrvs;
|
---|
623 | iData->lpMciDrvs = wmd;
|
---|
624 |
|
---|
625 | for (modp.wDeviceID = MCI_MAGIC;
|
---|
626 | MCI_GetDriver(modp.wDeviceID) != 0;
|
---|
627 | modp.wDeviceID++);
|
---|
628 |
|
---|
629 | wmd->wDeviceID = modp.wDeviceID;
|
---|
630 |
|
---|
631 | LeaveCriticalSection(&iData->cs);
|
---|
632 |
|
---|
633 | dprintf(("wDevID=%04X strDevTyp: %s\n", modp.wDeviceID, strDevTyp));
|
---|
634 |
|
---|
635 | modp.lpstrParams = NULL;
|
---|
636 |
|
---|
637 | hDrv = OpenDriverA(strDevTyp, "mci", (LPARAM)&modp);
|
---|
638 |
|
---|
639 | if (!hDrv) {
|
---|
640 | dprintf(("Couldn't load driver for type %s.\n"
|
---|
641 | "If you don't have a windows installation accessible from Wine,\n"
|
---|
642 | "you perhaps forgot to create a [mci] section in system.ini\n",
|
---|
643 | strDevTyp));
|
---|
644 | dwRet = MCIERR_DEVICE_NOT_INSTALLED;
|
---|
645 | goto errCleanUp;
|
---|
646 | }
|
---|
647 |
|
---|
648 | /* FIXME: should also check that module's description is of the form
|
---|
649 | * MODULENAME:[MCI] comment
|
---|
650 | */
|
---|
651 |
|
---|
652 | wmd->hDrv = hDrv;
|
---|
653 | /* some drivers will return 0x0000FFFF, some others 0xFFFFFFFF */
|
---|
654 | wmd->uSpecificCmdTable = LOWORD(modp.wCustomCommandTable);
|
---|
655 | wmd->uTypeCmdTable = MCI_COMMAND_TABLE_NOT_LOADED;
|
---|
656 |
|
---|
657 | dprintf(("Loaded driver %x (%s), type is %d, cmdTable=%08x\n",
|
---|
658 | hDrv, strDevTyp, modp.wType, modp.wCustomCommandTable));
|
---|
659 |
|
---|
660 |
|
---|
661 | wmd->wType = modp.wType;
|
---|
662 |
|
---|
663 | #if 0
|
---|
664 | dprintf(("mcidev=%d, uDevTyp=%04X wDeviceID=%04X !\n",
|
---|
665 | modp.wDeviceID, modp.wType, modp.wDeviceID));
|
---|
666 | #endif
|
---|
667 |
|
---|
668 | *lpwmd = wmd;
|
---|
669 | #if 0
|
---|
670 | dprintf(("Leaving MCI_LoadMciDriver succesful...\n"));
|
---|
671 | #endif
|
---|
672 | return 0;
|
---|
673 | errCleanUp:
|
---|
674 | MCI_UnLoadMciDriver(iData, wmd);
|
---|
675 | // HeapFree(GetProcessHeap(), 0, strDevTyp);<-- done in MCI_UnloadMciDriver
|
---|
676 | *lpwmd = 0;
|
---|
677 | dprintf(("Leaving MCI_LoadMciDriver on error...\n"));
|
---|
678 | return dwRet;
|
---|
679 | }
|
---|
680 |
|
---|
681 |
|
---|
682 | /**************************************************************************
|
---|
683 | * MCI_SendCommandFrom32 [internal]
|
---|
684 | */
|
---|
685 | static DWORD MCI_SendCommandFrom32(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2)
|
---|
686 | {
|
---|
687 | DWORD dwRet = MCIERR_DEVICE_NOT_INSTALLED;
|
---|
688 | LPWINE_MCIDRIVER wmd = MCI_GetDriver(wDevID);
|
---|
689 |
|
---|
690 | if (!wmd) {
|
---|
691 | dwRet = MCIERR_INVALID_DEVICE_ID;
|
---|
692 | } else {
|
---|
693 | switch (GetDriverFlags(wmd->hDrv) & (WINE_GDF_EXIST)) {
|
---|
694 | case WINE_GDF_EXIST:
|
---|
695 | dwRet = SendDriverMessage(wmd->hDrv, wMsg, dwParam1, dwParam2);
|
---|
696 | break;
|
---|
697 | default:
|
---|
698 | dprintf(("Unknown driver %u\n", wmd->hDrv));
|
---|
699 | dwRet = MCIERR_DRIVER_INTERNAL;
|
---|
700 | }
|
---|
701 | }
|
---|
702 | return dwRet;
|
---|
703 | }
|
---|
704 |
|
---|
705 | /**************************************************************************
|
---|
706 | * MCI_FinishOpen [internal]
|
---|
707 | */
|
---|
708 | static DWORD MCI_FinishOpen(LPWINE_MCIDRIVER wmd, LPMCI_OPEN_PARMSA lpParms,
|
---|
709 | DWORD dwParam)
|
---|
710 | {
|
---|
711 | if (dwParam & MCI_OPEN_ELEMENT)
|
---|
712 | wmd->lpstrElementName = HEAP_strdupA(GetProcessHeap(), 0,
|
---|
713 | lpParms->lpstrElementName);
|
---|
714 |
|
---|
715 | if (dwParam & MCI_OPEN_ALIAS)
|
---|
716 | wmd->lpstrAlias = HEAP_strdupA(GetProcessHeap(), 0, lpParms->lpstrAlias);
|
---|
717 |
|
---|
718 | lpParms->wDeviceID = wmd->wDeviceID;
|
---|
719 |
|
---|
720 | return MCI_SendCommandFrom32(wmd->wDeviceID, MCI_OPEN_DRIVER, dwParam,
|
---|
721 | (DWORD)lpParms);
|
---|
722 | }
|
---|
723 |
|
---|
724 | /**************************************************************************
|
---|
725 | * MCI_Open [internal]
|
---|
726 | */
|
---|
727 | static DWORD MCI_Open(DWORD dwParam, LPMCI_OPEN_PARMSA lpParms)
|
---|
728 | {
|
---|
729 | char strDevTyp[128];
|
---|
730 | DWORD dwRet;
|
---|
731 | LPWINE_MCIDRIVER wmd = NULL;
|
---|
732 |
|
---|
733 | LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
|
---|
734 |
|
---|
735 | dprintf(("Entering MCI_OPEN...\n"));
|
---|
736 |
|
---|
737 | if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
|
---|
738 |
|
---|
739 | /* only two low bytes are generic, the other ones are dev type specific */
|
---|
740 | #define WINE_MCIDRIVER_SUPP (0xFFFF0000|MCI_OPEN_SHAREABLE|MCI_OPEN_ELEMENT| \
|
---|
741 | MCI_OPEN_ALIAS|MCI_OPEN_TYPE|MCI_OPEN_TYPE_ID| \
|
---|
742 | MCI_NOTIFY|MCI_WAIT)
|
---|
743 | if ((dwParam & ~WINE_MCIDRIVER_SUPP) != 0) {
|
---|
744 | dprintf(("Unsupported yet dwFlags=%08lX\n", dwParam & ~WINE_MCIDRIVER_SUPP));
|
---|
745 | }
|
---|
746 | #undef WINE_MCIDRIVER_SUPP
|
---|
747 |
|
---|
748 | strDevTyp[0] = 0;
|
---|
749 |
|
---|
750 | if (dwParam & MCI_OPEN_TYPE) {
|
---|
751 | if (dwParam & MCI_OPEN_TYPE_ID) {
|
---|
752 | WORD uDevType = LOWORD((DWORD)lpParms->lpstrDeviceType);
|
---|
753 | if (uDevType < MCI_DEVTYPE_FIRST ||
|
---|
754 | uDevType > MCI_DEVTYPE_LAST ||
|
---|
755 | !LoadStringA(iData->hWinMM32Instance, uDevType, strDevTyp, sizeof(strDevTyp))) /* This gets a name for the device e.g 'cdaudio' */
|
---|
756 | {
|
---|
757 | dwRet = MCIERR_BAD_INTEGER;
|
---|
758 | goto errCleanUp;
|
---|
759 | }
|
---|
760 | } else {
|
---|
761 | LPSTR ptr;
|
---|
762 | if (lpParms->lpstrDeviceType == NULL) {
|
---|
763 | dwRet = MCIERR_NULL_PARAMETER_BLOCK;
|
---|
764 | goto errCleanUp;
|
---|
765 | }
|
---|
766 | strcpy(strDevTyp, lpParms->lpstrDeviceType);
|
---|
767 | ptr = strchr(strDevTyp, '!');
|
---|
768 | if (ptr) {
|
---|
769 | /* this behavior is not documented in windows. However, since, in
|
---|
770 | * some occasions, MCI_OPEN handling is translated by WinMM into
|
---|
771 | * a call to mciSendString("open <type>"); this code shall be correct
|
---|
772 | */
|
---|
773 | if (dwParam & MCI_OPEN_ELEMENT) {
|
---|
774 | dprintf(("Both MCI_OPEN_ELEMENT(%s) and %s are used\n",
|
---|
775 | lpParms->lpstrElementName, strDevTyp));
|
---|
776 | dwRet = MCIERR_UNRECOGNIZED_KEYWORD;
|
---|
777 | goto errCleanUp;
|
---|
778 | }
|
---|
779 | dwParam |= MCI_OPEN_ELEMENT;
|
---|
780 | *ptr++ = 0;
|
---|
781 | /* FIXME: not a good idea to write in user supplied buffer */
|
---|
782 | lpParms->lpstrElementName = ptr;
|
---|
783 | }
|
---|
784 |
|
---|
785 | }
|
---|
786 | dprintf(("MCI_OPEN (MCI_OPEN_TYPE): devType='%s' !\n", strDevTyp));
|
---|
787 | }
|
---|
788 |
|
---|
789 | if (dwParam & MCI_OPEN_ELEMENT) {
|
---|
790 | dprintf(("lpstrElementName='%s'\n", lpParms->lpstrElementName));
|
---|
791 |
|
---|
792 | if (dwParam & MCI_OPEN_ELEMENT_ID) {
|
---|
793 | dprintf(("Unsupported yet flag MCI_OPEN_ELEMENT_ID\n"));
|
---|
794 | dwRet = MCIERR_UNRECOGNIZED_KEYWORD;
|
---|
795 | goto errCleanUp;
|
---|
796 | }
|
---|
797 |
|
---|
798 | if (!lpParms->lpstrElementName) {
|
---|
799 | dwRet = MCIERR_NULL_PARAMETER_BLOCK;
|
---|
800 | goto errCleanUp;
|
---|
801 | }
|
---|
802 |
|
---|
803 | #if 0
|
---|
804 | /* Only working on my machine!! CW */
|
---|
805 | if(lpParms->lpstrElementName[0]=='N') {
|
---|
806 | dprintf(("Discarding drive N:\n"));
|
---|
807 | dwRet = MCIERR_UNRECOGNIZED_KEYWORD;
|
---|
808 | goto errCleanUp;
|
---|
809 | }
|
---|
810 | #endif
|
---|
811 |
|
---|
812 | /* type, if given as a parameter, supersedes file extension */
|
---|
813 | if (!strDevTyp[0] &&
|
---|
814 | MCI_GetDevTypeFromFileName(lpParms->lpstrElementName,
|
---|
815 | strDevTyp, sizeof(strDevTyp))) {
|
---|
816 | if (GetDriveTypeA(lpParms->lpstrElementName) != DRIVE_CDROM) {
|
---|
817 | dwRet = MCIERR_EXTENSION_NOT_FOUND;
|
---|
818 | goto errCleanUp;
|
---|
819 | }
|
---|
820 | /* FIXME: this will not work if several CDROM drives are installed on the machine */
|
---|
821 | strcpy(strDevTyp, "CDAUDIO");
|
---|
822 | }
|
---|
823 | }
|
---|
824 |
|
---|
825 | if (strDevTyp[0] == 0) {
|
---|
826 | dprintf(("Couldn't load driver (MCI_Open line %d)\n",__LINE__));
|
---|
827 | dwRet = MCIERR_INVALID_DEVICE_NAME;
|
---|
828 | goto errCleanUp;
|
---|
829 | }
|
---|
830 |
|
---|
831 | if (dwParam & MCI_OPEN_ALIAS) {
|
---|
832 | dprintf(("MCI_OPEN_ALIAS requested\n"));
|
---|
833 | if (!lpParms->lpstrAlias) {
|
---|
834 | dwRet = MCIERR_NULL_PARAMETER_BLOCK;
|
---|
835 | goto errCleanUp;
|
---|
836 | }
|
---|
837 | dprintf(("Alias='%s' !\n", lpParms->lpstrAlias));
|
---|
838 | }
|
---|
839 |
|
---|
840 | if ((dwRet = MCI_LoadMciDriver(iData, strDevTyp, &wmd))) {
|
---|
841 | goto errCleanUp;
|
---|
842 | }
|
---|
843 |
|
---|
844 |
|
---|
845 | if ((dwRet = MCI_FinishOpen(wmd, lpParms, dwParam))) {
|
---|
846 | dprintf(("Failed to open driver (MCI_OPEN_DRIVER) [%08lx], closing\n", dwRet));
|
---|
847 | /* FIXME: is dwRet the correct ret code ? */
|
---|
848 | goto errCleanUp;
|
---|
849 | }
|
---|
850 |
|
---|
851 |
|
---|
852 | /* only handled devices fall through */
|
---|
853 | dprintf(("wDevID=%04X wDeviceID=%d dwRet=%ld\n", wmd->wDeviceID, lpParms->wDeviceID, dwRet));
|
---|
854 |
|
---|
855 | if (dwParam & MCI_NOTIFY)
|
---|
856 | // mciDriverNotify16(lpParms->dwCallback, wmd->wDeviceID, MCI_NOTIFY_SUCCESSFUL);
|
---|
857 | dprintf(("FIXME: MCI_NOTIFY not implemented yet! MCI_Open (line %d)\n",__LINE__));
|
---|
858 |
|
---|
859 | return 0;
|
---|
860 |
|
---|
861 | errCleanUp:
|
---|
862 |
|
---|
863 | if (wmd) MCI_UnLoadMciDriver(iData, wmd);
|
---|
864 |
|
---|
865 | if (dwParam & MCI_NOTIFY)
|
---|
866 | // mciDriverNotify16(lpParms->dwCallback, 0, MCI_NOTIFY_FAILURE);
|
---|
867 | dprintf(("FIXME: MCI_NOTIFY not implemented yet! MCI_Open (line %d)\n",__LINE__));
|
---|
868 |
|
---|
869 | dprintf(("Leaving MCI_Open on error...\n"));
|
---|
870 | return dwRet;
|
---|
871 | }
|
---|
872 |
|
---|
873 |
|
---|
874 | /**************************************************************************
|
---|
875 | * MCI_Close [internal]
|
---|
876 | */
|
---|
877 | static DWORD MCI_Close(UINT16 wDevID, DWORD dwParam, LPMCI_GENERIC_PARMS lpParms)
|
---|
878 | {
|
---|
879 | DWORD dwRet;
|
---|
880 | LPWINE_MCIDRIVER wmd;
|
---|
881 | LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
|
---|
882 |
|
---|
883 | //dprintf(("(%04x, %08lX, %p)\n", wDevID, dwParam, lpParms));
|
---|
884 |
|
---|
885 | if (wDevID == MCI_ALL_DEVICE_ID) {
|
---|
886 | LPWINE_MCIDRIVER next;
|
---|
887 |
|
---|
888 | EnterCriticalSection(&iData->cs);
|
---|
889 | /* FIXME: shall I notify once after all is done, or for
|
---|
890 | * each of the open drivers ? if the latest, which notif
|
---|
891 | * to return when only one fails ?
|
---|
892 | */
|
---|
893 | for (wmd = iData->lpMciDrvs; wmd; ) {
|
---|
894 | next = wmd->lpNext;
|
---|
895 | MCI_Close(wmd->wDeviceID, dwParam, lpParms);
|
---|
896 | wmd = next;
|
---|
897 | }
|
---|
898 | LeaveCriticalSection(&iData->cs);
|
---|
899 | return 0;
|
---|
900 | }
|
---|
901 |
|
---|
902 | if (!(wmd = MCI_GetDriver(wDevID))) {
|
---|
903 | return MCIERR_INVALID_DEVICE_ID;
|
---|
904 | }
|
---|
905 |
|
---|
906 | dwRet = MCI_SendCommandFrom32(wDevID, MCI_CLOSE_DRIVER, dwParam, (DWORD)lpParms);
|
---|
907 |
|
---|
908 | MCI_UnLoadMciDriver(iData, wmd);
|
---|
909 |
|
---|
910 | if (dwParam & MCI_NOTIFY)
|
---|
911 | dprintf(("FIXME: MCI_NOTIFY not implemented yet! MCI_Close (line %d)\n",__LINE__));
|
---|
912 | // mciDriverNotify16(lpParms->dwCallback, wDevID,
|
---|
913 | // (dwRet == 0) ? MCI_NOTIFY_SUCCESSFUL : MCI_NOTIFY_FAILURE);
|
---|
914 |
|
---|
915 | return dwRet;
|
---|
916 | }
|
---|
917 |
|
---|
918 |
|
---|
919 | /**************************************************************************
|
---|
920 | * MCI_WriteString [internal]
|
---|
921 | */
|
---|
922 | DWORD MCI_WriteString(LPSTR lpDstStr, DWORD dstSize, LPCSTR lpSrcStr)
|
---|
923 | {
|
---|
924 | DWORD ret = 0;
|
---|
925 |
|
---|
926 | if (lpSrcStr) {
|
---|
927 | if (dstSize <= strlen(lpSrcStr)) {
|
---|
928 | lstrcpynA(lpDstStr, lpSrcStr, dstSize - 1);
|
---|
929 | ret = MCIERR_PARAM_OVERFLOW;
|
---|
930 | } else {
|
---|
931 | strcpy(lpDstStr, lpSrcStr);
|
---|
932 | }
|
---|
933 | } else {
|
---|
934 | *lpDstStr = 0;
|
---|
935 | }
|
---|
936 | return ret;
|
---|
937 | }
|
---|
938 |
|
---|
939 |
|
---|
940 | /**************************************************************************
|
---|
941 | * MCI_Sysinfo [internal]
|
---|
942 | */
|
---|
943 | static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSA lpParms)
|
---|
944 | {
|
---|
945 | DWORD ret = MCIERR_INVALID_DEVICE_ID;
|
---|
946 | LPWINE_MCIDRIVER wmd;
|
---|
947 | LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
|
---|
948 |
|
---|
949 | if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
|
---|
950 |
|
---|
951 | TRACE("(%08x, %08lX, %08lX[num=%ld, wDevTyp=%u])\n",
|
---|
952 | uDevID, dwFlags, (DWORD)lpParms, lpParms->dwNumber, lpParms->wDeviceType);
|
---|
953 |
|
---|
954 | switch (dwFlags & ~MCI_SYSINFO_OPEN) {
|
---|
955 | case MCI_SYSINFO_QUANTITY:
|
---|
956 | {
|
---|
957 | DWORD cnt = 0;
|
---|
958 |
|
---|
959 | if (lpParms->wDeviceType < MCI_DEVTYPE_FIRST ||
|
---|
960 | lpParms->wDeviceType > MCI_DEVTYPE_LAST) {
|
---|
961 | if (dwFlags & MCI_SYSINFO_OPEN) {
|
---|
962 | TRACE("MCI_SYSINFO_QUANTITY: # of open MCI drivers\n");
|
---|
963 | EnterCriticalSection(&iData->cs);
|
---|
964 | for (wmd = iData->lpMciDrvs; wmd; wmd = wmd->lpNext) {
|
---|
965 | cnt++;
|
---|
966 | }
|
---|
967 | LeaveCriticalSection(&iData->cs);
|
---|
968 | } else {
|
---|
969 | TRACE("MCI_SYSINFO_QUANTITY: # of installed MCI drivers\n");
|
---|
970 | cnt = MCI_InstalledCount;
|
---|
971 | }
|
---|
972 | } else {
|
---|
973 | if (dwFlags & MCI_SYSINFO_OPEN) {
|
---|
974 | TRACE("MCI_SYSINFO_QUANTITY: # of open MCI drivers of type %u\n",
|
---|
975 | lpParms->wDeviceType);
|
---|
976 | EnterCriticalSection(&iData->cs);
|
---|
977 | for (wmd = iData->lpMciDrvs; wmd; wmd = wmd->lpNext) {
|
---|
978 | if (wmd->wType == lpParms->wDeviceType)
|
---|
979 | cnt++;
|
---|
980 | }
|
---|
981 | LeaveCriticalSection(&iData->cs);
|
---|
982 | } else {
|
---|
983 | TRACE("MCI_SYSINFO_QUANTITY: # of installed MCI drivers of type %u\n",
|
---|
984 | lpParms->wDeviceType);
|
---|
985 | FIXME("Don't know how to get # of MCI devices of a given type\n");
|
---|
986 | cnt = 1;
|
---|
987 | }
|
---|
988 | }
|
---|
989 | *(DWORD*)lpParms->lpstrReturn = cnt;
|
---|
990 | }
|
---|
991 | TRACE("(%ld) => '%ld'\n", lpParms->dwNumber, *(DWORD*)lpParms->lpstrReturn);
|
---|
992 | ret = MCI_INTEGER_RETURNED;
|
---|
993 | break;
|
---|
994 | case MCI_SYSINFO_INSTALLNAME:
|
---|
995 | TRACE("MCI_SYSINFO_INSTALLNAME \n");
|
---|
996 | if ((wmd = MCI_GetDriver(uDevID))) {
|
---|
997 | ret = MCI_WriteString(lpParms->lpstrReturn, lpParms->dwRetSize,
|
---|
998 | wmd->lpstrDeviceType);
|
---|
999 | } else {
|
---|
1000 | *lpParms->lpstrReturn = 0;
|
---|
1001 | ret = MCIERR_INVALID_DEVICE_ID;
|
---|
1002 | }
|
---|
1003 | TRACE("(%ld) => '%s'\n", lpParms->dwNumber, lpParms->lpstrReturn);
|
---|
1004 | break;
|
---|
1005 | case MCI_SYSINFO_NAME:
|
---|
1006 | TRACE("MCI_SYSINFO_NAME\n");
|
---|
1007 | if (dwFlags & MCI_SYSINFO_OPEN) {
|
---|
1008 | FIXME("Don't handle MCI_SYSINFO_NAME|MCI_SYSINFO_OPEN (yet)\n");
|
---|
1009 | ret = MCIERR_UNRECOGNIZED_COMMAND;
|
---|
1010 | } else if (lpParms->dwNumber > MCI_InstalledCount) {
|
---|
1011 | ret = MCIERR_OUTOFRANGE;
|
---|
1012 | } else {
|
---|
1013 | DWORD count = lpParms->dwNumber;
|
---|
1014 | LPSTR ptr = MCI_lpInstallNames;
|
---|
1015 |
|
---|
1016 | while (--count > 0) ptr += strlen(ptr) + 1;
|
---|
1017 | ret = MCI_WriteString(lpParms->lpstrReturn, lpParms->dwRetSize, ptr);
|
---|
1018 | }
|
---|
1019 | TRACE("(%ld) => '%s'\n", lpParms->dwNumber, lpParms->lpstrReturn);
|
---|
1020 | break;
|
---|
1021 | default:
|
---|
1022 | TRACE("Unsupported flag value=%08lx\n", dwFlags);
|
---|
1023 | ret = MCIERR_UNRECOGNIZED_COMMAND;
|
---|
1024 | }
|
---|
1025 | return ret;
|
---|
1026 | }
|
---|
1027 |
|
---|
1028 |
|
---|
1029 | /**************************************************************************
|
---|
1030 | * MCI_Break [internal]
|
---|
1031 | */
|
---|
1032 | static DWORD MCI_Break(UINT wDevID, DWORD dwFlags, LPMCI_BREAK_PARMS lpParms)
|
---|
1033 | {
|
---|
1034 | DWORD dwRet = 0;
|
---|
1035 |
|
---|
1036 | if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
|
---|
1037 |
|
---|
1038 | if (dwFlags & MCI_NOTIFY)
|
---|
1039 | dprintf(("FIXME: MCI_NOTIFY not implemented yet! MCI_Break (line %d)\n",__LINE__));
|
---|
1040 | // mciDriverNotify16(lpParms->dwCallback, wDevID,
|
---|
1041 | // (dwRet == 0) ? MCI_NOTIFY_SUCCESSFUL : MCI_NOTIFY_FAILURE);
|
---|
1042 |
|
---|
1043 | return dwRet;
|
---|
1044 | }
|
---|
1045 |
|
---|
1046 |
|
---|
1047 | /**************************************************************************
|
---|
1048 | * MCI_SendCommand [internal]
|
---|
1049 | */
|
---|
1050 | static DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD dwParam1,
|
---|
1051 | DWORD dwParam2)
|
---|
1052 | {
|
---|
1053 | DWORD dwRet = MCIERR_UNRECOGNIZED_COMMAND;
|
---|
1054 |
|
---|
1055 | switch (wMsg) {
|
---|
1056 | case MCI_OPEN:
|
---|
1057 | dwRet = MCI_Open(dwParam1, (LPMCI_OPEN_PARMSA)dwParam2);
|
---|
1058 | break;
|
---|
1059 | case MCI_CLOSE:
|
---|
1060 | dwRet = MCI_Close(wDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2);
|
---|
1061 | break;
|
---|
1062 | case MCI_SYSINFO:
|
---|
1063 | dwRet = MCI_SysInfo(wDevID, dwParam1, (LPMCI_SYSINFO_PARMSA)dwParam2);
|
---|
1064 | break;
|
---|
1065 | case MCI_BREAK:
|
---|
1066 | dwRet = MCI_Break(wDevID, dwParam1, (LPMCI_BREAK_PARMS)dwParam2);
|
---|
1067 | break;
|
---|
1068 | // case MCI_SOUND:
|
---|
1069 | /* FIXME: it seems that MCI_SOUND needs the same handling as MCI_BREAK
|
---|
1070 | * but I couldn't get any doc on this MCI message
|
---|
1071 | */
|
---|
1072 | // break;
|
---|
1073 | default:
|
---|
1074 | if (wDevID == MCI_ALL_DEVICE_ID) {
|
---|
1075 | dprintf(("MCI_SendCommand: unhandled MCI_ALL_DEVICE_ID\n"));
|
---|
1076 | dwRet = MCIERR_CANNOT_USE_ALL;
|
---|
1077 | } else {
|
---|
1078 | dwRet=MCI_SendCommandFrom32(wDevID, wMsg, dwParam1, dwParam2);
|
---|
1079 | }
|
---|
1080 | break;
|
---|
1081 | }
|
---|
1082 | return dwRet;
|
---|
1083 | }
|
---|
1084 |
|
---|
1085 |
|
---|
1086 |
|
---|
1087 |
|
---|
1088 | /**************************************************************************
|
---|
1089 | * MULTIMEDIA_MciInit [internal]
|
---|
1090 | *
|
---|
1091 | * Initializes the MCI internal variables.
|
---|
1092 | *
|
---|
1093 | */
|
---|
1094 | BOOL MULTIMEDIA_MciInit(void)
|
---|
1095 | {
|
---|
1096 | LPSTR ptr1, ptr2;
|
---|
1097 | HKEY hWineConf;
|
---|
1098 | HKEY hkey;
|
---|
1099 | DWORD err;
|
---|
1100 | DWORD type;
|
---|
1101 | DWORD count = 2048;
|
---|
1102 |
|
---|
1103 | MCI_InstalledCount = 0;
|
---|
1104 | ptr1 = MCI_lpInstallNames = (char*) HeapAlloc(GetProcessHeap(), 0, count);
|
---|
1105 |
|
---|
1106 | if (!MCI_lpInstallNames)
|
---|
1107 | return FALSE;
|
---|
1108 |
|
---|
1109 | #if 0
|
---|
1110 | /* FIXME: should do also some registry diving here ? */
|
---|
1111 | if (!(err = RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config", &hWineConf)) &&
|
---|
1112 | !(err = RegOpenKeyA(hWineConf, "options", &hkey))) {
|
---|
1113 | err = RegQueryValueExA(hkey, "mci", 0, &type, MCI_lpInstallNames, &count);
|
---|
1114 | RegCloseKey(hkey);
|
---|
1115 | FIXME("Registry handling for mci drivers not changed for odin yet. Verbatim copy from WINE (line %d)",__LINE__);
|
---|
1116 | }
|
---|
1117 | #endif
|
---|
1118 | FIXME("No Registry querying for mci drivers yet! (line %d)",__LINE__);
|
---|
1119 | err=1;
|
---|
1120 | if (!err) {
|
---|
1121 | TRACE("Wine => '%s' \n", ptr1);
|
---|
1122 | while ((ptr2 = strchr(ptr1, ':')) != 0) {
|
---|
1123 | *ptr2++ = 0;
|
---|
1124 | TRACE("---> '%s' \n", ptr1);
|
---|
1125 | MCI_InstalledCount++;
|
---|
1126 | ptr1 = ptr2;
|
---|
1127 | }
|
---|
1128 | MCI_InstalledCount++;
|
---|
1129 | TRACE("---> '%s' \n", ptr1);
|
---|
1130 | ptr1 += strlen(ptr1) + 1;
|
---|
1131 | } else {
|
---|
1132 | GetPrivateProfileStringA("mci", NULL, "", MCI_lpInstallNames, count, "SYSTEM.INI");
|
---|
1133 | while (strlen(ptr1) > 0) {
|
---|
1134 | TRACE("---> '%s' \n", ptr1);
|
---|
1135 | ptr1 += strlen(ptr1) + 1;
|
---|
1136 | MCI_InstalledCount++;
|
---|
1137 | }
|
---|
1138 | }
|
---|
1139 | //RegCloseKey(hWineConf);
|
---|
1140 | return TRUE;
|
---|
1141 | }
|
---|