Commit ade985f6 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

ALSA: report errors when, and simplify enumerating devices

parent c255d973
...@@ -908,8 +908,8 @@ error: ...@@ -908,8 +908,8 @@ error:
msleep(p_sys->i_period_time / 2); msleep(p_sys->i_period_time / 2);
} }
static void GetDevicesForCard( module_config_t *p_item, int i_card ); static void GetDevicesForCard( vlc_object_t *, module_config_t *, int card );
static void GetDevices( module_config_t *p_item ); static void GetDevices( vlc_object_t *, module_config_t * );
/***************************************************************************** /*****************************************************************************
* config variable callback * config variable callback
...@@ -918,7 +918,6 @@ static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name, ...@@ -918,7 +918,6 @@ static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name,
vlc_value_t newval, vlc_value_t oldval, void *p_unused ) vlc_value_t newval, vlc_value_t oldval, void *p_unused )
{ {
module_config_t *p_item; module_config_t *p_item;
int i;
(void)newval; (void)newval;
(void)oldval; (void)oldval;
(void)p_unused; (void)p_unused;
...@@ -929,6 +928,8 @@ static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name, ...@@ -929,6 +928,8 @@ static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name,
/* Clear-up the current list */ /* Clear-up the current list */
if( p_item->i_list ) if( p_item->i_list )
{ {
int i;
/* Keep the first entrie */ /* Keep the first entrie */
for( i = 1; i < p_item->i_list; i++ ) for( i = 1; i < p_item->i_list; i++ )
{ {
...@@ -941,7 +942,7 @@ static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name, ...@@ -941,7 +942,7 @@ static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name,
} }
p_item->i_list = 1; p_item->i_list = 1;
GetDevices( p_item ); GetDevices( p_this, p_item );
/* Signal change to the interface */ /* Signal change to the interface */
p_item->b_dirty = true; p_item->b_dirty = true;
...@@ -950,7 +951,8 @@ static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name, ...@@ -950,7 +951,8 @@ static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name,
} }
static void GetDevicesForCard( module_config_t *p_item, int i_card ) static void GetDevicesForCard( vlc_object_t *obj, module_config_t *p_item,
int i_card )
{ {
int i_pcm_device = -1; int i_pcm_device = -1;
int i_err = 0; int i_err = 0;
...@@ -984,12 +986,8 @@ static void GetDevicesForCard( module_config_t *p_item, int i_card ) ...@@ -984,12 +986,8 @@ static void GetDevicesForCard( module_config_t *p_item, int i_card )
if( ( i_err = snd_ctl_pcm_info( p_ctl, p_pcm_info ) ) < 0 ) if( ( i_err = snd_ctl_pcm_info( p_ctl, p_pcm_info ) ) < 0 )
{ {
if( i_err != -ENOENT ) if( i_err != -ENOENT )
{ msg_Err( obj, "cannot get PCM device %d:%d infos: %s", i_card,
/*printf( "get_devices_for_card(): " i_pcm_device, snd_strerror( -i_err ) );
"snd_ctl_pcm_info() "
"failed (%d:%d): %s.\n", i_card,
i_pcm_device, snd_strerror( -i_err ) );*/
}
continue; continue;
} }
...@@ -1017,25 +1015,14 @@ static void GetDevicesForCard( module_config_t *p_item, int i_card ) ...@@ -1017,25 +1015,14 @@ static void GetDevicesForCard( module_config_t *p_item, int i_card )
} }
static void GetDevices( vlc_object_t *obj, module_config_t *p_item )
static void GetDevices( module_config_t *p_item )
{ {
int i_card = -1; int i_card = -1;
int i_err = 0; int i_err;
if( ( i_err = snd_card_next( &i_card ) ) != 0 ) while( (i_err = snd_card_next( &i_card )) == 0 && i_card > -1 )
{ GetDevicesForCard( obj, p_item, i_card );
/*printf( "snd_card_next() failed: %s", snd_strerror( -i_err ) );*/
return;
}
while( i_card > -1 ) if( i_err )
{ msg_Err( obj, "cannot enumerate cards: %s", snd_strerror( -i_err ) );
GetDevicesForCard( p_item, i_card );
if( ( i_err = snd_card_next( &i_card ) ) != 0 )
{
/*printf( "snd_card_next() failed: %s", snd_strerror( -i_err ) );*/
break;
}
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment