QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) { Q_UNUSED(mode) QList<QByteArray> devices; if(mode == QAudio::AudioOutput) { WAVEOUTCAPS woc; unsigned long iNumDevs,i; iNumDevs = waveOutGetNumDevs(); for(i=0;i<iNumDevs;i++) { if(waveOutGetDevCaps(i, &woc, sizeof(WAVEOUTCAPS)) == MMSYSERR_NOERROR) { devices.append(QString((const QChar *)woc.szPname).toLocal8Bit().constData()); } } } else { WAVEINCAPS woc; unsigned long iNumDevs,i; iNumDevs = waveInGetNumDevs(); for(i=0;i<iNumDevs;i++) { if(waveInGetDevCaps(i, &woc, sizeof(WAVEINCAPS)) == MMSYSERR_NOERROR) { devices.append(QString((const QChar *)woc.szPname).toLocal8Bit().constData()); } } } if(devices.count() > 0) devices.append("default"); return devices; }
// Determine if this computer has a sound card capable of recording JNIEXPORT jboolean JNICALL Java_craigl_winrecorder_WinRecorder_nativeHasSoundCard( JNIEnv *env, jobject o) { WAVEINCAPS waveInCaps; BOOL success; if (waveInGetNumDevs() == 0) return FALSE; // We have a recording device, grab its specs success = (waveInGetDevCaps(0, &waveInCaps, sizeof(WAVEINCAPS)) == MMSYSERR_NOERROR); if (success) { #ifdef DEBUG // Display info printf("Manufacturer ID: %d\n", waveInCaps.wMid); printf("Product ID: %d\n", waveInCaps.wPid); printf("Maj Version: %d\n", waveInCaps.vDriverVersion >> 8); printf("Min Version: %d\n", waveInCaps.vDriverVersion & 255); printf("Product Name: %s\n", waveInCaps.szPname); printf("Formats: %x\n", waveInCaps.dwFormats); printf("Channels: %d\n", waveInCaps.wChannels); #endif return TRUE; } else return FALSE;
bool CAudio::InitializeWaveIn() { if (!waveInGetNumDevs()) return false; MMRESULT mmResult; DWORD dwThreadID = 0; m_hThreadCallBack = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)waveInCallBack, (LPVOID)this, CREATE_SUSPENDED, &dwThreadID); mmResult = waveInOpen(&m_hWaveIn, (WORD)WAVE_MAPPER, &(m_GSMWavefmt.wfx), (LONG)dwThreadID, (LONG)0, CALLBACK_THREAD); if (mmResult != MMSYSERR_NOERROR) return false; for (int i = 0; i < 2; i++) { m_lpInAudioHdr[i]->lpData = (LPSTR)m_lpInAudioData[i]; m_lpInAudioHdr[i]->dwBufferLength = m_nBufferLength; m_lpInAudioHdr[i]->dwFlags = 0; m_lpInAudioHdr[i]->dwLoops = 0; waveInPrepareHeader(m_hWaveIn, m_lpInAudioHdr[i], sizeof(WAVEHDR)); } waveInAddBuffer(m_hWaveIn, m_lpInAudioHdr[m_nWaveInIndex], sizeof(WAVEHDR)); ResumeThread(m_hThreadCallBack); waveInStart(m_hWaveIn); m_bIsWaveInUsed = true; return true; }
/* list the audio and MIDI device names */ void mmio_listdevs(void) { UINT wRtn, ndevices; unsigned int i; ndevices = waveInGetNumDevs(); for (i = 0; i < ndevices; i++) { WAVEINCAPS wicap; wRtn = waveInGetDevCaps(i, (LPWAVEINCAPS) &wicap, sizeof(wicap)); if (wRtn) nt_waveinerror("waveInGetDevCaps: %s\n", wRtn); else fprintf(stderr, "audio input device #%d: %s\n", i+1, wicap.szPname); } ndevices = waveOutGetNumDevs(); for (i = 0; i < ndevices; i++) { WAVEOUTCAPS wocap; wRtn = waveOutGetDevCaps(i, (LPWAVEOUTCAPS) &wocap, sizeof(wocap)); if (wRtn) nt_waveouterror("waveOutGetDevCaps: %s\n", wRtn); else fprintf(stderr, "audio output device #%d: %s\n", i+1, wocap.szPname); } }
void initAudioDevices(SIPX_INSTANCE_DATA& pInst) { #if defined(_WIN32) WAVEOUTCAPS outcaps; WAVEINCAPS incaps; int numDevices; MMRESULT result; numDevices = waveInGetNumDevs(); for (int i = 0; i < numDevices && i < MAX_AUDIO_DEVICES; i++) { result = waveInGetDevCaps(i, &incaps, sizeof(WAVEINCAPS)); assert(result == MMSYSERR_NOERROR); pInst.inputAudioDevices[i] = SAFE_STRDUP(incaps.szPname); } pInst.nInputAudioDevices = numDevices; numDevices = waveOutGetNumDevs(); for (int i = 0; i < numDevices && i < MAX_AUDIO_DEVICES; i++) { result = waveOutGetDevCaps(i, &outcaps, sizeof(WAVEOUTCAPS)); assert(result == MMSYSERR_NOERROR); pInst.outputAudioDevices[i] = SAFE_STRDUP(outcaps.szPname) ; } pInst.nOutputAudioDevices = numDevices; #else pInst.inputAudioDevices[0] = SAFE_STRDUP("Default"); pInst.outputAudioDevices[0] = SAFE_STRDUP("Default"); #endif }
void mmio_getdevs(char *indevlist, int *nindevs, char *outdevlist, int *noutdevs, int *canmulti, int maxndev, int devdescsize) { int wRtn, ndev, i; *canmulti = 2; /* supports multiple devices */ ndev = waveInGetNumDevs(); if (ndev > maxndev) ndev = maxndev; *nindevs = ndev; for (i = 0; i < ndev; i++) { WAVEINCAPS wicap; wRtn = waveInGetDevCaps(i, (LPWAVEINCAPS) &wicap, sizeof(wicap)); sprintf(indevlist + i * devdescsize, (wRtn ? "???" : wicap.szPname)); } ndev = waveOutGetNumDevs(); if (ndev > maxndev) ndev = maxndev; *noutdevs = ndev; for (i = 0; i < ndev; i++) { WAVEOUTCAPS wocap; wRtn = waveOutGetDevCaps(i, (LPWAVEOUTCAPS) &wocap, sizeof(wocap)); sprintf(outdevlist + i * devdescsize, (wRtn ? "???" : wocap.szPname)); } }
void CSettingsDlg::OnButtonAudioinput() { std::vector<CString> deviceList; //Obtain the number of input devices on the system DWORD numWaveInputDevices = waveInGetNumDevs(); //Scan through each input device to see if we can find the FM Radio for (DWORD i = 0; i < numWaveInputDevices; i++) { WAVEINCAPS waveInputCapabilities; //Get the device capabilities of the currently indexed device if (waveInGetDevCaps(i, &waveInputCapabilities, sizeof(waveInputCapabilities)) == MMSYSERR_NOERROR) { deviceList.push_back(waveInputCapabilities.szPname); } } CDeviceSelectDlg deviceSelectDlg(&deviceList, m_RadioIndex); if (deviceSelectDlg.DoModal() == IDOK) { m_RadioIndex = deviceSelectDlg.GetIndex(); } }
static DWORD widGetDevCaps(UINT wDevID, WAVEMAPDATA* wim, LPWAVEINCAPSW lpWaveCaps, DWORD dwParam2) { TRACE("(%04x, %p %p %08x)\n", wDevID, wim, lpWaveCaps, dwParam2); /* if opened low driver, forward message */ if (WAVEMAP_IsData(wim)) return waveInGetDevCapsW((UINT_PTR)wim->u.in.hInnerWave, lpWaveCaps, dwParam2); /* else if no drivers, nothing to map so return bad device */ if (waveInGetNumDevs() == 0) { WARN("bad device id\n"); return MMSYSERR_BADDEVICEID; } /* otherwise, return caps of mapper itself */ if (wDevID == (UINT)-1 || wDevID == (UINT16)-1) { WAVEINCAPSW wic; static const WCHAR init[] = {'W','i','n','e',' ','w','a','v','e',' ','i','n',' ','m','a','p','p','e','r',0}; wic.wMid = 0x00FF; wic.wPid = 0x0001; wic.vDriverVersion = 0x0001; strcpyW(wic.szPname, init); wic.dwFormats = WAVE_FORMAT_96M08 | WAVE_FORMAT_96S08 | WAVE_FORMAT_96M16 | WAVE_FORMAT_96S16 | WAVE_FORMAT_48M08 | WAVE_FORMAT_48S08 | WAVE_FORMAT_48M16 | WAVE_FORMAT_48S16 | WAVE_FORMAT_4M08 | WAVE_FORMAT_4S08 | WAVE_FORMAT_4M16 | WAVE_FORMAT_4S16 | WAVE_FORMAT_2M08 | WAVE_FORMAT_2S08 | WAVE_FORMAT_2M16 | WAVE_FORMAT_2S16 | WAVE_FORMAT_1M08 | WAVE_FORMAT_1S08 | WAVE_FORMAT_1M16 | WAVE_FORMAT_1S16; wic.wChannels = 2; memcpy(lpWaveCaps, &wic, min(dwParam2, sizeof(wic))); return MMSYSERR_NOERROR; } ERR("This shouldn't happen\n"); return MMSYSERR_ERROR; }
static void wave_in_tests(void) { WAVEINCAPSA capsA; WAVEINCAPSW capsW; WAVEFORMATEX format; HWAVEIN win; MMRESULT rc; DWORD preferred, status; UINT ndev,d; ndev=waveInGetNumDevs(); trace("found %d WaveIn devices\n",ndev); rc = waveInMessage((HWAVEIN)WAVE_MAPPER, DRVM_MAPPER_PREFERRED_GET, (DWORD_PTR)&preferred, (DWORD_PTR)&status); ok((ndev == 0 && (rc == MMSYSERR_NODRIVER || rc == MMSYSERR_BADDEVICEID)) || rc == MMSYSERR_NOTSUPPORTED || rc == MMSYSERR_NOERROR, "waveInMessage(DRVM_MAPPER_PREFERRED_GET) failed: %u\n", rc); if(rc != MMSYSERR_NOTSUPPORTED) ok((ndev == 0 && (preferred == -1 || broken(preferred != -1))) || preferred < ndev, "Got invalid preferred device: 0x%x\n", preferred); rc=waveInGetDevCapsA(ndev+1,&capsA,sizeof(capsA)); ok(rc==MMSYSERR_BADDEVICEID, "waveInGetDevCapsA(%s): MMSYSERR_BADDEVICEID expected, got %s\n", dev_name(ndev+1),wave_in_error(rc)); rc=waveInGetDevCapsA(WAVE_MAPPER,&capsA,sizeof(capsA)); ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_NODRIVER || (!ndev && (rc==MMSYSERR_BADDEVICEID)), "waveInGetDevCapsA(%s): got %s\n",dev_name(WAVE_MAPPER),wave_in_error(rc)); rc=waveInGetDevCapsW(ndev+1,&capsW,sizeof(capsW)); ok(rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NOTSUPPORTED, "waveInGetDevCapsW(%s): MMSYSERR_BADDEVICEID or MMSYSERR_NOTSUPPORTED " "expected, got %s\n",dev_name(ndev+1),wave_in_error(rc)); rc=waveInGetDevCapsW(WAVE_MAPPER,&capsW,sizeof(capsW)); ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_NODRIVER || rc==MMSYSERR_NOTSUPPORTED || (!ndev && (rc==MMSYSERR_BADDEVICEID)), "waveInGetDevCapsW(%s): got %s\n", dev_name(ndev+1),wave_in_error(rc)); format.wFormatTag=WAVE_FORMAT_PCM; format.nChannels=2; format.wBitsPerSample=16; format.nSamplesPerSec=44100; format.nBlockAlign=format.nChannels*format.wBitsPerSample/8; format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign; format.cbSize=0; rc=waveInOpen(&win,ndev+1,&format,0,0,CALLBACK_NULL); ok(rc==MMSYSERR_BADDEVICEID, "waveInOpen(%s): MMSYSERR_BADDEVICEID expected, got %s\n", dev_name(ndev+1),wave_in_error(rc)); for (d=0;d<ndev;d++) wave_in_test_device(d); if (ndev>0) wave_in_test_device(WAVE_MAPPER); }
// Open wave input channel int OpenWaveIn(HWAVEIN* hWaveIn, WAVEFORMATEX* wf) { int res; char lpTemp[256]; res = waveInGetNumDevs(); if (! res ) { _debug_print("Access WaveIn channel FAILED!",1); return -1; } else { _debug_print("Access WaveIn channel SUCCEED!"); } // Open wave input channel res = waveInOpen(hWaveIn,WAVE_MAPPER, wf, (DWORD)NULL,0L,CALLBACK_WINDOW); if ( res != MMSYSERR_NOERROR ) { sprintf(lpTemp, "Open wave input channel FAILED£¬Error_Code = 0x%x", res ); _debug_print(lpTemp,1); return -1; } else { _debug_print("Open wave input channel SUCCEED!"); } return 0; }
/* ////////////////////////// PUBLIC STATIC ///////////////////////////////// */ UtlString MpidWinMM::getDefaultDeviceName() { UtlString devName = ""; // Get windows default input device name unsigned nDevs = waveInGetNumDevs(); if (nDevs == 0) { OsSysLog::add(FAC_AUDIO, PRI_ERR, "MpidWinMM::getDefaultDeviceName: " "No input audio devices present!"); } assert(nDevs != 0); MMRESULT wavResult = MMSYSERR_NOERROR; WAVEINCAPS devCaps; int defaultWinDeviceId = 0; wavResult = waveInGetDevCaps(defaultWinDeviceId, &devCaps, sizeof(devCaps)); if (wavResult != MMSYSERR_NOERROR) { OsSysLog::add(FAC_AUDIO, PRI_ERR, "MpodWinMM::getDefaultDeviceName: " "Couldn't get default input device capabilities!"); showWaveError("WINDOWS_DEFAULT_DEVICE_HACK", wavResult, -1, __LINE__); } else { devName = devCaps.szPname; } assert(wavResult == MMSYSERR_NOERROR); return devName; }
UINT CSoundRecDlg::FillDevices() { CComboBox *pBox=(CComboBox*)GetDlgItem(IDC_DEVICES); UINT nDevices,nC1; WAVEINCAPS stWIC={0}; MMRESULT mRes; pBox->ResetContent(); nDevices=waveInGetNumDevs(); for(nC1=0;nC1<nDevices;++nC1) { ZeroMemory(&stWIC,sizeof(WAVEINCAPS)); mRes=waveInGetDevCaps(nC1,&stWIC,sizeof(WAVEINCAPS)); if(mRes==0) pBox->AddString(stWIC.szPname); else StoreError(mRes,TRUE,"File: %s ,Line Number:%d",__FILE__,__LINE__); } if(pBox->GetCount()) { pBox->SetCurSel(0); OnCbnSelchangeDevices(); } return nDevices; }
void Mixer::open(unsigned numChannels, unsigned samplingFrequency, unsigned granularityInMS) { HMIXER newHMixer = NULL; do { MIXERCAPS mc; if (mixerGetDevCaps(index, &mc, sizeof mc) != MMSYSERR_NOERROR) break; #ifdef UNICODE // Copy the mixer name: wcstombs(name, mc.szPname, MAXPNAMELEN); #else strncpy(name, mc.szPname, MAXPNAMELEN); #endif // Find the correct line for this mixer: unsigned i, uWavIn; unsigned nWavIn = waveInGetNumDevs(); for (i = 0; i < nWavIn; ++i) { WAVEINCAPS wic; if (waveInGetDevCaps(i, &wic, sizeof wic) != MMSYSERR_NOERROR) continue; MIXERLINE ml; ml.cbStruct = sizeof ml; ml.Target.dwType = MIXERLINE_TARGETTYPE_WAVEIN; #ifdef UNICODE wcsncpy(ml.Target.szPname, wic.szPname, MAXPNAMELEN); #else strncpy(ml.Target.szPname, wic.szPname, MAXPNAMELEN); #endif ml.Target.vDriverVersion = wic.vDriverVersion; ml.Target.wMid = wic.wMid; ml.Target.wPid = wic.wPid; if (mixerGetLineInfo((HMIXEROBJ)index, &ml, MIXER_GETLINEINFOF_TARGETTYPE/*|MIXER_OBJECTF_MIXER*/) == MMSYSERR_NOERROR) { // this is the right line uWavIn = i; dwRecLineID = ml.dwLineID; break; } } if (i >= nWavIn) break; // error: we couldn't find the right line if (mixerOpen(&newHMixer, index, (unsigned long)NULL, (unsigned long)NULL, MIXER_OBJECTF_MIXER) != MMSYSERR_NOERROR) break; if (newHMixer == NULL) break; // Sanity check: re-call "mixerGetDevCaps()" using the mixer device handle: if (mixerGetDevCaps((UINT)newHMixer, &mc, sizeof mc) != MMSYSERR_NOERROR) break; if (mc.cDestinations < 1) break; // error: this mixer has no destinations if (!WindowsAudioInputDevice_common::openWavInPort(uWavIn, numChannels, samplingFrequency, granularityInMS)) break; hMixer = newHMixer; return; } while (0); // An error occurred: close(); }
QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) { Q_UNUSED(mode) QList<QByteArray> devices; //enumerate device fullnames through directshow api CoInitialize(NULL); ICreateDevEnum *pDevEnum = NULL; IEnumMoniker *pEnum = NULL; // Create the System device enumerator HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, reinterpret_cast<void **>(&pDevEnum)); unsigned long iNumDevs = mode == QAudio::AudioOutput ? waveOutGetNumDevs() : waveInGetNumDevs(); if (SUCCEEDED(hr)) { // Create the enumerator for the audio input/output category if (pDevEnum->CreateClassEnumerator( mode == QAudio::AudioOutput ? CLSID_AudioRendererCategory : CLSID_AudioInputDeviceCategory, &pEnum, 0) == S_OK) { pEnum->Reset(); // go through and find all audio devices IMoniker *pMoniker = NULL; while (pEnum->Next(1, &pMoniker, NULL) == S_OK) { IPropertyBag *pPropBag; hr = pMoniker->BindToStorage(0,0,IID_IPropertyBag, reinterpret_cast<void **>(&pPropBag)); if (FAILED(hr)) { pMoniker->Release(); continue; // skip this one } // Find if it is a wave device VARIANT var; VariantInit(&var); hr = pPropBag->Read(mode == QAudio::AudioOutput ? L"WaveOutID" : L"WaveInID", &var, 0); if (SUCCEEDED(hr)) { LONG waveID = var.lVal; if (waveID >= 0 && waveID < LONG(iNumDevs)) { VariantClear(&var); // Find the description hr = pPropBag->Read(L"FriendlyName", &var, 0); if (SUCCEEDED(hr)) { QByteArray device; QDataStream ds(&device, QIODevice::WriteOnly); ds << quint32(waveID) << QString::fromWCharArray(var.bstrVal); devices.append(device); } } } pPropBag->Release(); pMoniker->Release(); } } } CoUninitialize(); return devices; }
static int winmm_enumerate_devices(cubeb * context, cubeb_device_type type, cubeb_device_collection ** collection) { UINT i, incount, outcount, total; cubeb_device_info * cur; outcount = waveOutGetNumDevs(); incount = waveInGetNumDevs(); total = outcount + incount; if (total > 0) { total -= 1; } *collection = malloc(sizeof(cubeb_device_collection) + sizeof(cubeb_device_info*) * total); (*collection)->count = 0; if (type & CUBEB_DEVICE_TYPE_OUTPUT) { WAVEOUTCAPSA woc; WAVEOUTCAPS2A woc2; ZeroMemory(&woc, sizeof(woc)); ZeroMemory(&woc2, sizeof(woc2)); for (i = 0; i < outcount; i++) { if ((waveOutGetDevCapsA(i, (LPWAVEOUTCAPSA)&woc2, sizeof(woc2)) == MMSYSERR_NOERROR && (cur = winmm_create_device_from_outcaps2(&woc2, i)) != NULL) || (waveOutGetDevCapsA(i, &woc, sizeof(woc)) == MMSYSERR_NOERROR && (cur = winmm_create_device_from_outcaps(&woc, i)) != NULL) ) { (*collection)->device[(*collection)->count++] = cur; } } } if (type & CUBEB_DEVICE_TYPE_INPUT) { WAVEINCAPSA wic; WAVEINCAPS2A wic2; ZeroMemory(&wic, sizeof(wic)); ZeroMemory(&wic2, sizeof(wic2)); for (i = 0; i < incount; i++) { if ((waveInGetDevCapsA(i, (LPWAVEINCAPSA)&wic2, sizeof(wic2)) == MMSYSERR_NOERROR && (cur = winmm_create_device_from_incaps2(&wic2, i)) != NULL) || (waveInGetDevCapsA(i, &wic, sizeof(wic)) == MMSYSERR_NOERROR && (cur = winmm_create_device_from_incaps(&wic, i)) != NULL) ) { (*collection)->device[(*collection)->count++] = cur; } } } return CUBEB_OK; }
void CWaveRecord::GetProductNames(CStringArray& strArrProductNames) { WAVEINCAPS caps; strArrProductNames.RemoveAll(); for(int i = 0; i < waveInGetNumDevs(); i++) { waveInGetDevCaps(i, &caps, sizeof(WAVEINCAPS)); strArrProductNames.Add(caps.szPname); } }
void Recorder::EnumDevs(EnumDevsProc lpProc) { WAVEINCAPS waveInCap; UINT count = waveInGetNumDevs(); for (int i = 0; i < count; i++) { UINT result = waveInGetDevCaps(i, &waveInCap, sizeof(waveInCap)); if (result == 0) { lpProc(i, waveInCap.szPname); } } }
//--------------------------------------------------------------------------- // サウンドカードの問い合わせ void __fastcall CWave::GetDevName(CString &as, int id) { if( (id == -1) && (waveInGetNumDevs() == 1) ){ id = 0; } WAVEINCAPS wic; if( !::waveInGetDevCaps(id, &wic, sizeof(wic)) ){ as = wic.szPname; } else { as = "Unknown device"; } }
//=========================================================================== void __fastcall Tform_Main::Setup_lb_WaveFormDevice() { combobox_SoundCard->Items->Clear(); combobox_SoundFreq->Items->Clear(); // ----- Количество ВАйфФОрм Устройств ------ for ( unsigned int i = 0; i < waveInGetNumDevs(); i++) { WAVEINCAPS wic; ZeroMemory(&wic, sizeof(wic)); waveInGetDevCaps(i, &wic, sizeof(wic)); combobox_SoundCard->Items->Add(wic.szPname); } }
void printInDevices() { unsigned int count = waveInGetNumDevs(); WAVEINCAPS caps; unsigned int i = 0; for (i = 0; i < count; i++) { if (waveInGetDevCaps(i, &caps, sizeof(caps)) == MMSYSERR_NOERROR) { fprintf(stderr, "%u: %s\r\n", i, caps.szPname); } else { fprintf(stderr, "Can't read devices\r\n"); exit(EXIT_FAILURE); } } }
/*------------------------------------------------------------------------------*/ static void WaveInInit( void ) { MMRESULT mmRes; WaveInNum = waveInGetNumDevs(); if ( WaveInNum >= WAVEINMAX ){ WaveInNum = WAVEINMAX-1; } for ( int i=0; i<WaveInNum; i++ ){ mmRes = waveInGetDevCaps( i, &WaveInCaps[i], sizeof(WAVEINCAPS) ); if ( mmRes != MMSYSERR_NOERROR ){ WaveInCaps[i].wChannels = 0; } } mmRes = waveInGetDevCaps( WAVE_MAPPER, &WaveInCaps[WAVEINMAX-1], sizeof(WAVEINCAPS) ); if ( mmRes != MMSYSERR_NOERROR ){ WaveInCaps[WAVEINMAX-1].wChannels = 0; } }
void WindowsAudioInputDevice::initializeIfNecessary() { if (ourAudioInputPorts != NULL) return; // we've already been initialized numAudioInputPorts = waveInGetNumDevs(); ourAudioInputPorts = new AudioInputPort[numAudioInputPorts]; // Initialize each audio input port for (unsigned i = 0; i < numAudioInputPorts; ++i) { AudioInputPort& port = ourAudioInputPorts[i]; port.index = i; port.open(); // to set the port name port.close(); } }
static int ww_init(void) { int err; play_dev_count = waveOutGetNumDevs(); DEBUG_INFO("ww_init: %d output devices found\n", play_dev_count); src_dev_count = waveInGetNumDevs(); DEBUG_INFO("ww_init: %d input devices found\n", src_dev_count); err = ausrc_register(&ausrc, "winwave", src_alloc); err |= auplay_register(&auplay, "winwave", play_alloc); return err; }
bool CAudioManager::Initialize() { if (!waveInGetNumDevs()) return false; // 正在使用中.. 防止重复使用 if (m_bIsWorking) return false; m_lpAudio = new CAudio; m_bIsWorking = true; return true; }
static void wave_in_tests(void) { WAVEINCAPSA capsA; WAVEINCAPSW capsW; WAVEFORMATEX format; HWAVEIN win; MMRESULT rc; UINT ndev,d; ndev=waveInGetNumDevs(); trace("found %d WaveIn devices\n",ndev); rc=waveInGetDevCapsA(ndev+1,&capsA,sizeof(capsA)); ok(rc==MMSYSERR_BADDEVICEID, "waveInGetDevCapsA(%s): MMSYSERR_BADDEVICEID expected, got %s\n", dev_name(ndev+1),wave_in_error(rc)); rc=waveInGetDevCapsA(WAVE_MAPPER,&capsA,sizeof(capsA)); ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_NODRIVER || (!ndev && (rc==MMSYSERR_BADDEVICEID)), "waveInGetDevCapsA(%s): got %s\n",dev_name(WAVE_MAPPER),wave_in_error(rc)); rc=waveInGetDevCapsW(ndev+1,&capsW,sizeof(capsW)); ok(rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NOTSUPPORTED, "waveInGetDevCapsW(%s): MMSYSERR_BADDEVICEID or MMSYSERR_NOTSUPPORTED " "expected, got %s\n",dev_name(ndev+1),wave_in_error(rc)); rc=waveInGetDevCapsW(WAVE_MAPPER,&capsW,sizeof(capsW)); ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_NODRIVER || rc==MMSYSERR_NOTSUPPORTED || (!ndev && (rc==MMSYSERR_BADDEVICEID)), "waveInGetDevCapsW(%s): got %s\n", dev_name(ndev+1),wave_in_error(rc)); format.wFormatTag=WAVE_FORMAT_PCM; format.nChannels=2; format.wBitsPerSample=16; format.nSamplesPerSec=44100; format.nBlockAlign=format.nChannels*format.wBitsPerSample/8; format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign; format.cbSize=0; rc=waveInOpen(&win,ndev+1,&format,0,0,CALLBACK_NULL); ok(rc==MMSYSERR_BADDEVICEID, "waveInOpen(%s): MMSYSERR_BADDEVICEID expected, got %s\n", dev_name(ndev+1),wave_in_error(rc)); for (d=0;d<ndev;d++) wave_in_test_device(d); if (ndev>0) wave_in_test_device(WAVE_MAPPER); }
static int ww_init(void) { int play_dev_count, src_dev_count; int err; play_dev_count = waveOutGetNumDevs(); src_dev_count = waveInGetNumDevs(); re_printf("winwave: output devices: %d, input devices: %d\n", play_dev_count, src_dev_count); err = ausrc_register(&ausrc, "winwave", winwave_src_alloc); err |= auplay_register(&auplay, "winwave", winwave_play_alloc); return err; }
void FillDevices() { WAVEINCAPS stWIC={0}; UINT nDevices=waveInGetNumDevs(); for(UINT nC1=0;nC1<nDevices;++nC1) { ZeroMemory(&stWIC,sizeof(WAVEINCAPS)); MMRESULT mRes=waveInGetDevCaps(nC1,&stWIC,sizeof(WAVEINCAPS)); if(mRes==0) LOG->Trace( stWIC.szPname ); else FAIL_M("bad"); } }
CDeviceManagerWaveIO::CDeviceManagerWaveIO() { muiNbOfDrivers_Outputs = waveOutGetNumDevs(); tuint32 ui; for (ui = 0; ui<muiNbOfDrivers_Outputs; ui++) { UINT uiDevID = ui; SMyWaveOutCaps* p = new SMyWaveOutCaps(); MMRESULT mmres = waveOutGetDevCaps((UINT_PTR)uiDevID, &(p->wocaps), sizeof(WAVEOUTCAPS)); if (mmres == MMSYSERR_NOERROR) { if (p->wocaps.dwFormats & WAVE_FORMAT_4S16) p->b44100 = TRUE; p->b48000 = CDeviceWaveIO::TestWaveOutCaps(&uiDevID, 48000); p->b88200 = CDeviceWaveIO::TestWaveOutCaps(&uiDevID, 88200); if (p->wocaps.dwFormats & WAVE_FORMAT_96S16) p->b96000 = TRUE; #ifdef _DEBUG tchar pszDevName[1024]; strcpy(pszDevName, p->wocaps.szPname); WORD wChannels = p->wocaps.wChannels; std::cout << "CDeviceManagerWaveIO::CDeviceManagerWaveIO() - Add device " << uiDevID << " = '" << pszDevName << "', " << wChannels << " channels.\n"; #endif _DEBUG } else { std::cerr << "CDeviceManagerWaveIO::CDeviceManagerWaveIO() - Unable to add device " << uiDevID << ".\n"; } mlistpMyWaveOutCaps.insert(mlistpMyWaveOutCaps.end(), p); } muiNbOfDrivers_Total = muiNbOfDrivers_Outputs + waveInGetNumDevs(); for (ui = muiNbOfDrivers_Outputs; ui < muiNbOfDrivers_Total; ui++) { UINT uiDevID = ui - muiNbOfDrivers_Outputs; SWaveInCaps* p = new SWaveInCaps(); MMRESULT mmres = waveInGetDevCaps((UINT_PTR)uiDevID, &(p->wicaps), sizeof(WAVEINCAPS)); if (mmres == MMSYSERR_NOERROR) { #ifdef _DEBUG tchar pszDevName[1024]; strcpy(pszDevName, p->wicaps.szPname); WORD wChannels = p->wicaps.wChannels; std::cout << "CDeviceManagerWaveIO::CDeviceManagerWaveIO() - Add device " << uiDevID << " = '" << pszDevName << "', " << wChannels << " channels.\n"; #endif _DEBUG } else { std::cerr << "CDeviceManagerWaveIO::CDeviceManagerWaveIO() - Unable to add device " << uiDevID << ".\n"; } mWaveInCaps.push_back(p); } } // constructor
tbool CDeviceWaveIO::LoadDriverInput(tint iIndex) { /* AbortCloseAndRelease(); mbDriverPseudoLoaded = FALSE; */ if ((iIndex < 0) || (iIndex >= (tint32)waveInGetNumDevs())) { return FALSE; } mbInput = true; mbOutput = false; muiDevIndex = (tuint32)iIndex; mbDriverPseudoLoaded = TRUE; return TRUE; } // LoadDriverInput
PLUGIN_FUNCTION_ARG3(GetDeviceName,unsigned,index, char *,buffer, unsigned,bufsize) { if (buffer == NULL || bufsize == 0) return PluginLID_InvalidParameter; if (m_hDLL== NULL) return PluginLID_InternalError; if (index > 0) return PluginLID_NoMoreNames; const char * searchName; switch (m_eProductID) { case TJIP_NONE : return PluginLID_NoSuchDevice; case TJIP_TJ560BPPG : case TJIP_TJ560BPPG_NO_EC : case TJIP_TJ560CPPG_NO_EC : case TJIP_TJ560BPPGPROSLIC : case TJIP_TJ560BPPGPROSLIC_NO_EC : searchName = "Personal PhoneGateway-USB"; break; case TJIP_TJ320PHONE : searchName = "PCI Internet Phone"; break; default : searchName = "USB Audio"; } for (UINT id = 0; id < waveInGetNumDevs(); id++) { WAVEINCAPS caps; if (waveInGetDevCaps(id, &caps, sizeof(caps)) == 0 && _strnicmp(caps.szPname, searchName, strlen(searchName)) == 0) { if (bufsize <= strlen(caps.szPname)) return PluginLID_BufferTooSmall; strcpy(buffer, caps.szPname); return PluginLID_NoError; } } return PluginLID_InternalError; }