[vlc-commits] hotkeys: use aout_DeviceGet() and aout_DevicesList()

Rémi Denis-Courmont git at videolan.org
Mon Jan 14 18:44:12 CET 2013


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Jan 14 19:41:05 2013 +0200| [6399242329713a90a60e15478dd94f5aa6852923] | committer: Rémi Denis-Courmont

hotkeys: use aout_DeviceGet() and aout_DevicesList()

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

 modules/control/hotkeys.c |   37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
index b43b790..4b0672c 100644
--- a/modules/control/hotkeys.c
+++ b/modules/control/hotkeys.c
@@ -319,27 +319,34 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
             if( p_aout == NULL )
                 break;
 
-            char *dev = var_GetNonEmptyString( p_aout, "device" );
-            const char *devstr = (dev != NULL) ? dev : "";
+            char **ids, **names;
+            int n = aout_DevicesList( p_aout, &ids, &names );
+            if( n == -1 )
+                break;
 
-            vlc_value_t ids, names;
-            var_Change( p_aout, "device", VLC_VAR_GETCHOICES, &ids, &names );
+            char *dev = aout_DeviceGet( p_aout );
+            const char *devstr = (dev != NULL) ? dev : "";
 
-            int i = 0;
-            for( i = 0; i < ids.p_list->i_count; i++ )
-                if( !strcmp(devstr, ids.p_list->p_values[i].psz_string) )
-                    break;
+            int idx = 0;
+            for( int i = 0; i < n; i++ )
+            {
+                if( !strcmp(devstr, ids[i]) )
+                    idx = (i + 1) % n;
+            }
             free( dev );
 
-            i++;
-            if( i >= ids.p_list->i_count )
-                i = 0;
-            if( !aout_DeviceSet( p_aout, ids.p_list->p_values[i].psz_string ) )
+            if( !aout_DeviceSet( p_aout, ids[idx] ) )
                 DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL,
-                                _("Audio Device: %s"),
-                                names.p_list->p_values[i].psz_string);
-            var_FreeList( &ids, &names );
+                                _("Audio Device: %s"), names[idx] );
             vlc_object_release( p_aout );
+
+            for( int i = 0; i < n; i++ )
+            {
+                free( ids[i] );
+                free( names[i] );
+            }
+            free( ids );
+            free( names );
             break;
         }
 



More information about the vlc-commits mailing list