1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-04-30 15:49:41 +02:00

Temporary workaround to provide (only) WASAPI loopback input devices.

This commit is contained in:
lllucius 2013-08-30 04:17:02 +00:00
parent d63709908a
commit 96afea6e4b
3 changed files with 46 additions and 0 deletions

View File

@ -263,6 +263,16 @@ int PaWasapi_GetDeviceDefaultFormat( void *pFormat, unsigned int nFormatSize, Pa
int/*PaWasapiDeviceRole*/ PaWasapi_GetDeviceRole( PaDeviceIndex nDevice ); 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 /** Boost thread priority of calling thread (MMCSS). Use it for Blocking Interface only for thread
which makes calls to Pa_WriteStream/Pa_ReadStream. which makes calls to Pa_WriteStream/Pa_ReadStream.

View File

@ -357,6 +357,9 @@ typedef struct PaWasapiDeviceInfo
// Formfactor // Formfactor
EndpointFormFactor formFactor; EndpointFormFactor formFactor;
// Loopback indicator
int loopBack;
} }
PaWasapiDeviceInfo; PaWasapiDeviceInfo;
@ -1403,6 +1406,8 @@ PaError PaWasapi_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInd
memcpy(&paWasapi->devInfo[i + 1], &paWasapi->devInfo[i], sizeof(*paWasapi->devInfo)); memcpy(&paWasapi->devInfo[i + 1], &paWasapi->devInfo[i], sizeof(*paWasapi->devInfo));
i++; i++;
paWasapi->devInfo[i].loopBack = 1;
deviceInfo = &deviceInfoArray[i]; deviceInfo = &deviceInfoArray[i];
deviceInfo->maxInputChannels = deviceInfo->maxOutputChannels; deviceInfo->maxInputChannels = deviceInfo->maxOutputChannels;
@ -1579,6 +1584,29 @@ int PaWasapi_GetDeviceRole( PaDeviceIndex nDevice )
return paWasapi->devInfo[ index ].formFactor; 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 ) PaError PaWasapi_GetFramesPerHostBuffer( PaStream *pStream, unsigned int *nInput, unsigned int *nOutput )
{ {

View File

@ -7,6 +7,10 @@
******************************************************************/ ******************************************************************/
#include "portaudio.h" #include "portaudio.h"
#ifdef __WXMSW__
#include "pa_win_wasapi.h"
#endif
#ifdef USE_PORTMIXER #ifdef USE_PORTMIXER
#include "portmixer.h" #include "portmixer.h"
#endif #endif
@ -281,6 +285,10 @@ void DeviceManager::Rescan()
} }
if (info->maxInputChannels > 0) { if (info->maxInputChannels > 0) {
#ifdef __WXMSW__
if (Pa_GetHostApiInfo(info->hostApi)->type != paWASAPI ||
PaWasapi_IsLoopback(i) > 0)
#endif
AddSources(i, info->defaultSampleRate, &mInputDeviceSourceMaps, 1); AddSources(i, info->defaultSampleRate, &mInputDeviceSourceMaps, 1);
} }
} }