Commit 00760708 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

hotkeys: put all text on the default SPU channel

Never more than one piece of text is displayed at a time anyway.
Also simplify format string handling and use single precision maths.
parent 395f4e4a
...@@ -41,11 +41,9 @@ ...@@ -41,11 +41,9 @@
#include <vlc_keys.h> #include <vlc_keys.h>
#include "math.h" #include "math.h"
#define CHANNELS_NUMBER 4 #define CHANNELS_NUMBER 2
#define VOLUME_TEXT_CHAN p_intf->p_sys->p_channels[ 0 ] #define VOLUME_WIDGET_CHAN p_intf->p_sys->p_channels[ 0 ]
#define VOLUME_WIDGET_CHAN p_intf->p_sys->p_channels[ 1 ] #define POSITION_WIDGET_CHAN p_intf->p_sys->p_channels[ 1 ]
#define POSITION_TEXT_CHAN p_intf->p_sys->p_channels[ 2 ]
#define POSITION_WIDGET_CHAN p_intf->p_sys->p_channels[ 3 ]
/***************************************************************************** /*****************************************************************************
* intf_sys_t: description and status of FB interface * intf_sys_t: description and status of FB interface
...@@ -72,8 +70,11 @@ static void DisplayRate ( vout_thread_t *, float ); ...@@ -72,8 +70,11 @@ static void DisplayRate ( vout_thread_t *, float );
static float AdjustRateFine( vlc_object_t *, const int ); static float AdjustRateFine( vlc_object_t *, const int );
static void ClearChannels ( intf_thread_t *, vout_thread_t * ); static void ClearChannels ( intf_thread_t *, vout_thread_t * );
#define DisplayMessage(vout, ch, fmt, ...) \ #define DisplayMessage(vout, ...) \
do { if(vout) vout_OSDMessage(vout, ch, fmt, __VA_ARGS__); } while(0) do { \
if (vout) \
vout_OSDMessage(vout, SPU_DEFAULT_CHANNEL, __VA_ARGS__); \
} while(0)
#define DisplayIcon(vout, icon) \ #define DisplayIcon(vout, icon) \
do { if(vout) vout_OSDIcon(vout, SPU_DEFAULT_CHANNEL, icon); } while(0) do { if(vout) vout_OSDIcon(vout, SPU_DEFAULT_CHANNEL, icon); } while(0)
...@@ -152,7 +153,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action ) ...@@ -152,7 +153,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
libvlc_Quit( p_intf->p_libvlc ); libvlc_Quit( p_intf->p_libvlc );
ClearChannels( p_intf, p_vout ); ClearChannels( p_intf, p_vout );
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, "%s", _( "Quit" ) ); DisplayMessage( p_vout, _( "Quit" ) );
break; break;
case ACTIONID_INTF_TOGGLE_FSC: case ACTIONID_INTF_TOGGLE_FSC:
...@@ -186,11 +187,11 @@ static int PutAction( intf_thread_t *p_intf, int i_action ) ...@@ -186,11 +187,11 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
break; break;
case ACTIONID_NEXT: case ACTIONID_NEXT:
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, "%s", _("Next") ); DisplayMessage( p_vout, _("Next") );
playlist_Next( p_playlist ); playlist_Next( p_playlist );
break; break;
case ACTIONID_PREV: case ACTIONID_PREV:
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, "%s", _("Previous") ); DisplayMessage( p_vout, _("Previous") );
playlist_Prev( p_playlist ); playlist_Prev( p_playlist );
break; break;
...@@ -298,8 +299,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action ) ...@@ -298,8 +299,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
free( dev ); free( dev );
if( !aout_DeviceSet( p_aout, ids[idx] ) ) if( !aout_DeviceSet( p_aout, ids[idx] ) )
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, DisplayMessage( p_vout, _("Audio Device: %s"), names[idx] );
_("Audio Device: %s"), names[idx] );
vlc_object_release( p_aout ); vlc_object_release( p_aout );
for( int i = 0; i < n; i++ ) for( int i = 0; i < n; i++ )
...@@ -361,8 +361,8 @@ static int PutAction( intf_thread_t *p_intf, int i_action ) ...@@ -361,8 +361,8 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
if( p_input && var_GetBool( p_input, "can-record" ) ) if( p_input && var_GetBool( p_input, "can-record" ) )
{ {
const bool on = var_ToggleBool( p_input, "record" ); const bool on = var_ToggleBool( p_input, "record" );
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, "%s", DisplayMessage( p_vout, vlc_gettext(on
vlc_gettext(on ? N_("Recording") : N_("Recording done")) ); ? N_("Recording") : N_("Recording done")) );
} }
break; break;
...@@ -370,8 +370,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action ) ...@@ -370,8 +370,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
if( p_input ) if( p_input )
{ {
var_TriggerCallback( p_input, "frame-next" ); var_TriggerCallback( p_input, "frame-next" );
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, DisplayMessage( p_vout, _("Next frame") );
"%s", _("Next frame") );
} }
break; break;
...@@ -385,8 +384,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action ) ...@@ -385,8 +384,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
var_SetTime( p_input, "spu-delay", i_delay ); var_SetTime( p_input, "spu-delay", i_delay );
ClearChannels( p_intf, p_vout ); ClearChannels( p_intf, p_vout );
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, DisplayMessage( p_vout, _( "Subtitle delay %i ms" ),
_( "Subtitle delay %i ms" ),
(int)(i_delay/1000) ); (int)(i_delay/1000) );
} }
break; break;
...@@ -401,8 +399,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action ) ...@@ -401,8 +399,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
var_SetTime( p_input, "audio-delay", i_delay ); var_SetTime( p_input, "audio-delay", i_delay );
ClearChannels( p_intf, p_vout ); ClearChannels( p_intf, p_vout );
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, DisplayMessage( p_vout, _( "Audio delay %i ms" ),
_( "Audio delay %i ms" ),
(int)(i_delay/1000) ); (int)(i_delay/1000) );
} }
break; break;
...@@ -438,8 +435,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action ) ...@@ -438,8 +435,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
else else
i++; i++;
var_Set( p_input, "audio-es", list.p_list->p_values[i] ); var_Set( p_input, "audio-es", list.p_list->p_values[i] );
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, DisplayMessage( p_vout, _("Audio track: %s"),
_("Audio track: %s"),
list2.p_list->p_values[i].psz_string ); list2.p_list->p_values[i].psz_string );
} }
var_FreeList( &list, &list2 ); var_FreeList( &list, &list2 );
...@@ -457,8 +453,8 @@ static int PutAction( intf_thread_t *p_intf, int i_action ) ...@@ -457,8 +453,8 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
i_count = list.p_list->i_count; i_count = list.p_list->i_count;
if( i_count <= 1 ) if( i_count <= 1 )
{ {
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, DisplayMessage( p_vout, _("Subtitle track: %s"),
_("Subtitle track: %s"), _("N/A") ); _("N/A") );
var_FreeList( &list, &list2 ); var_FreeList( &list, &list2 );
break; break;
} }
...@@ -481,8 +477,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action ) ...@@ -481,8 +477,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
else else
i++; i++;
var_Set( p_input, "spu-es", list.p_list->p_values[i] ); var_Set( p_input, "spu-es", list.p_list->p_values[i] );
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, DisplayMessage( p_vout, _("Subtitle track: %s"),
_("Subtitle track: %s"),
list2.p_list->p_values[i].psz_string ); list2.p_list->p_values[i].psz_string );
var_FreeList( &list, &list2 ); var_FreeList( &list, &list2 );
} }
...@@ -499,8 +494,8 @@ static int PutAction( intf_thread_t *p_intf, int i_action ) ...@@ -499,8 +494,8 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
i_count = list.p_list->i_count; i_count = list.p_list->i_count;
if( i_count <= 1 ) if( i_count <= 1 )
{ {
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, DisplayMessage( p_vout, _("Program Service ID: %s"),
_("Program Service ID: %s"), _("N/A") ); _("N/A") );
var_FreeList( &list, &list2 ); var_FreeList( &list, &list2 );
break; break;
} }
...@@ -523,8 +518,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action ) ...@@ -523,8 +518,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
else else
i++; i++;
var_Set( p_input, "program", list.p_list->p_values[i] ); var_Set( p_input, "program", list.p_list->p_values[i] );
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, DisplayMessage( p_vout, _("Program Service ID: %s"),
_("Program Service ID: %s"),
list2.p_list->p_values[i].psz_string ); list2.p_list->p_values[i].psz_string );
var_FreeList( &list, &list2 ); var_FreeList( &list, &list2 );
} }
...@@ -648,8 +642,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action ) ...@@ -648,8 +642,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
if( i == val_list.p_list->i_count ) i = 0; if( i == val_list.p_list->i_count ) i = 0;
var_SetString( p_vout, "aspect-ratio", var_SetString( p_vout, "aspect-ratio",
val_list.p_list->p_values[i].psz_string ); val_list.p_list->p_values[i].psz_string );
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, DisplayMessage( p_vout, _("Aspect ratio: %s"),
_("Aspect ratio: %s"),
text_list.p_list->p_values[i].psz_string ); text_list.p_list->p_values[i].psz_string );
var_FreeList( &val_list, &text_list ); var_FreeList( &val_list, &text_list );
...@@ -679,8 +672,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action ) ...@@ -679,8 +672,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
if( i == val_list.p_list->i_count ) i = 0; if( i == val_list.p_list->i_count ) i = 0;
var_SetString( p_vout, "crop", var_SetString( p_vout, "crop",
val_list.p_list->p_values[i].psz_string ); val_list.p_list->p_values[i].psz_string );
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, DisplayMessage( p_vout, _("Crop: %s"),
_("Crop: %s"),
text_list.p_list->p_values[i].psz_string ); text_list.p_list->p_values[i].psz_string );
var_FreeList( &val_list, &text_list ); var_FreeList( &val_list, &text_list );
...@@ -728,19 +720,16 @@ static int PutAction( intf_thread_t *p_intf, int i_action ) ...@@ -728,19 +720,16 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
if ( f_scalefactor != 1.f ) if ( f_scalefactor != 1.f )
{ {
var_SetFloat( p_vout, "scale", 1.f ); var_SetFloat( p_vout, "scale", 1.f );
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, DisplayMessage( p_vout, _("Zooming reset") );
"%s", _("Zooming reset") );
} }
else else
{ {
bool b_autoscale = !var_GetBool( p_vout, "autoscale" ); bool b_autoscale = !var_GetBool( p_vout, "autoscale" );
var_SetBool( p_vout, "autoscale", b_autoscale ); var_SetBool( p_vout, "autoscale", b_autoscale );
if( b_autoscale ) if( b_autoscale )
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, DisplayMessage( p_vout, _("Scaled to screen") );
"%s", _("Scaled to screen") );
else else
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, DisplayMessage( p_vout, _("Original Size") );
"%s", _("Original Size") );
} }
} }
break; break;
...@@ -809,8 +798,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action ) ...@@ -809,8 +798,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
if( i == -1 ) i = val_list.p_list->i_count-1; if( i == -1 ) i = val_list.p_list->i_count-1;
var_SetFloat( p_vout, "zoom", var_SetFloat( p_vout, "zoom",
val_list.p_list->p_values[i].f_float ); val_list.p_list->p_values[i].f_float );
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, DisplayMessage( p_vout, _("Zoom mode: %s"),
_("Zoom mode: %s"),
text_list.p_list->p_values[i].psz_string ); text_list.p_list->p_values[i].psz_string );
var_FreeList( &val_list, &text_list ); var_FreeList( &val_list, &text_list );
...@@ -825,8 +813,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action ) ...@@ -825,8 +813,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
if( i_deinterlace != 0 ) if( i_deinterlace != 0 )
{ {
var_SetInteger( p_vout, "deinterlace", 0 ); var_SetInteger( p_vout, "deinterlace", 0 );
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, DisplayMessage( p_vout, _("Deinterlace off") );
"%s", _("Deinterlace off") );
} }
else else
{ {
...@@ -845,8 +832,8 @@ static int PutAction( intf_thread_t *p_intf, int i_action ) ...@@ -845,8 +832,8 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
break; break;
} }
} }
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, DisplayMessage( p_vout, "%s (%s)", _("Deinterlace on"),
"%s (%s)", _("Deinterlace on"), psz_text ? psz_text : psz_mode ); psz_text ? psz_text : psz_mode );
var_FreeList( &vlist, &tlist ); var_FreeList( &vlist, &tlist );
} }
...@@ -878,13 +865,13 @@ static int PutAction( intf_thread_t *p_intf, int i_action ) ...@@ -878,13 +865,13 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
int i_deinterlace = var_GetInteger( p_vout, "deinterlace" ); int i_deinterlace = var_GetInteger( p_vout, "deinterlace" );
if( i_deinterlace != 0 ) if( i_deinterlace != 0 )
{ {
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, DisplayMessage( p_vout, "%s (%s)", _("Deinterlace on"),
"%s (%s)", _("Deinterlace on"), psz_text ? psz_text : psz_mode ); psz_text ? psz_text : psz_mode );
} }
else else
{ {
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, DisplayMessage( p_vout, "%s (%s)", _("Deinterlace off"),
"%s (%s)", _("Deinterlace off"), psz_text ? psz_text : psz_mode ); psz_text ? psz_text : psz_mode );
} }
var_FreeList( &vlist, &tlist ); var_FreeList( &vlist, &tlist );
...@@ -903,8 +890,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action ) ...@@ -903,8 +890,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
i_pos = var_IncInteger( p_vout, "sub-margin" ); i_pos = var_IncInteger( p_vout, "sub-margin" );
ClearChannels( p_intf, p_vout ); ClearChannels( p_intf, p_vout );
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, DisplayMessage( p_vout, _( "Subtitle position %d px" ), i_pos );
_( "Subtitle position %d px" ), i_pos );
break; break;
} }
...@@ -1011,12 +997,11 @@ static void DisplayPosition( intf_thread_t *p_intf, vout_thread_t *p_vout, ...@@ -1011,12 +997,11 @@ static void DisplayPosition( intf_thread_t *p_intf, vout_thread_t *p_vout,
if( time.i_time > 0 ) if( time.i_time > 0 )
{ {
secstotimestr( psz_duration, time.i_time / 1000000 ); secstotimestr( psz_duration, time.i_time / 1000000 );
DisplayMessage( p_vout, POSITION_TEXT_CHAN, "%s / %s", DisplayMessage( p_vout, "%s / %s", psz_time, psz_duration );
psz_time, psz_duration );
} }
else if( i_seconds > 0 ) else if( i_seconds > 0 )
{ {
DisplayMessage( p_vout, POSITION_TEXT_CHAN, "%s", psz_time ); DisplayMessage( p_vout, "%s", psz_time );
} }
if( var_GetBool( p_vout, "fullscreen" ) ) if( var_GetBool( p_vout, "fullscreen" ) )
...@@ -1035,15 +1020,14 @@ static void DisplayVolume( intf_thread_t *p_intf, vout_thread_t *p_vout, ...@@ -1035,15 +1020,14 @@ static void DisplayVolume( intf_thread_t *p_intf, vout_thread_t *p_vout,
ClearChannels( p_intf, p_vout ); ClearChannels( p_intf, p_vout );
if( var_GetBool( p_vout, "fullscreen" ) ) if( var_GetBool( p_vout, "fullscreen" ) )
vout_OSDSlider( p_vout, VOLUME_WIDGET_CHAN, lround(vol * 100.), vout_OSDSlider( p_vout, VOLUME_WIDGET_CHAN, lroundf(vol * 100.f),
OSD_VERT_SLIDER ); OSD_VERT_SLIDER );
DisplayMessage( p_vout, VOLUME_TEXT_CHAN, _( "Volume %ld%%" ), DisplayMessage( p_vout, _( "Volume %ld%%" ), lroundf(vol * 100.f) );
lround(vol * 100.) );
} }
static void DisplayRate( vout_thread_t *p_vout, float f_rate ) static void DisplayRate( vout_thread_t *p_vout, float f_rate )
{ {
DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL, _("Speed: %.2fx"), f_rate ); DisplayMessage( p_vout, _("Speed: %.2fx"), f_rate );
} }
static float AdjustRateFine( vlc_object_t *p_obj, const int i_dir ) static float AdjustRateFine( vlc_object_t *p_obj, const int i_dir )
......
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