modules/control/lirc/lirc.c:

 * backported some changes from the hotkeys module
 * implemented buttons to cycle audio and subtitle tracks.
 * implemented a mute button
doc/lirc/example.lircrc:
 * example for the new buttons
parent 5b34ebd8
...@@ -74,3 +74,15 @@ begin ...@@ -74,3 +74,15 @@ begin
button = VOLUME_UP_DOWN button = VOLUME_UP_DOWN
config = VOL_UP config = VOL_UP
end end
begin
prog = vlc
button = SOMEBUTTON
config = AUDIO_TRACK
end
begin
prog = vlc
button = MUTE_UP
config = MUTE
end
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* lirc.c : lirc module for vlc * lirc.c : lirc module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2004 VideoLAN * Copyright (C) 2004 VideoLAN
* $Id: lirc.c,v 1.10 2004/01/25 16:17:03 anil Exp $ * $Id: lirc.c,v 1.11 2004/02/15 19:40:41 sigmunau Exp $
* *
* Author: Sigmund Augdal <sigmunau@idi.ntnu.no> * Author: Sigmund Augdal <sigmunau@idi.ntnu.no>
* *
...@@ -55,7 +55,6 @@ struct intf_sys_t ...@@ -55,7 +55,6 @@ struct intf_sys_t
static int Open ( vlc_object_t * ); static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * ); static void Close ( vlc_object_t * );
static void Run ( intf_thread_t * ); static void Run ( intf_thread_t * );
static void Feedback( intf_thread_t *, char * );
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
...@@ -190,24 +189,33 @@ static void Run( intf_thread_t *p_intf ) ...@@ -190,24 +189,33 @@ static void Run( intf_thread_t *p_intf )
if( !strcmp( c, "QUIT" ) ) if( !strcmp( c, "QUIT" ) )
{ {
p_intf->p_vlc->b_die = VLC_TRUE; p_intf->p_vlc->b_die = VLC_TRUE;
Feedback( p_intf, _("Quit" ) ); vout_OSDMessage( p_intf, _("Quit" ) );
continue; continue;
} }
if( !strcmp( c, "VOL_UP" ) ) else if( !strcmp( c, "VOL_UP" ) )
{ {
audio_volume_t i_newvol; audio_volume_t i_newvol;
char string[9];
aout_VolumeUp( p_intf, 1, &i_newvol ); aout_VolumeUp( p_intf, 1, &i_newvol );
sprintf( string, "Vol %%%d", i_newvol*100/AOUT_VOLUME_MAX ); vout_OSDMessage( p_intf, _("Vol %%%d"), i_newvol*100/AOUT_VOLUME_MAX );
Feedback( p_intf, string );
} }
if( !strcmp( c, "VOL_DOWN" ) ) else if( !strcmp( c, "VOL_DOWN" ) )
{ {
audio_volume_t i_newvol; audio_volume_t i_newvol;
char string[9];
aout_VolumeDown( p_intf, 1, &i_newvol ); aout_VolumeDown( p_intf, 1, &i_newvol );
sprintf( string, "Vol %%%d", i_newvol*100/AOUT_VOLUME_MAX ); vout_OSDMessage( p_intf, _("Vol %%%d"), i_newvol*100/AOUT_VOLUME_MAX );
Feedback( p_intf, string ); }
else if( !strcmp( c, "MUTE" ) )
{
audio_volume_t i_newvol = -1;
aout_VolumeMute( p_intf, &i_newvol );
if( i_newvol == 0 )
{
vout_OSDMessage( p_intf, _( "Mute" ) );
}
else
{
vout_OSDMessage( p_intf, _("Vol %d%%"), i_newvol*100/AOUT_VOLUME_MAX );
}
} }
if( p_vout ) if( p_vout )
{ {
...@@ -291,11 +299,17 @@ static void Run( intf_thread_t *p_intf ) ...@@ -291,11 +299,17 @@ static void Run( intf_thread_t *p_intf )
if( !strcmp( c, "PLAYPAUSE" ) ) if( !strcmp( c, "PLAYPAUSE" ) )
{ {
if( p_input && vlc_value_t val;
p_input->stream.control.i_status != PAUSE_S ) val.i_int = PLAYING_S;
if( p_input )
{ {
Feedback( p_intf, _( "Pause" ) ); var_Get( p_input, "state", &val );
input_SetStatus( p_input, INPUT_STATUS_PAUSE ); }
if( p_input && val.i_int != PAUSE_S )
{
vout_OSDMessage( VLC_OBJECT(p_intf), _( "Pause" ) );
val.i_int = PAUSE_S;
var_Set( p_input, "state", val );
} }
else else
{ {
...@@ -307,7 +321,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -307,7 +321,7 @@ static void Run( intf_thread_t *p_intf )
if( p_playlist->i_size ) if( p_playlist->i_size )
{ {
vlc_mutex_unlock( &p_playlist->object_lock ); vlc_mutex_unlock( &p_playlist->object_lock );
Feedback( p_intf, _( "Play" ) ); vout_OSDMessage( p_intf, _( "Play" ) );
playlist_Play( p_playlist ); playlist_Play( p_playlist );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
} }
...@@ -318,10 +332,78 @@ static void Run( intf_thread_t *p_intf ) ...@@ -318,10 +332,78 @@ static void Run( intf_thread_t *p_intf )
else if( p_input ) else if( p_input )
{ {
if( !strcmp( c, "PAUSE" ) ) if( !strcmp( c, "AUDIO_TRACK" ) )
{
vlc_value_t val,list,list2;
int i_count, i;
var_Get( p_input, "audio-es", &val );
var_Change( p_input, "audio-es", VLC_VAR_GETCHOICES, &list, &list2 );
i_count = list.p_list->i_count;
for( i = 0; i < i_count; i++ )
{
if( val.i_int == list.p_list->p_values[i].i_int )
{
break;
}
}
/* value of audio-es was not in choices list */
if( i == i_count )
{
msg_Warn( p_input, "invalid current audio track, selecting 0" );
var_Set( p_input, "audio-es", list.p_list->p_values[0] );
i = 0;
}
else if( i == i_count - 1 )
{
var_Set( p_input, "audio-es", list.p_list->p_values[0] );
i = 0;
}
else
{
var_Set( p_input, "audio-es", list.p_list->p_values[i+1] );
i = i + 1;
}
vout_OSDMessage( VLC_OBJECT(p_input), _("Audio track: %s"), list2.p_list->p_values[i].psz_string );
}
else if( !strcmp( c, "SUBTITLE_TRACK" ) )
{
vlc_value_t val,list,list2;
int i_count, i;
var_Get( p_input, "spu-es", &val );
var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES, &list, &list2 );
i_count = list.p_list->i_count;
for( i = 0; i < i_count; i++ )
{
if( val.i_int == list.p_list->p_values[i].i_int )
{
break;
}
}
/* value of audio-es was not in choices list */
if( i == i_count )
{
msg_Warn( p_input, "invalid current subtitle track, selecting 0" );
var_Set( p_input, "spu-es", list.p_list->p_values[0] );
i = 0;
}
else if( i == i_count - 1 )
{
var_Set( p_input, "spu-es", list.p_list->p_values[0] );
i = 0;
}
else
{
var_Set( p_input, "spu-es", list.p_list->p_values[i+1] );
i = i + 1;
}
vout_OSDMessage( VLC_OBJECT(p_input), _("Subtitle track: %s"), list2.p_list->p_values[i].psz_string );
}
else if( !strcmp( c, "PAUSE" ) )
{ {
Feedback( p_intf, _( "Pause" ) ); vlc_value_t val;
input_SetStatus( p_input, INPUT_STATUS_PAUSE ); vout_OSDMessage( p_intf, _( "Pause" ) );
val.i_int = PAUSE_S;
var_Set( p_input, "state", val );
} }
else if( !strcmp( c, "NEXT" ) ) else if( !strcmp( c, "NEXT" ) )
{ {
...@@ -355,11 +437,13 @@ static void Run( intf_thread_t *p_intf ) ...@@ -355,11 +437,13 @@ static void Run( intf_thread_t *p_intf )
} }
else if( !strcmp( c, "FAST" ) ) else if( !strcmp( c, "FAST" ) )
{ {
input_SetStatus( p_input, INPUT_STATUS_FASTER ); vlc_value_t val; val.b_bool = VLC_TRUE;
var_Set( p_input, "rate-faster", val );
} }
else if( !strcmp( c, "SLOW" ) ) else if( !strcmp( c, "SLOW" ) )
{ {
input_SetStatus( p_input, INPUT_STATUS_SLOWER ); vlc_value_t val; val.b_bool = VLC_TRUE;
var_Set( p_input, "rate-slower", val );
} }
/* beginning of modifications by stephane Thu Jun 19 15:29:49 CEST 2003 */ /* beginning of modifications by stephane Thu Jun 19 15:29:49 CEST 2003 */
else if ( !strcmp(c, "CHAPTER_N" ) || else if ( !strcmp(c, "CHAPTER_N" ) ||
...@@ -400,12 +484,3 @@ static void Run( intf_thread_t *p_intf ) ...@@ -400,12 +484,3 @@ static void Run( intf_thread_t *p_intf )
free( code ); free( code );
} }
} }
static void Feedback( intf_thread_t *p_intf, char *psz_string )
{
if ( p_intf->p_sys->p_vout )
{
vout_ShowTextRelative( p_intf->p_sys->p_vout, psz_string, NULL,
OSD_ALIGN_TOP|OSD_ALIGN_RIGHT, 30,20,400000 );
}
}
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