[vlc-devel] Added hotkey to cycle through audio devices
Dylan Yudaken
dyudaken at gmail.com
Mon Mar 24 16:12:17 CET 2008
I have updated & cleaned the patch.
Its now in 2 files, I wasnt sure how to combine them with git. can
someone explain how I would do this?
The default key is shift + 'd'. (d for devices.). I dont know how the
VLC hotkey system likes keys to be done so that can be changed easily.
Jean-Baptiste Kempf wrote:
> On Mon, Mar 24, 2008, Dylan Yudaken wrote :
>
>> I wrote a small patch to add a hotkey to VLC to cycle through the audio
>> devices.
>> It could be useful if you run VLC on a tv and need to remotely switch
>> between them.
>>
> OK.
>
>
>> @@ -335,4 +335,5 @@ static inline int StringToKey( char *psz_key )
>> #define ACTIONID_ZOOM_ORIGINAL 94
>> #define ACTIONID_ZOOM_DOUBLE 95
>>
>> +#define ACTIONID_AUDIODEVICE_CYCLE 103
>>
>
> Why 103 and not 96 ?
>
>
>> @@ -626,19 +626,67 @@ static void Run( intf_thread_t *p_intf )
>> }
>> free( val.psz_string );
>> }
>> - else if( ( i_action == ACTIONID_ZOOM || i_action == ACTIONID_UNZOOM ) && p_vout )
>> - {
>> - vlc_value_t val={0}, val_list, text_list;
>> - var_Get( p_vout, "zoom", &val );
>> - if( var_Change( p_vout, "zoom", VLC_VAR_GETLIST,
>> - &val_list, &text_list ) >= 0 )
>> + 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 )
>> {
>> - int i;
>> - for( i = 0; i < val_list.p_list->i_count; i++ )
>> + continue;
>> + }
>> + for( i = 1; i < i_count; i++ )
>> + {
>> + if( val.i_int == list.p_list->p_values[i].i_int )
>> {
>> - if( val_list.p_list->p_values[i].f_float
>> + 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[i+1] );
>> + 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_ZOOM || i_action == ACTIONID_UNZOOM ) && p_vout )
>> + {
>> + vlc_value_t val={0}, val_list, text_list;
>> + var_Get( p_vout, "zoom", &val );
>> + if( var_Change( p_vout, "zoom", VLC_VAR_GETLIST,
>> + &val_list, &text_list ) >= 0 )
>> + {
>> + int i;
>> + for( i = 0; i < val_list.p_list->i_count; i++ )
>> + {
>> + if( val_list.p_list->p_values[i].f_float
>> == val.f_float )
>> - {
>> + {
>> if( i_action == ACTIONID_ZOOM )
>> i++;
>> else /* ACTIONID_UNZOOM */
>>
>
> Could you keep some correct code alignment please ?
>
>
>
>> +# define KEY_AUDIODEVICE_CYCLE KEY_MODIFIER_SHIFT|'s'
>>
> What is the rationnal of using shift+s for that ?
>
>
>
>> + //Dylan test
>>
> Remove this
>
> Else, it should be ok.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20080324/8f64ae4f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Add-hotkey-to-cycle-through-audio-devices.patch
Type: application/mbox
Size: 2606 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20080324/8f64ae4f/attachment.mbox>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-Hotkey-to-cycle-through-audio-devices.patch
Type: application/mbox
Size: 5246 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20080324/8f64ae4f/attachment-0001.mbox>
More information about the vlc-devel
mailing list