[vlc-devel] commit: ALSA: report errors when, and simplify enumerating devices ( Rémi Denis-Courmont )

git version control git at videolan.org
Thu Jan 14 21:15:10 CET 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Jan 14 22:14:10 2010 +0200| [ade985f6dc0e72b09d22cb75b57c38750037cb12] | committer: Rémi Denis-Courmont 

ALSA: report errors when, and simplify enumerating devices

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ade985f6dc0e72b09d22cb75b57c38750037cb12
---

 modules/audio_output/alsa.c |   43 +++++++++++++++----------------------------
 1 files changed, 15 insertions(+), 28 deletions(-)

diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c
index ccf0537..e03f8bc 100644
--- a/modules/audio_output/alsa.c
+++ b/modules/audio_output/alsa.c
@@ -908,8 +908,8 @@ error:
     msleep(p_sys->i_period_time / 2);
 }
 
-static void GetDevicesForCard( module_config_t *p_item, int i_card );
-static void GetDevices( module_config_t *p_item );
+static void GetDevicesForCard( vlc_object_t *, module_config_t *, int card );
+static void GetDevices( vlc_object_t *, module_config_t * );
 
 /*****************************************************************************
  * config variable callback
@@ -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 )
 {
     module_config_t *p_item;
-    int i;
     (void)newval;
     (void)oldval;
     (void)p_unused;
@@ -929,6 +928,8 @@ static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name,
     /* Clear-up the current list */
     if( p_item->i_list )
     {
+        int i;
+
         /* Keep the first entrie */
         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,
     }
     p_item->i_list = 1;
 
-    GetDevices( p_item );
+    GetDevices( p_this, p_item );
 
     /* Signal change to the interface */
     p_item->b_dirty = true;
@@ -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_err = 0;
@@ -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 != -ENOENT )
-            {
-                /*printf( "get_devices_for_card(): "
-                         "snd_ctl_pcm_info() "
-                         "failed (%d:%d): %s.\n", i_card,
-                         i_pcm_device, snd_strerror( -i_err ) );*/
-            }
+                msg_Err( obj, "cannot get PCM device %d:%d infos: %s", i_card,
+                         i_pcm_device, snd_strerror( -i_err ) );
             continue;
         }
 
@@ -1017,25 +1015,14 @@ static void GetDevicesForCard( module_config_t *p_item, int i_card )
 }
 
 
-
-static void GetDevices( module_config_t *p_item )
+static void GetDevices( vlc_object_t *obj, module_config_t *p_item )
 {
     int i_card = -1;
-    int i_err = 0;
+    int i_err;
 
-    if( ( i_err = snd_card_next( &i_card ) ) != 0 )
-    {
-        /*printf( "snd_card_next() failed: %s", snd_strerror( -i_err ) );*/
-        return;
-    }
+    while( (i_err = snd_card_next( &i_card )) == 0 && i_card > -1 )
+        GetDevicesForCard( obj, p_item, i_card );
 
-    while( i_card > -1 )
-    {
-        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;
-        }
-    }
+    if( i_err )
+        msg_Err( obj, "cannot enumerate cards: %s", snd_strerror( -i_err ) );
 }




More information about the vlc-devel mailing list