static bool get_idx_playback_from_name(int *idx, const char *name) { int i; WAVEOUTCAPSA wa_device; if (!waveOutGetNumDevs()) { return false; } for (i = 0; i < waveOutGetNumDevs(); i++) { memset(&wa_device, 0, sizeof(wa_device)); if (waveOutGetDevCapsA(i, &wa_device, sizeof(wa_device)) == 0) { if (!strcmp(wa_device.szPname, name)) { *idx = i; return true; } } } return false; }
static bool set_tux_as_default_playback(void) { int i; WAVEOUTCAPSA wa_device; if (!waveOutGetNumDevs()) { return false; } for (i = 0; i < waveOutGetNumDevs(); i++) { memset(&wa_device, 0, sizeof(wa_device)); if (waveOutGetDevCapsA(i, &wa_device, sizeof(wa_device)) == 0) { if (strstr(wa_device.szPname, "TuxDroid-Audio") != NULL) { if (waveOutMessage((HWAVEOUT)WAVE_MAPPER, DRVM_MAPPER_PREFERRED_SET, i, 0) == 0) { return true; } } } } return false; }
BOOL WINAPI DllMain( HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved) { switch (fdwReason) { case DLL_PROCESS_ATTACH: dsound_hInstance = hInstDLL; #if 1 DPRINT("NumDevs %u\n", waveOutGetNumDevs()); if (EnumAudioDeviceInterfaces(&RootInfo) != S_OK) { DPRINT("EnumAudioDeviceInterfaces failed\n"); RootInfo = NULL; } DPRINT1("EnumAudioDeviceInterfaces %p %u\n", RootInfo, waveOutGetNumDevs()); #endif DisableThreadLibraryCalls(dsound_hInstance); break; default: break; } return TRUE; }
bool MediaObject::getWaveOutDevice() { deleteValidWaveOutDevice(); for(UINT deviceId = 0; deviceId < waveOutGetNumDevs(); deviceId++) { if(deviceId == waveOutGetNumDevs()) return false; if(waveOutOpen(&m_hWaveOut, WAVE_MAPPER, &m_waveFormatEx, (DWORD)WaveOutCallBack, 0, CALLBACK_FUNCTION) == MMSYSERR_NOERROR) return m_hWaveOut; //m_hWaveOut !=0; } return false; }
s32 Test() const { if (waveOutGetNumDevs() == 0) { SysMessage("No waveOut Devices Present\n"); return -1; } return 0; }
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 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)); } }
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; }
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; }
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; }
bool CAudio::InitializeWaveOut() { if (!waveOutGetNumDevs()) return false; for (int i = 0; i < 2; i++) memset(m_lpOutAudioData[i], 0, m_nBufferLength); MMRESULT mmResult; mmResult = waveOutOpen(&m_hWaveOut, (WORD)WAVE_MAPPER, &(m_GSMWavefmt.wfx), (LONG)0, (LONG)0, CALLBACK_NULL); if (mmResult != MMSYSERR_NOERROR) return false; for (int i = 0; i < 2; i++) { m_lpOutAudioHdr[i]->lpData = (LPSTR)m_lpOutAudioData[i]; m_lpOutAudioHdr[i]->dwBufferLength = m_nBufferLength; m_lpOutAudioHdr[i]->dwFlags = 0; m_lpOutAudioHdr[i]->dwLoops = 0; waveOutPrepareHeader(m_hWaveOut, m_lpOutAudioHdr[i], sizeof(WAVEHDR)); } m_bIsWaveOutUsed = true; return true; }
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 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); }
/* 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); } }
/*************************************************************************** * DirectSoundEnumerateW [DSOUND.3] * * Enumerate all DirectSound drivers installed in the system * * PARAMS * lpDSEnumCallback [I] Address of callback function. * lpContext [I] Address of user defined context passed to callback function. * * RETURNS * Success: DS_OK * Failure: DSERR_INVALIDPARAM */ HRESULT WINAPI DirectSoundEnumerateW( LPDSENUMCALLBACKW lpDSEnumCallback, LPVOID lpContext ) { unsigned devs, wod; DSDRIVERDESC desc; GUID guid; int err; WCHAR wDesc[MAXPNAMELEN]; WCHAR wName[MAXPNAMELEN]; TRACE("lpDSEnumCallback = %p, lpContext = %p\n", lpDSEnumCallback, lpContext); if (lpDSEnumCallback == NULL) { WARN("invalid parameter: lpDSEnumCallback == NULL\n"); return DSERR_INVALIDPARAM; } setup_dsound_options(); devs = waveOutGetNumDevs(); if (devs > 0) { if (GetDeviceID(&DSDEVID_DefaultPlayback, &guid) == DS_OK) { static const WCHAR empty[] = { 0 }; for (wod = 0; wod < devs; ++wod) { if (IsEqualGUID( &guid, &DSOUND_renderer_guids[wod] ) ) { err = mmErr(waveOutMessage(UlongToHandle(wod),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,ds_hw_accel)); if (err == DS_OK) { TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n", "Primary Sound Driver",desc.szDrvname,lpContext); MultiByteToWideChar( CP_ACP, 0, "Primary Sound Driver", -1, wDesc, sizeof(wDesc)/sizeof(WCHAR) ); if (lpDSEnumCallback(NULL, wDesc, empty, lpContext) == FALSE) return DS_OK; } } } } } for (wod = 0; wod < devs; ++wod) { err = mmErr(waveOutMessage(UlongToHandle(wod),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,ds_hw_accel)); if (err == DS_OK) { TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n", debugstr_guid(&DSOUND_renderer_guids[wod]),desc.szDesc,desc.szDrvname,lpContext); MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDesc, sizeof(wDesc)/sizeof(WCHAR) ); wDesc[(sizeof(wDesc)/sizeof(WCHAR)) - 1] = '\0'; MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wName, sizeof(wName)/sizeof(WCHAR) ); wName[(sizeof(wName)/sizeof(WCHAR)) - 1] = '\0'; if (lpDSEnumCallback(&DSOUND_renderer_guids[wod], wDesc, wName, lpContext) == FALSE) return DS_OK; } } return DS_OK; }
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; }
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]); } } }
tbool CDeviceWaveIO::LoadDriver(tint iIndex, tbool bEnableInput, tbool bEnableOutput) { AbortCloseAndRelease(); mbDriverPseudoLoaded = FALSE; mbInput = false; if (iIndex == -1) { tuint32 uiDev = WAVE_MAPPER; // Can only be either output or input mbInput = (bEnableInput && !bEnableOutput); if (mbInput) { WAVEINCAPS caps; MMRESULT mmres = waveInGetDevCaps(WAVE_MAPPER, &caps, sizeof(caps)); if (mmres != MMSYSERR_NOERROR) return false; miChannelsIn = caps.wChannels; } else { // We must query for default wave-out device if (!TestWaveOutCaps(&uiDev, 44100)) return FALSE; iIndex = (tint32)uiDev; } } else { if (iIndex < 0) return false; if (iIndex >= (tint32)waveOutGetNumDevs()) { // Load input device tbool bSuccess = LoadDriverInput(iIndex - waveOutGetNumDevs()); if (!bSuccess) return false; WAVEINCAPS caps; MMRESULT mmres = waveInGetDevCaps(WAVE_MAPPER, &caps, sizeof(caps)); if (mmres != MMSYSERR_NOERROR) return false; miChannelsIn = caps.wChannels; mbInput = (bEnableInput && (miChannelsIn > 0)); } } muiDevIndex = (tuint32)iIndex; mbDriverPseudoLoaded = TRUE; mbOutput = bEnableOutput; return (mbInput || mbOutput); } // LoadDriver
int audio_open(struct audio_info_struct *ai) { MMRESULT res; WAVEFORMATEX outFormatex; if(ai->rate == -1) return(0); if(!waveOutGetNumDevs()) { MessageBox(NULL, "No audio devices present!", "Error...", MB_OK); return -1; } outFormatex.wFormatTag = WAVE_FORMAT_PCM; outFormatex.wBitsPerSample = 16; outFormatex.nChannels = 2; outFormatex.nSamplesPerSec = ai->rate; outFormatex.nAvgBytesPerSec = outFormatex.nSamplesPerSec * outFormatex.nChannels * outFormatex.wBitsPerSample/8; outFormatex.nBlockAlign = outFormatex.nChannels * outFormatex.wBitsPerSample/8; res = waveOutOpen(&dev, (UINT)ai->device, &outFormatex, (DWORD)wave_callback, 0, CALLBACK_FUNCTION); if(res != MMSYSERR_NOERROR) { switch(res) { case MMSYSERR_ALLOCATED: MessageBox(NULL, "Device Is Already Open", "Error...", MB_OK); break; case MMSYSERR_BADDEVICEID: MessageBox(NULL, "The Specified Device Is out of range", "Error...", MB_OK); break; case MMSYSERR_NODRIVER: MessageBox(NULL, "There is no audio driver in this system.", "Error...", MB_OK); break; case MMSYSERR_NOMEM: MessageBox(NULL, "Unable to allocate sound memory.", "Error...", MB_OK); break; case WAVERR_BADFORMAT: MessageBox(NULL, "This audio format is not supported.", "Error...", MB_OK); break; case WAVERR_SYNC: MessageBox(NULL, "The device is synchronous.", "Error...", MB_OK); break; default: MessageBox(NULL, "Unknown Media Error", "Error...", MB_OK); break; } return -1; } waveOutReset(dev); InitializeCriticalSection(&cs); return 0; }
void CWave::InitVars( void ) { m_bLoaded = FALSE; m_lpSoundData = NULL; m_hResHandle = NULL; m_nDevices = waveOutGetNumDevs(); }
static int open_output (void) { int i, j, mono, eight_bit, warnings = 0; PCMWAVEFORMAT pcm; MMRESULT res; /* Check if there is at least one audio device */ if (!waveOutGetNumDevs ()) { fprintf(stderr, "No audio devices present!"); return -1; } /* They can't mean these */ dpm.encoding &= ~(PE_ULAW|PE_BYTESWAP); if (dpm.encoding & PE_16BIT) dpm.encoding |= PE_SIGNED; else dpm.encoding &= ~PE_SIGNED; mono = (dpm.encoding & PE_MONO); eight_bit = !(dpm.encoding & PE_16BIT); pcm.wf.wFormatTag = WAVE_FORMAT_PCM; pcm.wf.nChannels = mono ? 1 : 2; pcm.wf.nSamplesPerSec = i = dpm.rate; j = 1; if (!mono) { i *= 2; j *= 2; } if (!eight_bit) { i *= 2; j *= 2; } pcm.wf.nAvgBytesPerSec = i; pcm.wf.nBlockAlign = j; pcm.wBitsPerSample = eight_bit ? 8 : 16; res = waveOutOpen (NULL, 0, (LPWAVEFORMAT)&pcm, NULL, 0, WAVE_FORMAT_QUERY); if (res) { fprintf(stderr, "Format not supported!\n"); return -1; } res = waveOutOpen (&dev, 0, (LPWAVEFORMAT)&pcm, (DWORD)wave_callback, 0, CALLBACK_FUNCTION); if (res) { fprintf(stderr, "Can't open audio device"); return -1; } nBlocks = 0; return warnings; }
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; }
int setup_sound(void) { if (waveOutGetNumDevs() < 1) { have_sound = 0; return 0; } have_sound = 1; sound_available = 1; return 1; }
static int init(struct xmp_context *ctx) { struct xmp_options *o = &ctx->o; MMRESULT res; WAVEFORMATEX wfe; int i; char *token, **parm; num_buffers = 10; parm_init(); chkparm1("buffers", num_buffers = strtoul(token, NULL, 0)); parm_end(); if (num_buffers > MAXBUFFERS) num_buffers = MAXBUFFERS; if (!waveOutGetNumDevs()) return XMP_ERR_DINIT; wfe.wFormatTag = WAVE_FORMAT_PCM; wfe.wBitsPerSample = o->resol; wfe.nChannels = o->flags & XMP_FMT_MONO ? 1 : 2; wfe.nSamplesPerSec = o->freq; wfe.nAvgBytesPerSec = wfe.nSamplesPerSec * wfe.nChannels * wfe.wBitsPerSample / 8; wfe.nBlockAlign = wfe.nChannels * wfe.wBitsPerSample / 8; res = waveOutOpen(&hwaveout, WAVE_MAPPER, &wfe, (DWORD) wave_callback, 0, CALLBACK_FUNCTION); if (res != MMSYSERR_NOERROR) { show_error(res); return XMP_ERR_DINIT; } waveOutReset(hwaveout); for (i = 0; i < num_buffers; i++) { buffer[i] = malloc(OUT_MAXLEN); header[i].lpData = buffer[i]; if (!buffer[i] || res != MMSYSERR_NOERROR) { show_error(res); return XMP_ERR_DINIT; } } freebuffer = nextbuffer = 0; return xmp_smix_on(ctx); }
/*------------------------------------------------------------------------------*/ 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; } }
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); } } }
bool OutputWaveOut::initialize() { #ifdef WIN32 if (!waveOutGetNumDevs ()) { qWarning("OutputWaveOut: no audio device found"); return FALSE; } return TRUE; #else return FALSE; #endif }
static std::string show_waveout_devices( std::ostream & /*log*/ ) { std::ostringstream devices; devices << " waveout:" << std::endl; for ( UINT i = 0; i < waveOutGetNumDevs(); ++i ) { devices << " " << i << ": "; WAVEOUTCAPSW caps; ZeroMemory( &caps, sizeof( caps ) ); waveOutGetDevCapsW( i, &caps, sizeof( caps ) ); devices << wstring_to_utf8( caps.szPname ); devices << std::endl; } return devices.str(); }
bool OutputWaveOut::initialize(quint32 freq, ChannelMap map, Qmmp::AudioFormat format) { Q_UNUSED(format); if (!waveOutGetNumDevs ()) { qWarning("OutputWaveOut: no audio device found"); return false; } WAVEFORMATEX fmt; UINT deviceID = WAVE_MAPPER; fmt.wFormatTag = WAVE_FORMAT_PCM; fmt.wBitsPerSample = 16; fmt.nChannels = map.count(); fmt.nSamplesPerSec = (unsigned long)(freq); fmt.nBlockAlign = fmt.nChannels * fmt.wBitsPerSample/8; fmt.nAvgBytesPerSec = fmt.nSamplesPerSec * fmt.nChannels * fmt.wBitsPerSample/8; switch (waveOutOpen (&dev, deviceID, &fmt, (DWORD)wave_callback, 0, CALLBACK_FUNCTION)) { case MMSYSERR_ALLOCATED: qWarning("OutputWaveOut: Device is already open."); return false; case MMSYSERR_BADDEVICEID: qWarning("OutputWaveOut: The specified device is out of range."); return false; case MMSYSERR_NODRIVER: qWarning("OutputWaveOut: There is no audio driver in this system."); return false; case MMSYSERR_NOMEM: qWarning("OutputWaveOut: Unable to allocate sound memory."); return false; case WAVERR_BADFORMAT: qWarning("OutputWaveOut: This audio format is not supported."); return false; case WAVERR_SYNC: qWarning("OutputWaveOut: The device is synchronous."); return false; default: qWarning("OutputWaveOut: Unknown media error."); return false; case MMSYSERR_NOERROR: break; } waveOutReset (dev); InitializeCriticalSection (&cs); configure(freq, map, Qmmp::PCM_S16LE); return true; }
/*---------------------------------------------------------------------- | main +---------------------------------------------------------------------*/ int main(int argc, char** argv) { bool no_pcm = false; if (argc >= 2 && !strcmp(argv[1], "--no-pcm")) no_pcm = true; printf("------- Win32 Soundcard Probe ------ built " __DATE__ "\n"); unsigned int num_devs = waveOutGetNumDevs(); printf("Found %d devices\n", num_devs); for (unsigned int i=0; i<num_devs; i++) { ProbeDevice(i, no_pcm); } }