From: dmitrykos Date: Thu, 26 Mar 2020 18:50:52 +0000 (+0200) Subject: alsa: Introduce possibility to ignore all ALSA plugin devices by setting the environm... X-Git-Tag: v19.7.0~100^2 X-Git-Url: https://andrewgundersen.net/repos?a=commitdiff_plain;h=6bb858643b55834b12664401e9df7fe1899a20ef;p=portaudio alsa: Introduce possibility to ignore all ALSA plugin devices by setting the environment variable PA_ALSA_IGNORE_ALL_PLUGINS to non-0. Fixed logic of guarding assertion in BuildDeviceList() when only one or none PCM device is available (may occur if PA_ALSA_IGNORE_ALL_PLUGINS is set to non-0 or when device has no any audio device available, including plugin devices). --- diff --git a/src/hostapi/alsa/pa_linux_alsa.c b/src/hostapi/alsa/pa_linux_alsa.c index 584cde8..c92f9aa 100644 --- a/src/hostapi/alsa/pa_linux_alsa.c +++ b/src/hostapi/alsa/pa_linux_alsa.c @@ -1066,6 +1066,10 @@ static int IgnorePlugin( const char *pluginId ) static const char *ignoredPlugins[] = {"hw", "plughw", "plug", "dsnoop", "tee", "file", "null", "shm", "cards", "rate_convert", NULL}; int i = 0; + + if( getenv( "PA_ALSA_IGNORE_ALL_PLUGINS" ) && atoi( getenv( "PA_ALSA_IGNORE_ALL_PLUGINS") ) ) + return 1; + while( ignoredPlugins[i] ) { if( !strcmp( pluginId, ignoredPlugins[i] ) ) @@ -1327,6 +1331,8 @@ static PaError BuildDeviceList( PaAlsaHostApiRepresentation *alsaApi ) paInsufficientMemory ); snprintf( deviceName, len, "%s: %s (%s)", cardName, infoName, buf ); + PA_DEBUG(( "%s: Found device [%d]: %s\n", __FUNCTION__, numDeviceNames, deviceName )); + ++numDeviceNames; if( !hwDevInfos || numDeviceNames > maxDeviceNames ) { @@ -1450,7 +1456,7 @@ static PaError BuildDeviceList( PaAlsaHostApiRepresentation *alsaApi ) PA_ENSURE( FillInDevInfo( alsaApi, hwInfo, blocking, devInfo, &devIdx ) ); } - assert( devIdx < numDeviceNames ); + assert( devIdx <= numDeviceNames ); /* Now inspect 'dmix' and 'default' plugins */ for( i = 0; i < numDeviceNames; ++i ) {