/*! Retreive the global details of this ACM driver \param a_DriverDetail will be filled with all the corresponding data */ inline DWORD ACM::OnDriverDetails(const HDRVR hdrvr, LPACMDRIVERDETAILS a_DriverDetail) { if (my_hIcon == NULL) my_hIcon = LoadIcon(GetDriverModuleHandle(hdrvr), MAKEINTRESOURCE(IDI_ICON)); a_DriverDetail->hicon = my_hIcon; a_DriverDetail->fccType = ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC; a_DriverDetail->fccComp = ACMDRIVERDETAILS_FCCCOMP_UNDEFINED; /// \note this is an explicit hack of the FhG values /// \note later it could be a new value when the decoding is done a_DriverDetail->wMid = MM_FRAUNHOFER_IIS; a_DriverDetail->wPid = MM_FHGIIS_MPEGLAYER3; a_DriverDetail->vdwACM = VERSION_MSACM; a_DriverDetail->vdwDriver = VERSION_ACM_DRIVER; a_DriverDetail->fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CODEC; a_DriverDetail->cFormatTags = FORMAT_TAG_MAX_NB; // 2 : MP3 and PCM // a_DriverDetail->cFormatTags = 1; // 2 : MP3 and PCM a_DriverDetail->cFilterTags = FILTER_TAG_MAX_NB; lstrcpyW( a_DriverDetail->szShortName, L"LAME MP3" ); char tmpStr[128]; wsprintf(tmpStr, "LAME MP3 Codec v%s", GetVersionString()); int u = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, tmpStr, -1, a_DriverDetail->szLongName, 0); MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, tmpStr, -1, a_DriverDetail->szLongName, u); lstrcpyW( a_DriverDetail->szCopyright, L"2002 Steve Lhomme" ); lstrcpyW( a_DriverDetail->szLicensing, L"LGPL (see gnu.org)" ); /// \todo update this part when the code changes lstrcpyW( a_DriverDetail->szFeatures , L"only CBR implementation" ); return MMSYSERR_NOERROR; // Can also return DRVCNF_CANCEL }
/* 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) { 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 = pAudioDrv->hDriver)) { 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); } } } } } } /* 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]); }
LONG WINAPI DriverProc(DWORD dwDriverId, HDRVR hdrvr, UINT msg, LONG lParam1, LONG lParam2) { switch (msg) { case DRV_OPEN: // acmDriverOpen { if (debug == NULL) { debug = new ADbg(DEBUG_LEVEL_CREATION); debug->setPrefix("LAMEdrv"); } if (debug != NULL) { // Sent when the driver is opened. if (lParam2 != NULL) debug->OutPut(DEBUG_LEVEL_MSG, "DRV_OPEN (ID 0x%08X), pDesc = 0x%08X",dwDriverId,lParam2); else debug->OutPut(DEBUG_LEVEL_MSG, "DRV_OPEN (ID 0x%08X), pDesc = NULL",dwDriverId); } if (lParam2 != NULL) { LPACMDRVOPENDESC pDesc = (LPACMDRVOPENDESC)lParam2; if (pDesc->fccType != ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC) { if (debug != NULL) { debug->OutPut(DEBUG_LEVEL_FUNC_CODE, "wrong pDesc->fccType (0x%08X)",pDesc->fccType); } return NULL; } } else { if (debug != NULL) { debug->OutPut(DEBUG_LEVEL_FUNC_CODE, "pDesc == NULL"); } } ACM * ThisACM = new ACM(GetDriverModuleHandle(hdrvr)); if (debug != NULL) { debug->OutPut(DEBUG_LEVEL_FUNC_CODE, "OPENED instance 0x%08X",ThisACM); } return (LONG)ThisACM;// returns 0L to fail // value subsequently used // for dwDriverId. } break; case DRV_CLOSE: // acmDriverClose { if (debug != NULL) { // Sent when the driver is closed. Drivers are // unloaded when the open count reaches zero. debug->OutPut(DEBUG_LEVEL_MSG, "DRV_CLOSE"); } ACM * ThisACM = (ACM *)dwDriverId; delete ThisACM; if (debug != NULL) { debug->OutPut(DEBUG_LEVEL_FUNC_CODE, "CLOSED instance 0x%08X",ThisACM); delete debug; debug = NULL; } return 1L; // returns 0L to fail } break; case DRV_LOAD: { // nothing to do if (debug != NULL) { // debug->OutPut(DEBUG_LEVEL_MSG, "DRV_LOAD, version %s %s %s", ACM_VERSION, __DATE__, __TIME__); debug->OutPut(DEBUG_LEVEL_MSG, "DRV_LOAD, %s %s", __DATE__, __TIME__); } return 1L; } break; case DRV_ENABLE: { // nothing to do if (debug != NULL) { debug->OutPut(DEBUG_LEVEL_MSG, "DRV_ENABLE"); } return 1L; } break; case DRV_DISABLE: { // nothing to do if (debug != NULL) { debug->OutPut(DEBUG_LEVEL_MSG, "DRV_DISABLE"); } return 1L; } break; case DRV_FREE: { if (debug != NULL) { debug->OutPut(DEBUG_LEVEL_MSG, "DRV_FREE"); } return 1L; } break; default: { ACM * ThisACM = (ACM *)dwDriverId; if (ThisACM != NULL) return ThisACM->DriverProcedure(hdrvr, msg, lParam1, lParam2); else { if (debug != NULL) { debug->OutPut(DEBUG_LEVEL_MSG, "Driver not opened, unknown message (0x%08X), lParam1 = 0x%08X, lParam2 = 0x%08X", msg, lParam1, lParam2); } return DefDriverProc (dwDriverId, hdrvr, msg, lParam1, lParam2); } } break; } }