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).

This commit is contained in:
dmitrykos 2020-03-26 20:50:52 +02:00
commit 6bb858643b

View file

@ -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 )
{