/*********************************************************************** * ICClose [MSVFW32.@] */ LRESULT WINAPI ICClose(HIC hic) { WINE_HIC* whic = MSVIDEO_GetHicPtr(hic); WINE_HIC** p; TRACE("(%p)\n",hic); if (!whic) return ICERR_BADHANDLE; if (whic->driverproc) { MSVIDEO_SendMessage(whic, DRV_CLOSE, 0, 0); MSVIDEO_SendMessage(whic, DRV_DISABLE, 0, 0); MSVIDEO_SendMessage(whic, DRV_FREE, 0, 0); } else { CloseDriver(whic->hdrv, 0, 0); } /* remove whic from list */ for (p = &MSVIDEO_FirstHic; *p != NULL; p = &((*p)->next)) { if ((*p) == whic) { *p = whic->next; break; } } HeapFree(GetProcessHeap(), 0, whic); return 0; }
/*********************************************************************** * ICOpenFunction [MSVFW32.@] */ HIC VFWAPI ICOpenFunction(DWORD fccType, DWORD fccHandler, UINT wMode, DRIVERPROC lpfnHandler) { ICOPEN icopen; WINE_HIC* whic; TRACE("(%s,%s,%d,%p)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wMode, lpfnHandler); icopen.dwSize = sizeof(ICOPEN); icopen.fccType = fccType; icopen.fccHandler = fccHandler; icopen.dwVersion = ICVERSION; icopen.dwFlags = wMode; icopen.dwError = 0; icopen.pV1Reserved = NULL; icopen.pV2Reserved = NULL; icopen.dnDevNode = 0; /* FIXME */ whic = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_HIC)); if (!whic) return 0; whic->driverproc = lpfnHandler; while (MSVIDEO_GetHicPtr((HIC)(ULONG_PTR)IC_HandleRef) != NULL) IC_HandleRef++; whic->hic = (HIC)(ULONG_PTR)IC_HandleRef++; whic->next = MSVIDEO_FirstHic; MSVIDEO_FirstHic = whic; /* Now try opening/loading the driver. Taken from DRIVER_AddToList */ /* What if the function is used more than once? */ if (MSVIDEO_SendMessage(whic, DRV_LOAD, 0L, 0L) != DRV_SUCCESS) { WARN("DRV_LOAD failed for hic %p\n", whic->hic); MSVIDEO_FirstHic = whic->next; HeapFree(GetProcessHeap(), 0, whic); return 0; } /* return value is not checked */ MSVIDEO_SendMessage(whic, DRV_ENABLE, 0L, 0L); whic->driverId = (DWORD)MSVIDEO_SendMessage(whic, DRV_OPEN, 0, (DWORD_PTR)&icopen); /* FIXME: What should we put here? */ whic->hdrv = NULL; if (whic->driverId == 0) { WARN("DRV_OPEN failed for hic %p\n", whic->hic); MSVIDEO_FirstHic = whic->next; HeapFree(GetProcessHeap(), 0, whic); return 0; } TRACE("=> %p\n", whic->hic); return whic->hic; }
/*********************************************************************** * ICSendMessage [MSVFW32.@] */ LRESULT VFWAPI ICSendMessage(HIC hic, UINT msg, DWORD_PTR lParam1, DWORD_PTR lParam2) { WINE_HIC* whic = MSVIDEO_GetHicPtr(hic); if (!whic) return ICERR_BADHANDLE; return MSVIDEO_SendMessage(whic, msg, lParam1, lParam2); }
/*********************************************************************** * ICSendMessage [MSVIDEO.205] */ LRESULT VFWAPI ICSendMessage16(HIC16 hic, UINT16 msg, DWORD lParam1, DWORD lParam2) { LRESULT ret = ICERR_BADHANDLE; WINE_HIC* whic; whic = MSVIDEO_GetHicPtr(HIC_32(hic)); if (whic) { /* we've got a 16 bit driver proc... call it directly */ if (whic->driverproc16) { WORD args[8]; DWORD result; /* FIXME: original code was passing hdrv first and hic second */ /* but this doesn't match what IC_Callback3216 does */ args[7] = HIWORD(hic); args[6] = LOWORD(hic); args[5] = HDRVR_16(whic->hdrv); args[4] = msg; args[3] = HIWORD(lParam1); args[2] = LOWORD(lParam1); args[1] = HIWORD(lParam2); args[0] = LOWORD(lParam2); WOWCallback16Ex( whic->driverproc16, WCB16_PASCAL, sizeof(args), args, &result ); ret = result; } else { /* map the message for a 32 bit infrastructure, and pass it along */ void* data16 = MSVIDEO_MapMsg16To32(msg, &lParam1, &lParam2); ret = MSVIDEO_SendMessage(whic, msg, lParam1, lParam2); if (data16) MSVIDEO_UnmapMsg16To32(msg, data16, &lParam1, &lParam2); } } return ret; }