Commit 7db16547 authored by Olivier Teulière's avatar Olivier Teulière

* modules/control/hotkeys.c and lirc.c: fixed a refcount problem + small

   coding style changes
parent eebed017
...@@ -85,26 +85,26 @@ static void SetBookmark ( intf_thread_t *, int ); ...@@ -85,26 +85,26 @@ static void SetBookmark ( intf_thread_t *, int );
vlc_module_begin(); vlc_module_begin();
set_description( _("Hotkeys management interface") ); set_description( _("Hotkeys management interface") );
add_string( "bookmark1", NULL, NULL, add_string( "bookmark1", NULL, NULL,
BOOKMARK1_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE ); BOOKMARK1_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
add_string( "bookmark2", NULL, NULL, add_string( "bookmark2", NULL, NULL,
BOOKMARK2_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE ); BOOKMARK2_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
add_string( "bookmark3", NULL, NULL, add_string( "bookmark3", NULL, NULL,
BOOKMARK3_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE ); BOOKMARK3_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
add_string( "bookmark4", NULL, NULL, add_string( "bookmark4", NULL, NULL,
BOOKMARK4_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE ); BOOKMARK4_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
add_string( "bookmark5", NULL, NULL, add_string( "bookmark5", NULL, NULL,
BOOKMARK5_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE ); BOOKMARK5_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
add_string( "bookmark6", NULL, NULL, add_string( "bookmark6", NULL, NULL,
BOOKMARK6_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE ); BOOKMARK6_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
add_string( "bookmark7", NULL, NULL, add_string( "bookmark7", NULL, NULL,
BOOKMARK7_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE ); BOOKMARK7_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
add_string( "bookmark8", NULL, NULL, add_string( "bookmark8", NULL, NULL,
BOOKMARK8_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE ); BOOKMARK8_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
add_string( "bookmark9", NULL, NULL, add_string( "bookmark9", NULL, NULL,
BOOKMARK9_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE ); BOOKMARK9_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
add_string( "bookmark10", NULL, NULL, add_string( "bookmark10", NULL, NULL,
BOOKMARK10_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE ); BOOKMARK10_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
set_capability( "interface", 0 ); set_capability( "interface", 0 );
set_callbacks( Open, Close ); set_callbacks( Open, Close );
vlc_module_end(); vlc_module_end();
...@@ -200,8 +200,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -200,8 +200,7 @@ static void Run( intf_thread_t *p_intf )
/* Update the vout */ /* Update the vout */
if( p_vout == NULL ) if( p_vout == NULL )
{ {
p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
FIND_ANYWHERE );
p_intf->p_sys->p_vout = p_vout; p_intf->p_sys->p_vout = p_vout;
} }
else if( p_vout->b_die ) else if( p_vout->b_die )
...@@ -251,22 +250,22 @@ static void Run( intf_thread_t *p_intf ) ...@@ -251,22 +250,22 @@ static void Run( intf_thread_t *p_intf )
{ {
int i_delay; int i_delay;
if( input_Control( p_input, INPUT_GET_SUBDELAY, &i_delay ) == if( input_Control( p_input, INPUT_GET_SUBDELAY, &i_delay ) ==
VLC_SUCCESS ) VLC_SUCCESS )
{ {
i_delay--; i_delay--;
input_Control( p_input, INPUT_SET_SUBDELAY, i_delay ); input_Control( p_input, INPUT_SET_SUBDELAY, i_delay );
vout_OSDMessage( p_intf, "Subtitle delay %i ms",i_delay*100); vout_OSDMessage( p_intf, "Subtitle delay %i ms", i_delay*100);
} }
} }
else if( i_action == ACTIONID_SUBDELAY_UP ) else if( i_action == ACTIONID_SUBDELAY_UP )
{ {
int i_delay; int i_delay;
if( input_Control( p_input, INPUT_GET_SUBDELAY, &i_delay ) == if( input_Control( p_input, INPUT_GET_SUBDELAY, &i_delay ) ==
VLC_SUCCESS ) VLC_SUCCESS )
{ {
i_delay++; i_delay++;
input_Control( p_input, INPUT_SET_SUBDELAY, i_delay ); input_Control( p_input, INPUT_SET_SUBDELAY, i_delay );
vout_OSDMessage( p_intf, "Subtitle delay %i ms",i_delay*100); vout_OSDMessage( p_intf, "Subtitle delay %i ms", i_delay*100);
} }
} }
else if( i_action == ACTIONID_VOL_MUTE ) else if( i_action == ACTIONID_VOL_MUTE )
...@@ -280,7 +279,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -280,7 +279,7 @@ static void Run( intf_thread_t *p_intf )
else else
{ {
vout_OSDMessage( p_intf, "Vol %d%%", vout_OSDMessage( p_intf, "Vol %d%%",
i_newvol*100/AOUT_VOLUME_MAX ); i_newvol * 100 / AOUT_VOLUME_MAX );
} }
} }
else if( i_action == ACTIONID_FULLSCREEN && p_vout ) else if( i_action == ACTIONID_FULLSCREEN && p_vout )
...@@ -317,14 +316,9 @@ static void Run( intf_thread_t *p_intf ) ...@@ -317,14 +316,9 @@ static void Run( intf_thread_t *p_intf )
FIND_ANYWHERE ); FIND_ANYWHERE );
if( p_playlist ) if( p_playlist )
{ {
vlc_mutex_lock( &p_playlist->object_lock ); vout_OSDMessage( p_intf, _( "Play" ) );
if( p_playlist->i_size ) playlist_Play( p_playlist );
{ vlc_object_release( p_playlist );
vlc_mutex_unlock( &p_playlist->object_lock );
vout_OSDMessage( p_intf, _( "Play" ) );
playlist_Play( p_playlist );
vlc_object_release( p_playlist );
}
} }
} }
} }
...@@ -414,15 +408,16 @@ static void Run( intf_thread_t *p_intf ) ...@@ -414,15 +408,16 @@ static void Run( intf_thread_t *p_intf )
} }
else if( i_action == ACTIONID_POSITION ) else if( i_action == ACTIONID_POSITION )
{ {
playlist_t *p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, playlist_t *p_playlist =
FIND_ANYWHERE ); vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
char psz_duration[MSTRTIME_MAX_SIZE]; char psz_duration[MSTRTIME_MAX_SIZE];
char psz_time[MSTRTIME_MAX_SIZE]; char psz_time[MSTRTIME_MAX_SIZE];
vlc_value_t time; vlc_value_t time;
mtime_t i_seconds; mtime_t i_seconds;
var_Get( p_input, "time", &time ); var_Get( p_input, "time", &time );
if( p_playlist ) if( p_playlist )
{ {
mtime_t dur = mtime_t dur =
...@@ -430,14 +425,15 @@ static void Run( intf_thread_t *p_intf ) ...@@ -430,14 +425,15 @@ static void Run( intf_thread_t *p_intf )
i_seconds = time.i_time / 1000000; i_seconds = time.i_time / 1000000;
secstotimestr ( psz_time, i_seconds ); secstotimestr ( psz_time, i_seconds );
if( dur != -1 ) if( dur != -1 )
{ {
secstotimestr( psz_duration, dur/1000000 ); secstotimestr( psz_duration, dur / 1000000 );
vout_OSDMessage( p_playlist, "%s / %s", psz_time, psz_duration ); vout_OSDMessage( p_playlist, "%s / %s",
psz_time, psz_duration );
} }
else if( i_seconds > 0 ) else if( i_seconds > 0 )
{ {
vout_OSDMessage( p_playlist, psz_time ); vout_OSDMessage( p_playlist, psz_time );
} }
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
...@@ -522,23 +518,24 @@ static int ActionKeyCB( vlc_object_t *p_this, char const *psz_var, ...@@ -522,23 +518,24 @@ static int ActionKeyCB( vlc_object_t *p_this, char const *psz_var,
} }
static void PlayBookmark( intf_thread_t *p_intf, int i_num ) static void PlayBookmark( intf_thread_t *p_intf, int i_num )
{ {
vlc_value_t val; vlc_value_t val;
int i_position; int i_position;
char psz_bookmark_name[11]; char psz_bookmark_name[11];
playlist_t *p_playlist = vlc_object_find( p_intf, playlist_t *p_playlist =
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
sprintf( psz_bookmark_name, "bookmark%i", i_num ); sprintf( psz_bookmark_name, "bookmark%i", i_num );
var_Create( p_intf, psz_bookmark_name, VLC_VAR_STRING|VLC_VAR_DOINHERIT ); var_Create( p_intf, psz_bookmark_name, VLC_VAR_STRING|VLC_VAR_DOINHERIT );
var_Get( p_intf, psz_bookmark_name, &val ); var_Get( p_intf, psz_bookmark_name, &val );
if( p_playlist ) if( p_playlist )
{ {
char *psz_bookmark = strdup( val.psz_string ); char *psz_bookmark = strdup( val.psz_string );
for( i_position = 0 ; i_position < p_playlist->i_size ; i_position++) for( i_position = 0; i_position < p_playlist->i_size; i_position++)
{ {
if( !strcmp( psz_bookmark, p_playlist->pp_items[i_position]->input.psz_uri ) ) if( !strcmp( psz_bookmark,
p_playlist->pp_items[i_position]->input.psz_uri ) )
{ {
playlist_Goto( p_playlist, i_position ); playlist_Goto( p_playlist, i_position );
break; break;
...@@ -551,16 +548,18 @@ static void PlayBookmark( intf_thread_t *p_intf, int i_num ) ...@@ -551,16 +548,18 @@ static void PlayBookmark( intf_thread_t *p_intf, int i_num )
static void SetBookmark( intf_thread_t *p_intf, int i_num ) static void SetBookmark( intf_thread_t *p_intf, int i_num )
{ {
vlc_value_t val; vlc_value_t val;
playlist_t *p_playlist = vlc_object_find( p_intf, playlist_t *p_playlist =
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( p_playlist ) if( p_playlist )
{ {
char psz_bookmark_name[11]; char psz_bookmark_name[11];
sprintf( psz_bookmark_name, "bookmark%i", i_num ); sprintf( psz_bookmark_name, "bookmark%i", i_num );
var_Create( p_intf, psz_bookmark_name, VLC_VAR_STRING|VLC_VAR_DOINHERIT ); var_Create( p_intf, psz_bookmark_name,
VLC_VAR_STRING|VLC_VAR_DOINHERIT );
val.psz_string = strdup( p_playlist->pp_items[p_playlist->i_index]->input.psz_uri ); val.psz_string = strdup( p_playlist->pp_items[p_playlist->i_index]->input.psz_uri );
var_Set( p_intf, psz_bookmark_name, val ); var_Set( p_intf, psz_bookmark_name, val );
msg_Info( p_intf, "setting playlist bookmark %i to %s", i_num, val.psz_string ); msg_Info( p_intf, "setting playlist bookmark %i to %s", i_num,
val.psz_string );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
} }
} }
...@@ -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.11 2004/02/15 19:40:41 sigmunau Exp $ * $Id$
* *
* Author: Sigmund Augdal <sigmunau@idi.ntnu.no> * Author: Sigmund Augdal <sigmunau@idi.ntnu.no>
* *
...@@ -196,13 +196,15 @@ static void Run( intf_thread_t *p_intf ) ...@@ -196,13 +196,15 @@ static void Run( intf_thread_t *p_intf )
{ {
audio_volume_t i_newvol; audio_volume_t i_newvol;
aout_VolumeUp( p_intf, 1, &i_newvol ); aout_VolumeUp( p_intf, 1, &i_newvol );
vout_OSDMessage( p_intf, _("Vol %%%d"), i_newvol*100/AOUT_VOLUME_MAX ); vout_OSDMessage( p_intf, _("Vol %%%d"),
i_newvol * 100 / AOUT_VOLUME_MAX );
} }
else if( !strcmp( c, "VOL_DOWN" ) ) else if( !strcmp( c, "VOL_DOWN" ) )
{ {
audio_volume_t i_newvol; audio_volume_t i_newvol;
aout_VolumeDown( p_intf, 1, &i_newvol ); aout_VolumeDown( p_intf, 1, &i_newvol );
vout_OSDMessage( p_intf, _("Vol %%%d"), i_newvol*100/AOUT_VOLUME_MAX ); vout_OSDMessage( p_intf, _("Vol %%%d"),
i_newvol * 100 / AOUT_VOLUME_MAX );
} }
else if( !strcmp( c, "MUTE" ) ) else if( !strcmp( c, "MUTE" ) )
{ {
...@@ -214,7 +216,8 @@ static void Run( intf_thread_t *p_intf ) ...@@ -214,7 +216,8 @@ static void Run( intf_thread_t *p_intf )
} }
else else
{ {
vout_OSDMessage( p_intf, _("Vol %d%%"), i_newvol*100/AOUT_VOLUME_MAX ); vout_OSDMessage( p_intf, _("Vol %d%%"),
i_newvol * 100 / AOUT_VOLUME_MAX );
} }
} }
if( p_vout ) if( p_vout )
...@@ -283,16 +286,11 @@ static void Run( intf_thread_t *p_intf ) ...@@ -283,16 +286,11 @@ static void Run( intf_thread_t *p_intf )
if( !strcmp( c, "PLAY" ) ) if( !strcmp( c, "PLAY" ) )
{ {
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE ); FIND_ANYWHERE );
if( p_playlist ) if( p_playlist )
{ {
vlc_mutex_lock( &p_playlist->object_lock ); playlist_Play( p_playlist );
if( p_playlist->i_size ) vlc_object_release( p_playlist );
{
vlc_mutex_unlock( &p_playlist->object_lock );
playlist_Play( p_playlist );
vlc_object_release( p_playlist );
}
} }
continue; continue;
} }
...@@ -334,10 +332,11 @@ static void Run( intf_thread_t *p_intf ) ...@@ -334,10 +332,11 @@ static void Run( intf_thread_t *p_intf )
{ {
if( !strcmp( c, "AUDIO_TRACK" ) ) if( !strcmp( c, "AUDIO_TRACK" ) )
{ {
vlc_value_t val,list,list2; vlc_value_t val, list, list2;
int i_count, i; int i_count, i;
var_Get( p_input, "audio-es", &val ); var_Get( p_input, "audio-es", &val );
var_Change( p_input, "audio-es", VLC_VAR_GETCHOICES, &list, &list2 ); var_Change( p_input, "audio-es", VLC_VAR_GETCHOICES,
&list, &list2 );
i_count = list.p_list->i_count; i_count = list.p_list->i_count;
for( i = 0; i < i_count; i++ ) for( i = 0; i < i_count; i++ )
{ {
...@@ -349,28 +348,34 @@ static void Run( intf_thread_t *p_intf ) ...@@ -349,28 +348,34 @@ static void Run( intf_thread_t *p_intf )
/* value of audio-es was not in choices list */ /* value of audio-es was not in choices list */
if( i == i_count ) if( i == i_count )
{ {
msg_Warn( p_input, "invalid current audio track, selecting 0" ); msg_Warn( p_input,
var_Set( p_input, "audio-es", list.p_list->p_values[0] ); "invalid current audio track, selecting 0" );
var_Set( p_input, "audio-es",
list.p_list->p_values[0] );
i = 0; i = 0;
} }
else if( i == i_count - 1 ) else if( i == i_count - 1 )
{ {
var_Set( p_input, "audio-es", list.p_list->p_values[0] ); var_Set( p_input, "audio-es",
list.p_list->p_values[0] );
i = 0; i = 0;
} }
else else
{ {
var_Set( p_input, "audio-es", list.p_list->p_values[i+1] ); var_Set( p_input, "audio-es",
i = i + 1; list.p_list->p_values[i+1] );
i++;
} }
vout_OSDMessage( VLC_OBJECT(p_input), _("Audio track: %s"), list2.p_list->p_values[i].psz_string ); vout_OSDMessage( VLC_OBJECT(p_input), _("Audio track: %s"),
list2.p_list->p_values[i].psz_string );
} }
else if( !strcmp( c, "SUBTITLE_TRACK" ) ) else if( !strcmp( c, "SUBTITLE_TRACK" ) )
{ {
vlc_value_t val,list,list2; vlc_value_t val, list, list2;
int i_count, i; int i_count, i;
var_Get( p_input, "spu-es", &val ); var_Get( p_input, "spu-es", &val );
var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES, &list, &list2 ); var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
&list, &list2 );
i_count = list.p_list->i_count; i_count = list.p_list->i_count;
for( i = 0; i < i_count; i++ ) for( i = 0; i < i_count; i++ )
{ {
......
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