/*********************************************************************** * ICOpen [MSVFW.37] * Opens an installable compressor. Return special handle. */ HIC VFWAPI //ICOpen(long fccType,long fccHandler,unsigned int wMode) { ICOpen(long filename,long fccHandler,unsigned int wMode) { ICOPEN icopen; HDRVR hdrv; WINE_HIC *whic; /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the * same layout as ICOPEN */ icopen.fccType = 0x63646976; // "vidc" //fccType; icopen.fccHandler = fccHandler; icopen.dwSize = sizeof(ICOPEN); icopen.dwFlags = wMode; icopen.pV1Reserved = (void*)filename; /* FIXME: do we need to fill out the rest too? */ hdrv=OpenDriverA((long)&icopen); if (!hdrv) return 0; whic = malloc(sizeof(WINE_HIC)); whic->hdrv = hdrv; whic->driverproc= ((DRVR*)hdrv)->DriverProc; // whic->private = ICSendMessage((HIC)whic,DRV_OPEN,0,(long)&icopen); whic->driverid = ((DRVR*)hdrv)->dwDriverID; return (HIC)whic; }
/************************************************************************** * JOY_LoadDriver [internal] */ static BOOL JOY_LoadDriver(DWORD dwJoyID) { if (dwJoyID >= MAXJOYSTICK) return FALSE; if (JOY_Sticks[dwJoyID].hDriver) return TRUE; JOY_Sticks[dwJoyID].hDriver = OpenDriverA("winejoystick.drv", 0, dwJoyID); return (JOY_Sticks[dwJoyID].hDriver != 0); }
/*********************************************************************** * acmDriverOpen (MSACM32.10) */ MMRESULT WINAPI acmDriverOpen(PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpen) { PWINE_ACMDRIVERID padid; PWINE_ACMDRIVER pad; ICOPEN icopen; /* HDRVR hdrv; -- not used */ TRACE("(%p, %x, %08lu)\n", phad, hadid, fdwOpen); if (!phad) return MMSYSERR_INVALPARAM; padid = MSACM_GetDriverID(hadid); if (!padid) return MMSYSERR_INVALHANDLE; if (fdwOpen) return MMSYSERR_INVALFLAG; pad = HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVER)); if (!pad) return MMSYSERR_NOMEM; pad->obj.pACMDriverID = padid; icopen.fccType = mmioFOURCC('a', 'u', 'd', 'c'); icopen.fccHandler = (long)padid->pszFileName; icopen.dwSize = sizeof(ICOPEN); icopen.dwFlags = 0; icopen.pV1Reserved = padid->pszFileName; if (!padid->hInstModule) pad->hDrvr = OpenDriverA((long)&icopen); else pad->hDrvr = padid->hInstModule; if (!pad->hDrvr) { HeapFree(MSACM_hHeap, 0, pad); return MMSYSERR_ERROR; } pad->pfnDriverProc = GetProcAddress(pad->hDrvr, "DriverProc"); /* insert new pad at beg of list */ pad->pNextACMDriver = padid->pACMDriverList; padid->pACMDriverList = pad; /* FIXME: Create a WINE_ACMDRIVER32 */ *phad = (HACMDRIVER)pad; return MMSYSERR_NOERROR; }
/* find all drivers that can be loaded */ static void findAudioDrivers(void) { int numFound = 0; const AUDIO_DRIVER *pAudioDrv = NULL; HCURSOR old_cursor; /* delete an existing list */ HeapFree(GetProcessHeap(), 0, loadedAudioDrv); loadedAudioDrv = 0; /* change to the wait cursor because this can take a while if there is a * misbehaving driver that takes a long time to open */ old_cursor = SetCursor(LoadCursor(0, IDC_WAIT)); for (pAudioDrv = sAudioDrivers; pAudioDrv->nameID; pAudioDrv++) { if (strlen(pAudioDrv->szDriver)) { HDRVR hdrv; char driver[MAX_PATH]; sprintf(driver, "wine%s.drv", pAudioDrv->szDriver); if ((hdrv = OpenDriverA(driver, 0, 0))) { CloseDriver(hdrv, 0, 0); if (loadedAudioDrv) loadedAudioDrv = HeapReAlloc(GetProcessHeap(), 0, loadedAudioDrv, (numFound + 1) * sizeof(AUDIO_DRIVER)); else loadedAudioDrv = HeapAlloc(GetProcessHeap(), 0, sizeof(AUDIO_DRIVER)); CopyMemory(&loadedAudioDrv[numFound], pAudioDrv, sizeof(AUDIO_DRIVER)); numFound++; } } } /* restore the original cursor */ SetCursor(old_cursor); /* terminate list with empty driver */ if (numFound) { loadedAudioDrv = HeapReAlloc(GetProcessHeap(), 0, loadedAudioDrv, (numFound + 1) * sizeof(AUDIO_DRIVER)); CopyMemory(&loadedAudioDrv[numFound], pAudioDrv, sizeof(AUDIO_DRIVER)); } else { loadedAudioDrv = HeapAlloc(GetProcessHeap(), 0, sizeof(AUDIO_DRIVER)); CopyMemory(&loadedAudioDrv[0], pAudioDrv, sizeof(AUDIO_DRIVER)); } }
/* display a driver specific configuration dialog */ static void configureAudioDriver(HWND hDlg) { const AUDIO_DRIVER *pAudioDrv = &loadedAudioDrv[toConfigure]; if (strlen(pAudioDrv->szDriver) != 0) { HDRVR hdrvr; char wine_driver[MAX_NAME_LENGTH + 9]; sprintf(wine_driver, "wine%s.drv", pAudioDrv->szDriver); hdrvr = OpenDriverA(wine_driver, 0, 0); if (hdrvr != 0) { if (SendDriverMessage(hdrvr, DRV_QUERYCONFIGURE, 0, 0) != 0) { DRVCONFIGINFO dci; LONG lRes; dci.dwDCISize = sizeof (dci); dci.lpszDCISectionName = NULL; dci.lpszDCIAliasName = NULL; lRes = SendDriverMessage(hdrvr, DRV_CONFIGURE, 0, (LONG_PTR)&dci); } CloseDriver(hdrvr, 0, 0); } else { WCHAR wine_driverW[MAX_NAME_LENGTH+9]; WCHAR messageStr[256]; WCHAR str[1024]; MultiByteToWideChar (CP_ACP, 0, wine_driver, -1, wine_driverW, sizeof (wine_driverW)/sizeof(wine_driverW[0])); LoadStringW (GetModuleHandle (NULL), IDS_OPEN_DRIVER_ERROR, messageStr, sizeof(messageStr)/sizeof(messageStr[0])); wsprintfW (str, messageStr, wine_driverW); MessageBoxW (hDlg, str, NULL, MB_OK | MB_ICONERROR); } } }
/* find all drivers that can be loaded */ static void findAudioDrivers(void) { int numFound = 0; AUDIO_DRIVER *pAudioDrv = NULL; HCURSOR old_cursor; /* delete an existing list */ HeapFree(GetProcessHeap(), 0, loadedAudioDrv); loadedAudioDrv = 0; /* change to the wait cursor because this can take a while if there is a * misbehaving driver that takes a long time to open */ old_cursor = SetCursor(LoadCursor(0, IDC_WAIT)); for (pAudioDrv = sAudioDrivers; pAudioDrv->nameID; pAudioDrv++) { if (strlen(pAudioDrv->szDriver)) { HDRVR hdrv; char driver[MAX_PATH]; sprintf(driver, "wine%s.drv", pAudioDrv->szDriver); hdrv = pAudioDrv->hDriver; if (!pAudioDrv->hDriver && (hdrv = OpenDriverA(driver, 0, 0))) { HMODULE lib = GetDriverModuleHandle(hdrv); MessagePtr wodMessagePtr = (MessagePtr)GetProcAddress(lib, "wodMessage"); MessagePtr widMessagePtr = (MessagePtr)GetProcAddress(lib, "widMessage"); MessagePtr modMessagePtr = (MessagePtr)GetProcAddress(lib, "modMessage"); MessagePtr midMessagePtr = (MessagePtr)GetProcAddress(lib, "midMessage"); MessagePtr auxMessagePtr = (MessagePtr)GetProcAddress(lib, "auxMessage"); MessagePtr mxdMessagePtr = (MessagePtr)GetProcAddress(lib, "mxdMessage"); pAudioDrv->hDriver = hdrv; if (wodMessagePtr) wodMessagePtr(0, DRVM_INIT, 0, 0, 0); if (widMessagePtr) widMessagePtr(0, DRVM_INIT, 0, 0, 0); if (modMessagePtr) modMessagePtr(0, DRVM_INIT, 0, 0, 0); if (midMessagePtr) midMessagePtr(0, DRVM_INIT, 0, 0, 0); if (auxMessagePtr) auxMessagePtr(0, DRVM_INIT, 0, 0, 0); if (mxdMessagePtr) mxdMessagePtr(0, DRVM_INIT, 0, 0, 0); } if (hdrv) { if (loadedAudioDrv) loadedAudioDrv = HeapReAlloc(GetProcessHeap(), 0, loadedAudioDrv, (numFound + 1) * sizeof(AUDIO_DRIVER)); else loadedAudioDrv = HeapAlloc(GetProcessHeap(), 0, sizeof(AUDIO_DRIVER)); CopyMemory(&loadedAudioDrv[numFound], pAudioDrv, sizeof(AUDIO_DRIVER)); numFound++; } } } /* restore the original cursor */ SetCursor(old_cursor); /* terminate list with empty driver */ if (numFound) { loadedAudioDrv = HeapReAlloc(GetProcessHeap(), 0, loadedAudioDrv, (numFound + 1) * sizeof(AUDIO_DRIVER)); CopyMemory(&loadedAudioDrv[numFound], pAudioDrv, sizeof(AUDIO_DRIVER)); } else { loadedAudioDrv = HeapAlloc(GetProcessHeap(), 0, sizeof(AUDIO_DRIVER)); CopyMemory(&loadedAudioDrv[0], pAudioDrv, sizeof(AUDIO_DRIVER)); } }
static void initAudioDeviceTree(HWND hDlg) { const AUDIO_DRIVER *pAudioDrv = NULL; int i, j; TVINSERTSTRUCTW insert; HTREEITEM root, driver[10]; HWND tree = NULL; HIMAGELIST hImageList; HBITMAP hBitMap; HCURSOR old_cursor; WCHAR driver_type[64], dev_type[64]; tree = GetDlgItem(hDlg, IDC_AUDIO_TREE); if (!tree) return; /* set tree view style */ SetWindowLong(tree, GWL_STYLE, GetWindowLong(tree, GWL_STYLE) | TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT); /* state checkbox */ hImageList = ImageList_Create(16, 16, FALSE, 3, 0); hBitMap = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_CHECKBOX)); ImageList_Add(hImageList, hBitMap, NULL); DeleteObject(hBitMap); SendMessageW( tree, TVM_SETIMAGELIST, TVSIL_STATE, (LPARAM)hImageList ); /* root item */ LoadStringW (GetModuleHandle (NULL), IDS_SOUNDDRIVERS, driver_type, sizeof(driver_type)/sizeof(driver_type[0])); insert.hParent = TVI_ROOT; insert.hInsertAfter = TVI_LAST; insert.u.item.mask = TVIF_TEXT | TVIF_CHILDREN; insert.u.item.pszText = driver_type; insert.u.item.cChildren = 1; root = (HTREEITEM)SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert); /* change to the wait cursor because this can take a while if there is a * misbehaving driver that takes a long time to open */ old_cursor = SetCursor(LoadCursor(0, IDC_WAIT)); /* iterate over list of loaded drivers */ for (pAudioDrv = loadedAudioDrv, i = 0; pAudioDrv->nameID; i++, pAudioDrv++) { HDRVR hdrv; char name[MAX_PATH]; WCHAR text[MAX_PATH]; sprintf(name, "wine%s.drv", pAudioDrv->szDriver); LoadStringW (GetModuleHandle (NULL), pAudioDrv->nameID, text, sizeof(text)/sizeof(text[0])); if ((hdrv = OpenDriverA(name, 0, 0))) { HMODULE lib; if ((lib = GetDriverModuleHandle(hdrv))) { int num_wod = 0, num_wid = 0, num_mod = 0, num_mid = 0, num_aux = 0, num_mxd = 0; MessagePtr wodMessagePtr = (MessagePtr)GetProcAddress(lib, "wodMessage"); MessagePtr widMessagePtr = (MessagePtr)GetProcAddress(lib, "widMessage"); MessagePtr modMessagePtr = (MessagePtr)GetProcAddress(lib, "modMessage"); MessagePtr midMessagePtr = (MessagePtr)GetProcAddress(lib, "midMessage"); MessagePtr auxMessagePtr = (MessagePtr)GetProcAddress(lib, "auxMessage"); MessagePtr mxdMessagePtr = (MessagePtr)GetProcAddress(lib, "mxdMessage"); if (wodMessagePtr) num_wod = wodMessagePtr(0, WODM_GETNUMDEVS, 0, 0, 0); if (widMessagePtr) num_wid = widMessagePtr(0, WIDM_GETNUMDEVS, 0, 0, 0); if (modMessagePtr) num_mod = modMessagePtr(0, MODM_GETNUMDEVS, 0, 0, 0); if (midMessagePtr) num_mid = midMessagePtr(0, MIDM_GETNUMDEVS, 0, 0, 0); if (auxMessagePtr) num_aux = auxMessagePtr(0, AUXDM_GETNUMDEVS, 0, 0, 0); if (mxdMessagePtr) num_mxd = mxdMessagePtr(0, MXDM_GETNUMDEVS, 0, 0, 0); if (num_wod == 0 && num_wid == 0 && num_mod == 0 && num_mid == 0 && num_aux == 0 && num_mxd == 0) { insert.hParent = root; insert.u.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM; insert.u.item.pszText = text; insert.u.item.stateMask = TVIS_STATEIMAGEMASK; insert.u.item.lParam = i + DRIVER_MASK; if (isDriverSet(pAudioDrv->szDriver)) insert.u.item.state = INDEXTOSTATEIMAGEMASK(2); else insert.u.item.state = INDEXTOSTATEIMAGEMASK(1); driver[i] = (HTREEITEM)SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert); } else { HTREEITEM type; insert.hParent = root; insert.u.item.mask = TVIF_TEXT | TVIF_CHILDREN | TVIF_STATE | TVIF_PARAM; insert.u.item.pszText = text; insert.u.item.cChildren = 1; insert.u.item.stateMask = TVIS_STATEIMAGEMASK; insert.u.item.lParam = i + DRIVER_MASK; if (isDriverSet(pAudioDrv->szDriver)) insert.u.item.state = INDEXTOSTATEIMAGEMASK(2); else insert.u.item.state = INDEXTOSTATEIMAGEMASK(1); driver[i] = (HTREEITEM)SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert); if (num_wod) { LoadStringW (GetModuleHandle (NULL), IDS_DEVICES_WAVEOUT, dev_type, sizeof(dev_type)/sizeof(dev_type[0])); insert.hParent = driver[i]; insert.u.item.mask = TVIF_TEXT | TVIF_CHILDREN; insert.u.item.pszText = dev_type; insert.u.item.cChildren = 1; type = (HTREEITEM)SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert); for (j = 0; j < num_wod; j++) { WAVEOUTCAPSW caps; wodMessagePtr(j, WODM_GETDEVCAPS, 0, (DWORD_PTR)&caps, sizeof(caps)); insert.hParent = type; insert.u.item.mask = TVIF_TEXT | TVIF_PARAM; insert.u.item.pszText = caps.szPname; insert.u.item.lParam = j + DEVICE_MASK; SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert); } } if (num_wid) { LoadStringW (GetModuleHandle (NULL), IDS_DEVICES_WAVEIN, dev_type, sizeof(dev_type)/sizeof(dev_type[0])); insert.hParent = driver[i]; insert.u.item.mask = TVIF_TEXT | TVIF_CHILDREN; insert.u.item.pszText = dev_type; insert.u.item.cChildren = 1; type = (HTREEITEM)SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert); for (j = 0; j < num_wid; j++) { WAVEINCAPSW caps; widMessagePtr(j, WIDM_GETDEVCAPS, 0, (DWORD_PTR)&caps, sizeof(caps)); insert.hParent = type; insert.u.item.mask = TVIF_TEXT | TVIF_PARAM; insert.u.item.pszText = caps.szPname; insert.u.item.lParam = j + DEVICE_MASK; SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert); } } if (num_mod) { LoadStringW (GetModuleHandle (NULL), IDS_DEVICES_MIDIOUT, dev_type, sizeof(dev_type)/sizeof(dev_type[0])); insert.hParent = driver[i]; insert.u.item.mask = TVIF_TEXT | TVIF_CHILDREN; insert.u.item.pszText = dev_type; insert.u.item.cChildren = 1; type = (HTREEITEM)SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert); for (j = 0; j < num_mod; j++) { MIDIOUTCAPSW caps; modMessagePtr(j, MODM_GETDEVCAPS, 0, (DWORD_PTR)&caps, sizeof(caps)); insert.hParent = type; insert.u.item.mask = TVIF_TEXT | TVIF_PARAM; insert.u.item.pszText = caps.szPname; insert.u.item.lParam = j + DEVICE_MASK; SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert); } } if (num_mid) { LoadStringW (GetModuleHandle (NULL), IDS_DEVICES_MIDIIN, dev_type, sizeof(dev_type)/sizeof(dev_type[0])); insert.hParent = driver[i]; insert.u.item.mask = TVIF_TEXT | TVIF_CHILDREN; insert.u.item.pszText = dev_type; insert.u.item.cChildren = 1; type = (HTREEITEM)SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert); for (j = 0; j < num_mid; j++) { MIDIINCAPSW caps; midMessagePtr(j, MIDM_GETDEVCAPS, 0, (DWORD_PTR)&caps, sizeof(caps)); insert.hParent = type; insert.u.item.mask = TVIF_TEXT | TVIF_PARAM; insert.u.item.pszText = caps.szPname; insert.u.item.lParam = j + DEVICE_MASK; SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert); } } if (num_aux) { LoadStringW (GetModuleHandle (NULL), IDS_DEVICES_AUX, dev_type, sizeof(dev_type)/sizeof(dev_type[0])); insert.hParent = driver[i]; insert.u.item.mask = TVIF_TEXT | TVIF_CHILDREN; insert.u.item.pszText = dev_type; insert.u.item.cChildren = 1; type = (HTREEITEM)SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert); for (j = 0; j < num_aux; j++) { AUXCAPSW caps; auxMessagePtr(j, AUXDM_GETDEVCAPS, 0, (DWORD_PTR)&caps, sizeof(caps)); insert.hParent = type; insert.u.item.mask = TVIF_TEXT | TVIF_PARAM; insert.u.item.pszText = caps.szPname; insert.u.item.lParam = j + DEVICE_MASK; SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert); } } if (num_mxd) { LoadStringW (GetModuleHandle (NULL), IDS_DEVICES_MIXER, dev_type, sizeof(dev_type)/sizeof(dev_type[0])); insert.hParent = driver[i]; insert.u.item.mask = TVIF_TEXT | TVIF_CHILDREN; insert.u.item.pszText = dev_type; insert.u.item.cChildren = 1; type = (HTREEITEM)SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert); for (j = 0; j < num_mxd; j++) { MIXERCAPSW caps; mxdMessagePtr(j, MXDM_GETDEVCAPS, 0, (DWORD_PTR)&caps, sizeof(caps)); insert.hParent = type; insert.u.item.mask = TVIF_TEXT | TVIF_PARAM; insert.u.item.pszText = caps.szPname; insert.u.item.lParam = j + DEVICE_MASK; SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert); } } } } CloseDriver(hdrv, 0, 0); } } /* restore the original cursor */ SetCursor(old_cursor); SendDlgItemMessage(hDlg, IDC_AUDIO_TREE, TVM_SELECTITEM, 0, 0); SendDlgItemMessage(hDlg, IDC_AUDIO_TREE, TVM_EXPAND, TVE_EXPAND, (LPARAM)root); for (j = 0; j < i; j++) SendDlgItemMessage(hDlg, IDC_AUDIO_TREE, TVM_EXPAND, TVE_EXPAND, (LPARAM)driver[j]); }