[vlc-devel] commit: Add Hotkey to cycle through audio devices (Dylan )

git version control git at videolan.org
Thu Mar 27 07:39:49 CET 2008


vlc | branch: master | Dylan <dyudaken at gmail.com> | Mon Mar 24 14:26:50 2008 +0200| [0aebd65691ffa6427f13500adc65f5fc1fd8f8d0]

Add Hotkey to cycle through audio devices

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 include/vlc_keys.h        |    3 +-
 modules/control/hotkeys.c |   48 +++++++++++++++++++++++++++++++++++++++++++++
 src/libvlc-module.c       |    6 +++++
 3 files changed, 56 insertions(+), 1 deletions(-)

diff --git a/include/vlc_keys.h b/include/vlc_keys.h
index cce28fc..bbc3c1a 100644
--- a/include/vlc_keys.h
+++ b/include/vlc_keys.h
@@ -334,5 +334,6 @@ static inline int StringToKey( char *psz_key )
 #define ACTIONID_ZOOM_HALF             93
 #define ACTIONID_ZOOM_ORIGINAL         94
 #define ACTIONID_ZOOM_DOUBLE           95
-
+/* Cycle Through Audio Devices */
+#define ACTIONID_AUDIODEVICE_CYCLE     96
 #endif
diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
index 23242a4..eb0f0ae 100644
--- a/modules/control/hotkeys.c
+++ b/modules/control/hotkeys.c
@@ -504,6 +504,54 @@ static void Run( intf_thread_t *p_intf )
                                  _("Audio track: %s"),
                                  list2.p_list->p_values[i].psz_string );
             }
+            else if( i_action == ACTIONID_AUDIODEVICE_CYCLE && p_vout)
+            {
+                vlc_value_t val, list, list2;
+                int i_count, i;
+                aout_instance_t *p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE );
+                var_Get( p_aout, "audio-device", &val );
+                var_Change( p_aout, "audio-device", VLC_VAR_GETCHOICES,&list, &list2 );
+                i_count = list.p_list->i_count;
+                if( i_count <= 1 )
+                {
+                    continue;
+                }
+                for( i = 1; i < i_count; i )
+                {
+                    if( val.i_int == list.p_list->p_values[i].i_int )
+                    {
+                        break;
+                    }
+                }
+                if( i == i_count )
+                {
+                    msg_Warn( p_aout,
+                              "invalid current audio device, selecting 0" );
+                    var_Set( p_aout, "audio-device",
+                             list.p_list->p_values[1] );
+                    i = 1;
+           
+                }
+                else if( i == i_count -1 )
+                {
+                    var_Set( p_aout, "audio-device",
+                             list.p_list->p_values[0] );
+                    i = 0;
+           
+                }
+                else
+                {
+                    var_Set( p_aout, "audio-device",
+                             list.p_list->p_values[i1] );
+                    i;
+        
+                }
+                vout_OSDMessage( VLC_OBJECT(p_input), 
+                                 DEFAULT_CHAN,
+                                 _("Audio Device: %s"),
+                                 list2.p_list->p_values[i].psz_string );
+       
+            }
             else if( i_action == ACTIONID_SUBTITLE_TRACK )
             {
                 vlc_value_t val, list, list2;
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 90e668b..efb8c13 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -1356,6 +1356,8 @@ static const char *ppsz_pltree_descriptions[] = { N_("Default"), N_("Always"), N
 #define MENU_SELECT_KEY_LONGTEXT N_( \
         "Selecting current widget performs the associated action.")
 
+#define AUDI_DEVICE_CYCLE_KEY_TEXT N_("Cycle through audio devices")
+#define AUDI_DEVICE_CYCLE_KEY_LONGTEXT N_("Cycle through available audio devices")
 const char vlc_usage[] = N_(
     "Usage: %s [options] [stream] ..."
     "\nYou can specify multiple streams on the commandline. They will be enqueued in the playlist."
@@ -2192,6 +2194,7 @@ vlc_module_begin();
 #   define KEY_MENU_UP            KEY_MODIFIER_ALT|KEY_MODIFIER_SHIFT|KEY_UP
 #   define KEY_MENU_DOWN          KEY_MODIFIER_ALT|KEY_MODIFIER_SHIFT|KEY_DOWN
 #   define KEY_MENU_SELECT        KEY_MODIFIER_ALT|KEY_MODIFIER_SHIFT|KEY_ENTER
+#   define KEY_AUDIODEVICE_CYCLE  KEY_MODIFIER_ALT|'a'
 #endif
 
     add_key( "key-toggle-fullscreen", KEY_TOGGLE_FULLSCREEN, NULL, TOGGLE_FULLSCREEN_KEY_TEXT,
@@ -2272,6 +2275,8 @@ vlc_module_begin();
              AUDIODELAY_DOWN_KEY_TEXT, AUDIODELAY_DOWN_KEY_LONGTEXT, VLC_TRUE );
     add_key( "key-audio-track", KEY_AUDIO_TRACK, NULL, AUDIO_TRACK_KEY_TEXT,
              AUDIO_TRACK_KEY_LONGTEXT, VLC_FALSE );
+    add_key( "key-audiodevice-cycle", KEY_STOP, NULL, AUDI_DEVICE_CYCLE_KEY_TEXT,
+             AUDI_DEVICE_CYCLE_KEY_LONGTEXT, VLC_FALSE );
     add_key( "key-subtitle-track", KEY_SUBTITLE_TRACK, NULL,
              SUBTITLE_TRACK_KEY_TEXT, SUBTITLE_TRACK_KEY_LONGTEXT, VLC_FALSE );
     add_key( "key-aspect-ratio", KEY_ASPECT_RATIO, NULL,
@@ -2605,6 +2610,7 @@ const struct hotkey libvlc_hotkeys[] =
     { "key-menu-up", ACTIONID_MENU_UP, 0, 0, 0, 0 },
     { "key-menu-down", ACTIONID_MENU_DOWN, 0, 0, 0, 0 },
     { "key-menu-select", ACTIONID_MENU_SELECT, 0, 0, 0, 0 },
+    { "key-audiodevice-cycle", ACTIONID_AUDIODEVICE_CYCLE, 0, 0, 0, 0 },
     { NULL, 0, 0, 0, 0, 0 }
 };
 




More information about the vlc-devel mailing list