mirror of
https://github.com/cookiengineer/audacity
synced 2025-04-30 07:39:42 +02:00
Temporary workaround to provide (only) WASAPI loopback input devices.
This commit is contained in:
parent
d63709908a
commit
96afea6e4b
@ -263,6 +263,16 @@ int PaWasapi_GetDeviceDefaultFormat( void *pFormat, unsigned int nFormatSize, Pa
|
||||
int/*PaWasapiDeviceRole*/ PaWasapi_GetDeviceRole( PaDeviceIndex nDevice );
|
||||
|
||||
|
||||
/** Returns device loopback indicator.
|
||||
|
||||
@param nDevice device index.
|
||||
|
||||
@return 0 = Not loopback, 1 = loopback, < 0 = PaErrorCode
|
||||
if PortAudio is not initialized or an error is encountered.
|
||||
*/
|
||||
int PaWasapi_IsLoopback( PaDeviceIndex nDevice );
|
||||
|
||||
|
||||
/** Boost thread priority of calling thread (MMCSS). Use it for Blocking Interface only for thread
|
||||
which makes calls to Pa_WriteStream/Pa_ReadStream.
|
||||
|
||||
|
@ -357,6 +357,9 @@ typedef struct PaWasapiDeviceInfo
|
||||
|
||||
// Formfactor
|
||||
EndpointFormFactor formFactor;
|
||||
|
||||
// Loopback indicator
|
||||
int loopBack;
|
||||
}
|
||||
PaWasapiDeviceInfo;
|
||||
|
||||
@ -1403,6 +1406,8 @@ PaError PaWasapi_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInd
|
||||
memcpy(&paWasapi->devInfo[i + 1], &paWasapi->devInfo[i], sizeof(*paWasapi->devInfo));
|
||||
|
||||
i++;
|
||||
paWasapi->devInfo[i].loopBack = 1;
|
||||
|
||||
deviceInfo = &deviceInfoArray[i];
|
||||
|
||||
deviceInfo->maxInputChannels = deviceInfo->maxOutputChannels;
|
||||
@ -1579,6 +1584,29 @@ int PaWasapi_GetDeviceRole( PaDeviceIndex nDevice )
|
||||
return paWasapi->devInfo[ index ].formFactor;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
int PaWasapi_IsLoopback( PaDeviceIndex nDevice )
|
||||
{
|
||||
PaError ret;
|
||||
PaDeviceIndex index;
|
||||
|
||||
// Get API
|
||||
PaWasapiHostApiRepresentation *paWasapi = _GetHostApi(&ret);
|
||||
if (paWasapi == NULL)
|
||||
return paNotInitialized;
|
||||
|
||||
// Get device index
|
||||
ret = PaUtil_DeviceIndexToHostApiDeviceIndex(&index, nDevice, &paWasapi->inheritedHostApiRep);
|
||||
if (ret != paNoError)
|
||||
return ret;
|
||||
|
||||
// Validate index
|
||||
if ((UINT32)index >= paWasapi->deviceCount)
|
||||
return paInvalidDevice;
|
||||
|
||||
return paWasapi->devInfo[ index ].loopBack;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
PaError PaWasapi_GetFramesPerHostBuffer( PaStream *pStream, unsigned int *nInput, unsigned int *nOutput )
|
||||
{
|
||||
|
@ -7,6 +7,10 @@
|
||||
******************************************************************/
|
||||
|
||||
#include "portaudio.h"
|
||||
#ifdef __WXMSW__
|
||||
#include "pa_win_wasapi.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_PORTMIXER
|
||||
#include "portmixer.h"
|
||||
#endif
|
||||
@ -281,6 +285,10 @@ void DeviceManager::Rescan()
|
||||
}
|
||||
|
||||
if (info->maxInputChannels > 0) {
|
||||
#ifdef __WXMSW__
|
||||
if (Pa_GetHostApiInfo(info->hostApi)->type != paWASAPI ||
|
||||
PaWasapi_IsLoopback(i) > 0)
|
||||
#endif
|
||||
AddSources(i, info->defaultSampleRate, &mInputDeviceSourceMaps, 1);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user