/*------------------------------------------------------------------------------*/ static void WaveOutInit( void ) { MMRESULT mmRes; WaveOutNum = waveOutGetNumDevs(); if ( WaveOutNum >= WAVEOUTMAX ){ WaveOutNum = WAVEOUTMAX-1; } for ( int i=0; i<WaveOutNum; i++ ){ mmRes = waveOutGetDevCaps( i, &WaveOutCaps[i], sizeof(WAVEOUTCAPS) ); if ( mmRes != MMSYSERR_NOERROR ){ WaveOutCaps[i].wChannels = 0; } } mmRes = waveOutGetDevCaps( WAVE_MAPPER, &WaveOutCaps[WAVEOUTMAX-1], sizeof(WAVEOUTCAPS) ); if ( mmRes != MMSYSERR_NOERROR ){ WaveOutCaps[WAVEOUTMAX-1].wChannels = 0; } }
/*---------------------------------------------------------------------- | ProbeDevice +---------------------------------------------------------------------*/ static void ProbeDevice(unsigned int device_id, bool no_pcm) { printf("+++ Probing Device %d ++++++\n", device_id); WAVEOUTCAPS caps; MMRESULT result = waveOutGetDevCaps(device_id, &caps, sizeof(WAVEOUTCAPS)); wprintf(L"Name=%s\n", caps.szPname); printf("Manufacturer=%x, Product=%x, Version=%x\n", caps.wMid, caps.wPid, caps.vDriverVersion); printf("Channels=%d\n", caps.wChannels); printf("Flags: "); if (caps.dwSupport & WAVECAPS_VOLUME) printf("VOLUME "); if (caps.dwSupport & WAVECAPS_LRVOLUME) printf("LRVOLUME "); if (caps.dwSupport & WAVECAPS_PITCH) printf("PITCH "); if (caps.dwSupport & WAVECAPS_PLAYBACKRATE) printf("PLAYBACKRATE "); if (caps.dwSupport & WAVECAPS_SAMPLEACCURATE) printf("SAMPLEACCURATE "); printf("\n"); for (unsigned int f=0; f<sizeof(SampleFormats)/sizeof(SampleFormats[0]); f++) { if (no_pcm && SampleFormats[f].Data1 == 1) continue; for (unsigned int channel_count=1; channel_count<=8; channel_count++) { for (unsigned int sr=0; sr<sizeof(SampleRates)/sizeof(SampleRates[0]); sr++) { for (unsigned int bits_per_sample=8; bits_per_sample<=32; bits_per_sample += 8) { ProbeFormat(device_id, channel_count, SampleRates[sr], bits_per_sample, 0, SampleFormats[f]); } } } } printf("\n"); }
bool VolumeWaveOut::isSupported() const { WAVEOUTCAPS waveCaps; if(waveOutGetDevCaps(0,(LPWAVEOUTCAPS)&waveCaps, sizeof(WAVEOUTCAPS)) != MMSYSERR_NOERROR) return false; return (waveCaps.dwSupport & WAVECAPS_VOLUME) != 0; }
WAVEOUTCAPS* CViWavePlay::GetDeviceCap() { MMRESULT mRet = waveOutGetDevCaps(WAVE_MAPPER,&m_waveCaps,sizeof(m_waveCaps)); if( mRet == MMSYSERR_NOERROR ) return &m_waveCaps; return NULL; }
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; }
//--------------------------------------------------------------------------- // サウンドカードの名前を得る void __fastcall CWave::GetDeviceList(void) { m_InDevs = 0; m_OutDevs = 0; WAVEINCAPS incaps; for( int i = 0; i < AN(m_tInDevName); i++ ){ if( !waveInGetDevCaps(i, &incaps, sizeof(incaps)) ){ m_tInDevName[i] = incaps.szPname; m_InDevs = i + 1; } else { m_tInDevName[i] = ""; } } WAVEOUTCAPS outcaps; for( int i = 0; i < AN(m_tOutDevName); i++ ){ if( !waveOutGetDevCaps(i, &outcaps, sizeof(outcaps)) ){ m_tOutDevName[i] = outcaps.szPname; m_OutDevs = i + 1; } else { m_tOutDevName[i] = ""; } } }
int ao_wmm_set_option(ao_device *device, const char *key, const char *value) { ao_wmm_internal *internal = (ao_wmm_internal *) device->internal; int res = 0; if (!strcmp(key, "dev")) { if (!strcmp(value,"default")) { key = "id"; value = "0"; } else { WAVEOUTCAPS caps; int i, max = waveOutGetNumDevs(); adebug("searching for device %s among %d\n", value, max); for (i=0; i<max; ++i) { MMRESULT mmres = waveOutGetDevCaps(i, &caps, sizeof(caps)); if (mmres == MMSYSERR_NOERROR) { res = !strcmp(value, caps.szPname); adebug("checking id=%d, name='%s', ver=%d.%d => [%s]\n", i,caps.szPname,caps.vDriverVersion>>8,caps.vDriverVersion&255,res?"YES":"no"); if (res) { internal->id = i; internal->caps = caps; break; } } else { aerror("waveOutGetDevCaps(%d) => %s",i,mmerror(mmres)); } } goto finish; }
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 }
/* 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 MMS_Audio_Init() { MMRESULT status; LPWAVEOUTCAPS lpCaps; if( waveOutGetNumDevs() < 1 ) { fprintf(stderr,"Audio disabled - No Multimedia Services compatible audio devices available\n"); return; } /* Figure out device capabilities - Just use device 0 for now */ if((lpCaps = (LPWAVEOUTCAPS)mmeAllocMem(sizeof(WAVEOUTCAPS))) == NULL ) { fprintf(stderr,"Failed to allocate WAVEOUTCAPS struct\n"); return; } status = waveOutGetDevCaps( 0, lpCaps, sizeof(WAVEOUTCAPS)); if( status != MMSYSERR_NOERROR ) { fprintf(stderr,"waveOutGetDevCaps failed - status = %d\n", status); } mmeFreeMem(lpCaps); }
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)); } }
static UINT get_device_id(const char *device_name) { /* if device is not specified use wave mapper */ if (device_name == NULL) return WAVE_MAPPER; /* check for device id */ char *endptr; UINT id = strtoul(device_name, &endptr, 0); if (endptr > device_name && *endptr == 0) return id; /* check for device name */ for (UINT i = 0; i < waveOutGetNumDevs(); i++) { WAVEOUTCAPS caps; MMRESULT result = waveOutGetDevCaps(i, &caps, sizeof(caps)); if (result != MMSYSERR_NOERROR) continue; /* szPname is only 32 chars long, so it is often truncated. Use partial match to work around this. */ if (strstr(device_name, caps.szPname) == device_name) return i; } /* fallback to wave mapper */ return WAVE_MAPPER; }
PLUGIN_FUNCTION_ARG3(GetDeviceName,unsigned,index, char *,buffer, unsigned,bufsize) { if (buffer == NULL || bufsize < 4) return PluginLID_InvalidParameter; if (index >= 1) return PluginLID_NoMoreNames; if (StartDeviceDetection(NULL, 0, 0, 0, 0, 0, 0, 0, 0) == 0) return PluginLID_NoMoreNames; CloseDevice(); UINT numDevs = waveOutGetNumDevs(); for (UINT i = 0; i < numDevs; i++) { WAVEOUTCAPS caps; waveOutGetDevCaps(i, &caps, sizeof(caps)); if (strstr(caps.szPname, "USB Audio") != NULL) { if (bufsize <= strlen(caps.szPname)) return PluginLID_BufferTooSmall; int pos = strlen(caps.szPname)-1; while (caps.szPname[pos] == ' ') caps.szPname[pos--] = '\0'; strcpy(buffer, caps.szPname); return PluginLID_NoError; } } return PluginLID_NoMoreNames; }
void NativeSoundMix::GetNativeSoundCap( S32* format ) { // Check to capabilities of the waveform device WAVEOUTCAPS caps; waveOutGetDevCaps(WAVE_MAPPER, &caps, sizeof(caps)); // the desired format *format = sndStereo | snd16Bit | snd22K; // Check for sample rate support if ( (caps.dwFormats & WAVE_FORMAT_4M16) == 0 ) { *format = (*format & ~sndRateMask) | min(*format & sndRateMask, snd22K); } if ( (caps.dwFormats & WAVE_FORMAT_2M16) == 0 ) { *format = (*format & ~sndRateMask) | min(*format & sndRateMask, snd11K); } // Check to turn off stereo support if ( (caps.dwFormats & WAVE_FORMAT_2S16) == 0 ) *format &= ~sndStereo; // Check to turn off 16 bit sound if ( (caps.dwFormats & WAVE_FORMAT_2M16) == 0 ) *format &= ~snd16Bit; }
sspString sspWavOutDeviceGroup::getDeviceName(int nDevice) { WAVEOUTCAPS waveDevice; if (waveOutGetDevCaps(nDevice, (LPWAVEOUTCAPS) &waveDevice, sizeof(WAVEOUTCAPS)) == MMSYSERR_NOERROR) return waveDevice.szPname; else return _T(""); }
void load_sounds () { short i,t; HRSRC h; char snd_name[20]; WAVEOUTCAPS wavecaps; MMRESULT err; t = (short)waveOutGetNumDevs(); if (t == 0) { sounds_messed = TRUE; return; } err = waveOutGetDevCaps(0,&wavecaps,sizeof(WAVEOUTCAPS)); if (err != MMSYSERR_NOERROR) { sounds_messed = TRUE; switch (err) { case MMSYSERR_BADDEVICEID: MessageBox(mainPtr,"Cannot initialize sounds - No sound device detected. Game can still be played, but quietly.", "Sound Error",MB_OK | MB_ICONEXCLAMATION); return; case MMSYSERR_NODRIVER: MessageBox(mainPtr,"Cannot initialize sounds - No driver installed. Game can still be played, but quietly.", "Sound Error",MB_OK | MB_ICONEXCLAMATION); return; case MMSYSERR_NOMEM : MessageBox(mainPtr,"Cannot initialize sounds - can't find enough memory. Game can still be played, but quietly.", "Sound Error",MB_OK | MB_ICONEXCLAMATION); return; case MMSYSERR_ALLOCATED: MessageBox(mainPtr,"Cannot initialize sounds - sound card already allocated. Game can still be played, but quietly.", "Sound Error",MB_OK | MB_ICONEXCLAMATION); return; case MMSYSERR_ERROR: MessageBox(mainPtr,"Cannot initialize sounds - internal error. Game can still be played, but quietly.", "Sound Error",MB_OK | MB_ICONEXCLAMATION); return; default: MessageBox(mainPtr,"Cannot initialize sounds - unidentified error. Game can still be played, but quietly.", "Sound Error",MB_OK | MB_ICONEXCLAMATION); return; } } for (i = 0; i < NUM_SOUNDS; i++) { sound_handles[i] = NULL; load_when_play[i] = TRUE; if (load_when_play[i] == FALSE) { sprintf((char *)snd_name,"#%d",(int)(i + 1)); h = FindResource(store_hInstance,snd_name,"#100"); sound_handles[i] = LoadResource(store_hInstance,h); snds[i] = (char *) LockResource(sound_handles[i]); } } }
MMRESULT TinyWaveOut::GetDevCaps(UINT_PTR uDeviceID, LPWAVEOUTCAPS pwoc) { if (hWaveOut == NULL) return S_FALSE; MMRESULT hRes = waveOutGetDevCaps(uDeviceID, pwoc, sizeof(WAVEOUTCAPS)); if (hRes != MMSYSERR_NOERROR) { waveOutClose(hWaveOut); hWaveOut = NULL; } return hRes; }
void queryAudioDevices() { unsigned int count = waveOutGetNumDevs(); printf("%d wave output devices available.\n", count); for(unsigned int i=0; i<count; i++){ WAVEOUTCAPS caps; if(MMSYSERR_NOERROR == waveOutGetDevCaps(i, &caps, sizeof(WAVEOUTCAPS))){ printf("%d. %s\n", i, caps.szPname); }else{ printf("%d. Error retrieving caps.\n", i); } } }
UINT findWaveDeviceID() { WAVEOUTCAPS woc; UINT i, numDev; numDev = waveOutGetNumDevs(); for (i=0;i<numDev;i++) { if (!waveOutGetDevCaps(i, &woc, sizeof(WAVEOUTCAPS))) { if ((CompareString(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), NORM_IGNORECASE, woc.szPname, -1, TEXT("CMI8738/8768 Wave"), -1) == CSTR_EQUAL) || (CompareString(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), NORM_IGNORECASE, woc.szPname, -1, TEXT("Speakers (CMI8738/8768 Audio De"), -1) == CSTR_EQUAL)) { return i; } } } return WAVE_MAPPER; }
Boolean W95_Init(MADDriverRec *WinMADDriver) { MMRESULT err; PCMWAVEFORMAT wf; //long i; WinMADDriver->WIN95BUFFERSIZE = WinMADDriver->BufSize; WinMADDriver->WIN95BUFFERSIZE *= 2L; // double buffer system WinMADDriver->WIN95BUFFERSIZE *= MICROBUF; // multi internal buffer system WinMADDriver->MICROBUFState = 0; if (WinMADDriver->WIN95BUFFERSIZE < 0) return false; WinMADDriver->hglobal= GlobalAlloc(GMEM_FIXED, WinMADDriver->WIN95BUFFERSIZE); //GMEM_MOVEABLE | GMEM_SHARE if (WinMADDriver->hglobal == NULL) return false; WinMADDriver->mydata = GlobalLock(WinMADDriver->hglobal); /* get audio device name and put it into the driver structure: */ waveOutGetDevCaps(0, &WinMADDriver->woc, sizeof(WAVEOUTCAPS)); wf.wf.wFormatTag =WAVE_FORMAT_PCM; wf.wf.nChannels = 2; wf.wf.nSamplesPerSec = WinMADDriver->DriverSettings.outPutRate; wf.wBitsPerSample = WinMADDriver->DriverSettings.outPutBits; wf.wf.nBlockAlign = wf.wf.nChannels * (wf.wBitsPerSample/8); wf.wf.nAvgBytesPerSec = wf.wf.nSamplesPerSec * wf.wf.nBlockAlign; err = waveOutOpen(&WinMADDriver->hWaveOut, 0, (LPCWAVEFORMATEX)&wf, (unsigned long) 0, (unsigned long) NULL, 0L); if(err) { if(err==WAVERR_BADFORMAT) myerr="This output format is not supported (Try another sampling rate?)"; else if(err==MMSYSERR_ALLOCATED) myerr="Audio device already in use"; else myerr="Can't open audio device"; GlobalUnlock(WinMADDriver->hglobal); GlobalFree(WinMADDriver->hglobal); return false; } W95_PlayStart(WinMADDriver); return true; }
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
static void sink_get_volume_cb(pa_sink *s) { struct userdata *u = s->userdata; WAVEOUTCAPS caps; DWORD vol; pa_volume_t left, right; if (waveOutGetDevCaps(u->hwo, &caps, sizeof(caps)) != MMSYSERR_NOERROR) return; if (!(caps.dwSupport & WAVECAPS_VOLUME)) return; if (waveOutGetVolume(u->hwo, &vol) != MMSYSERR_NOERROR) return; left = PA_CLAMP_VOLUME((vol & 0xFFFF) * PA_VOLUME_NORM / WAVEOUT_MAX_VOLUME); if (caps.dwSupport & WAVECAPS_LRVOLUME) right = PA_CLAMP_VOLUME(((vol >> 16) & 0xFFFF) * PA_VOLUME_NORM / WAVEOUT_MAX_VOLUME); else
string CSoundChannel::m_sGetDefaultDevice(EDIRECTIONS eDir) { string strDevName; if(eDir == e_Player) { WAVEOUTCAPS capTmp; if(waveOutGetDevCaps(0, &capTmp, sizeof(capTmp)) == 0) strDevName = capTmp.szPname; } else { WAVEINCAPS capTmp; if(waveInGetDevCaps(0, &capTmp, sizeof(capTmp)) == 0) strDevName = capTmp.szPname; } return strDevName; }
/* * Find a suitable device - either input or output. Returns * 0xFFFF if none */ UINT FindDevice(BOOL Input) { UINT NumDev; UINT Device; NumDev = (Input ? waveInGetNumDevs() : waveOutGetNumDevs()); for (Device = 0; Device < NumDev; Device++) { if (Input) { WAVEINCAPS wc; if (MMSYSERR_NOERROR == waveInGetDevCaps(Device, &wc, sizeof(wc))) { /* * Need 11025 for input */ if (wc.dwFormats & WAVE_FORMAT_1M08) { return Device; } } } else { /* Output */ WAVEOUTCAPS wc; if (MMSYSERR_NOERROR == waveOutGetDevCaps(Device, &wc, sizeof(wc))) { /* * Need 11025 and 22050 for output */ if ((wc.dwFormats & (WAVE_FORMAT_1M08 | WAVE_FORMAT_2M08)) == (WAVE_FORMAT_1M08 | WAVE_FORMAT_2M08)) { return Device; } } } } return NO_DEVICE_FOUND; }
static unsigned int find_dev(const char *name) { WAVEOUTCAPS wic; unsigned int i, nInDevices = waveOutGetNumDevs(); if (!str_isset(name)) return WAVE_MAPPER; for (i=0; i<nInDevices; i++) { if (waveOutGetDevCaps(i, &wic, sizeof(WAVEOUTCAPS))==MMSYSERR_NOERROR) { if (0 == str_cmp(name, wic.szPname)) { return i; } } } return WAVE_MAPPER; }
static void GetSoundDriverDebugInfo() { int cnt = waveOutGetNumDevs(); for(int i = 0; i < cnt; ++i) { WAVEOUTCAPS caps; MMRESULT ret = waveOutGetDevCaps(i, &caps, sizeof(caps)); if(ret != MMSYSERR_NOERROR) { LOG->Info(wo_ssprintf(ret, "waveOutGetDevCaps(%i) failed", i)); continue; } LOG->Info("Sound device %i: %s, %i.%i, MID %i, PID %i %s", i, caps.szPname, HIBYTE(caps.vDriverVersion), LOBYTE(caps.vDriverVersion), caps.wMid, caps.wPid, caps.dwSupport & WAVECAPS_SAMPLEACCURATE? "":"(INACCURATE)"); } }
static bool get_device_id(const char *device_name, UINT *device_id, GError **error_r) { /* if device is not specified use wave mapper */ if (device_name == NULL) { *device_id = WAVE_MAPPER; return true; } UINT numdevs = waveOutGetNumDevs(); /* check for device id */ char *endptr; UINT id = strtoul(device_name, &endptr, 0); if (endptr > device_name && *endptr == 0) { if (id >= numdevs) goto fail; *device_id = id; return true; } /* check for device name */ for (UINT i = 0; i < numdevs; i++) { WAVEOUTCAPS caps; MMRESULT result = waveOutGetDevCaps(i, &caps, sizeof(caps)); if (result != MMSYSERR_NOERROR) continue; /* szPname is only 32 chars long, so it is often truncated. Use partial match to work around this. */ if (strstr(device_name, caps.szPname) == device_name) { *device_id = i; return true; } } fail: g_set_error(error_r, winmm_output_quark(), 0, "device \"%s\" is not found", device_name); return false; }
static void winsndcard_detect(MSSndCardManager *m){ MMRESULT mr = NOERROR; unsigned int nOutDevices = waveOutGetNumDevs (); unsigned int nInDevices = waveInGetNumDevs (); unsigned int item; if (nOutDevices>nInDevices) nInDevices = nOutDevices; for (item = 0; item < nInDevices; item++){ WAVEINCAPS incaps; WAVEOUTCAPS outcaps; mr = waveInGetDevCaps (item, &incaps, sizeof (WAVEINCAPS)); if (mr == MMSYSERR_NOERROR) { #if defined(_WIN32_WCE) char card[256]; snprintf(card, sizeof(card), "Input card %i", item); add_or_update_card(m,card,item,-1,MS_SND_CARD_CAP_CAPTURE); /* _tprintf(L"new card: %s", incaps.szPname); */ #else add_or_update_card(m,incaps.szPname,item,-1,MS_SND_CARD_CAP_CAPTURE); #endif } mr = waveOutGetDevCaps (item, &outcaps, sizeof (WAVEOUTCAPS)); if (mr == MMSYSERR_NOERROR) { #if defined(_WIN32_WCE) char card[256]; snprintf(card, sizeof(card), "Output card %i", item); add_or_update_card(m,card,-1,item,MS_SND_CARD_CAP_PLAYBACK); /* _tprintf(L"new card: %s", outcaps.szPname); */ #else add_or_update_card(m,outcaps.szPname,-1,item,MS_SND_CARD_CAP_PLAYBACK); #endif } } }
static int winmm_get_preferred_sample_rate(cubeb * ctx, uint32_t * rate) { WAVEOUTCAPS woc; MMRESULT r; r = waveOutGetDevCaps(WAVE_MAPPER, &woc, sizeof(WAVEOUTCAPS)); if (r != MMSYSERR_NOERROR) { return CUBEB_ERROR; } /* Check if we support 48kHz, but not 44.1kHz. */ if (!(woc.dwFormats & WAVE_FORMAT_4S16) && woc.dwFormats & WAVE_FORMAT_48S16) { *rate = 48000; return CUBEB_OK; } /* Prefer 44.1kHz between 44.1kHz and 48kHz. */ *rate = 44100; return CUBEB_OK; }
void showWaveDeviceCaps() { UINT numDevs; int i; WAVEOUTCAPS cap; numDevs = waveOutGetNumDevs(); printf_s("NumDevs:%d\n",numDevs); for(i=0 ; i < numDevs ; i++) { waveOutGetDevCaps(i,&cap,sizeof(cap)); printf_s("id:%d,Mid:%d,wPid:%d,DriverVersion:%x,ProductName:%s,Formats:%x,Channels:%d,dwSupport:%x\n" ,i ,cap.wMid,cap.wPid ,cap.vDriverVersion ,cap.szPname ,cap.dwFormats ,cap.wChannels ,cap.dwSupport); } }