Commit eb95c577 authored by Laurent Aimar's avatar Laurent Aimar

Used a vout object for vout_OSDMessage/OSDSlider/OSDIcon.

It reduces the number of executed vlc_object_find.
Some macosx calls have been commented out.
parent 26d4cf78
......@@ -55,10 +55,7 @@ VLC_EXPORT( int, vout_OSDEpg, ( vout_thread_t *, input_item_t * ) );
* \param i_channel Subpicture channel
* \param psz_format printf style formatting
**/
VLC_EXPORT( void, vout_OSDMessage, ( vlc_object_t *, int, const char *, ... ) LIBVLC_FORMAT( 3, 4 ) );
#define vout_OSDMessage( obj, chan, ...) \
vout_OSDMessage( VLC_OBJECT(obj), chan, __VA_ARGS__ )
VLC_EXPORT( void, vout_OSDMessage, ( vout_thread_t *, int, const char *, ... ) LIBVLC_FORMAT( 3, 4 ) );
/**
* Display a slider on the video output.
......@@ -68,7 +65,7 @@ VLC_EXPORT( void, vout_OSDMessage, ( vlc_object_t *, int, const char *, ... ) L
* \param i_type Types are: OSD_HOR_SLIDER and OSD_VERT_SLIDER.
* @see vlc_osd.h
*/
VLC_EXPORT( void, vout_OSDSlider, ( vlc_object_t *, int, int , short ) );
VLC_EXPORT( void, vout_OSDSlider, ( vout_thread_t *, int, int , short ) );
/**
* Display an Icon on the video output.
......@@ -77,7 +74,7 @@ VLC_EXPORT( void, vout_OSDSlider, ( vlc_object_t *, int, int , short ) );
* \param i_type Types are: OSD_PLAY_ICON, OSD_PAUSE_ICON, OSD_SPEAKER_ICON, OSD_MUTE_ICON
* @see vlc_osd.h
*/
VLC_EXPORT( void, vout_OSDIcon, ( vlc_object_t *, int, short ) );
VLC_EXPORT( void, vout_OSDIcon, ( vout_thread_t *, int, short ) );
#ifdef __cplusplus
}
......
......@@ -661,6 +661,14 @@ static int Position( vlc_object_t *p_this, char const *psz_cmd,
return VLC_SUCCESS;
}
#include <vlc_vout.h>
#define OSDMessage(dec, fmt, ...) do { \
vout_thread_t *p_vout = vlc_object_find( dec, VLC_OBJECT_VOUT, FIND_ANYWHERE ); \
if( p_vout ) { \
vout_OSDMessage( p_vout, fmt, __VA_ARGS__ ); \
vlc_object_release( p_vout ); \
} } while(0)
static int EventKey( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
......@@ -683,7 +691,7 @@ static int EventKey( vlc_object_t *p_this, char const *psz_cmd,
if ( !vbi_bcd_digits_greater( p_sys->i_wanted_subpage, 0x00 ) || vbi_bcd_digits_greater( p_sys->i_wanted_subpage, 0x99 ) )
p_sys->i_wanted_subpage = VBI_ANY_SUBNO;
else
vout_OSDMessage( p_this, SPU_DEFAULT_CHANNEL, "%s: %d", _("Subpage"), vbi_bcd2dec( p_sys->i_wanted_subpage) );
OSDMessage( p_this, SPU_DEFAULT_CHANNEL, "%s: %d", _("Subpage"), vbi_bcd2dec( p_sys->i_wanted_subpage) );
p_sys->b_update = true;
vlc_mutex_unlock( &p_sys->lock );
......@@ -697,7 +705,7 @@ static int EventKey( vlc_object_t *p_this, char const *psz_cmd,
p_sys->i_key[0] = p_sys->i_key[1];
p_sys->i_key[1] = p_sys->i_key[2];
p_sys->i_key[2] = (int)(newval.i_int - '0');
vout_OSDMessage( p_this, SPU_DEFAULT_CHANNEL, "%s: %c%c%c", _("Page"), (char)(p_sys->i_key[0]+'0'), (char)(p_sys->i_key[1]+'0'), (char)(p_sys->i_key[2]+'0') );
OSDMessage( p_this, SPU_DEFAULT_CHANNEL, "%s: %c%c%c", _("Page"), (char)(p_sys->i_key[0]+'0'), (char)(p_sys->i_key[1]+'0'), (char)(p_sys->i_key[2]+'0') );
int i_new_page = 0;
......
This diff is collapsed.
......@@ -211,12 +211,12 @@
var_Set( p_playlist, "random", val );
if( val.b_bool )
{
vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Random On" ) );
//vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Random On" ) );
config_PutInt( p_playlist, "random", 1 );
}
else
{
vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Random Off" ) );
//vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Random Off" ) );
config_PutInt( p_playlist, "random", 0 );
}
......@@ -278,7 +278,7 @@
config_PutInt( p_playlist, "loop", 0 );
/* show the change */
vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat One" ) );
//vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat One" ) );
}
else if( repeating.b_bool && !looping.b_bool )
{
......@@ -294,7 +294,7 @@
config_PutInt( p_playlist, "loop", 1 );
/* show the change */
vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat All" ) );
//vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat All" ) );
}
else
{
......@@ -310,7 +310,7 @@
config_PutInt( p_playlist, "loop", 0 );
/* show the change */
vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat Off" ) );
//vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat Off" ) );
}
/* communicate with core and the main intf loop */
......@@ -336,12 +336,12 @@
var_Set( p_playlist, "repeat", val );
if( val.b_bool )
{
vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat One" ) );
//vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat One" ) );
config_PutInt( p_playlist, "repeat", 1 );
}
else
{
vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat Off" ) );
//vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat Off" ) );
config_PutInt( p_playlist, "repeat", 0 );
}
......@@ -364,12 +364,12 @@
var_Set( p_playlist, "loop", val );
if( val.b_bool )
{
vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat All" ) );
//vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat All" ) );
config_PutInt( p_playlist, "loop", 1 );
}
else
{
vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat Off" ) );
//vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat Off" ) );
config_PutInt( p_playlist, "loop", 0 );
}
......
......@@ -36,8 +36,15 @@
void CmdQuit::execute()
{
// Stop the playlist
vout_OSDMessage( getIntf(), SPU_DEFAULT_CHANNEL, "%s", _( "Quit" ) );
if( getIntf()->p_sys->p_input )
{
vout_thread_t *pVout = input_GetVout( getIntf()->p_sys->p_input );
if( pVout )
{
vout_OSDMessage( pVout, SPU_DEFAULT_CHANNEL, "%s", _( "Quit" ) );
vlc_object_release( pVout );
}
}
// Kill libvlc
libvlc_Quit( getIntf()->p_libvlc );
......
......@@ -75,7 +75,13 @@ static int vlclua_osd_icon( lua_State *L )
else
{
vlc_object_t *p_this = vlclua_get_this( L );
vout_OSDIcon( p_this, i_chan, i_icon );
vout_thread_t *p_vout = vlc_object_find( p_this, VLC_OBJECT_VOUT,
FIND_ANYWHERE );
if( p_vout )
{
vout_OSDIcon( p_vout, i_chan, i_icon );
vlc_object_release( p_vout );
}
return 0;
}
}
......@@ -85,7 +91,13 @@ static int vlclua_osd_message( lua_State *L )
const char *psz_message = luaL_checkstring( L, 1 );
int i_chan = luaL_optint( L, 2, SPU_DEFAULT_CHANNEL );
vlc_object_t *p_this = vlclua_get_this( L );
vout_OSDMessage( p_this, i_chan, "%s", psz_message );
vout_thread_t *p_vout = vlc_object_find( p_this, VLC_OBJECT_VOUT,
FIND_ANYWHERE );
if( p_vout )
{
vout_OSDMessage( p_vout, i_chan, "%s", psz_message );
vlc_object_release( p_vout );
}
return 0;
}
......@@ -120,7 +132,13 @@ static int vlclua_osd_slider( lua_State *L )
else
{
vlc_object_t *p_this = vlclua_get_this( L );
vout_OSDSlider( p_this, i_chan, i_position, i_type );
vout_thread_t *p_vout = vlc_object_find( p_this, VLC_OBJECT_VOUT,
FIND_ANYWHERE );
if( p_vout )
{
vout_OSDSlider( p_vout, i_chan, i_position, i_type );
vlc_object_release( p_vout );
}
return 0;
}
}
......
......@@ -851,19 +851,15 @@ static void ThreadDisplayOsdTitle(vout_thread_t *vout, const char *string)
vlc_assert_locked(&vout->p->change_lock);
const mtime_t start = mdate();
const mtime_t stop = start +
INT64_C(1000) * vout->p->title.timeout;
if (stop > start)
vout_ShowTextAbsolute(vout, SPU_DEFAULT_CHANNEL,
if (vout->p->title.timeout > 0)
vout_ShowTextRelative(vout, SPU_DEFAULT_CHANNEL,
string, NULL,
vout->p->title.position,
30 + vout->p->fmt_in.i_width
- vout->p->fmt_in.i_visible_width
- vout->p->fmt_in.i_x_offset,
20 + vout->p->fmt_in.i_y_offset,
start, stop);
INT64_C(1000) * vout->p->title.timeout);
}
static void ThreadChangeFilters(vout_thread_t *vout, const char *filters)
......
......@@ -36,7 +36,7 @@
#include "vout_internal.h"
/**
* \brief Show text on the video for some time
* \brief Show text on the video from a given start date to a given end date
* \param p_vout pointer to the vout the text is to be showed on
* \param i_channel Subpicture channel
* \param psz_string The text to be shown
......@@ -47,35 +47,9 @@
* \param i_duration Amount of time the text is to be shown.
*/
int vout_ShowTextRelative( vout_thread_t *p_vout, int i_channel,
char *psz_string, const text_style_t *p_style,
int i_flags, int i_hmargin, int i_vmargin,
mtime_t i_duration )
{
mtime_t i_now = mdate();
return vout_ShowTextAbsolute( p_vout, i_channel, psz_string,
p_style, i_flags, i_hmargin, i_vmargin,
i_now, i_now + i_duration );
}
/**
* \brief Show text on the video from a given start date to a given end date
* \param p_vout pointer to the vout the text is to be showed on
* \param i_channel Subpicture channel
* \param psz_string The text to be shown
* \param p_style Pointer to a struct with text style info (it is duplicated if non NULL)
* \param i_flags flags for alignment and such
* \param i_hmargin horizontal margin in pixels
* \param i_vmargin vertical margin in pixels
* \param i_start the time when this string is to appear on the video
* \param i_stop the time when this string should stop to be displayed
* if this is 0 the string will be shown untill the next string
* is about to be shown
*/
int vout_ShowTextAbsolute( vout_thread_t *p_vout, int i_channel,
const char *psz_string, const text_style_t *p_style,
int i_flags, int i_hmargin, int i_vmargin,
mtime_t i_start, mtime_t i_stop )
mtime_t i_duration )
{
subpicture_t *p_spu;
video_format_t fmt;
......@@ -87,8 +61,8 @@ int vout_ShowTextAbsolute( vout_thread_t *p_vout, int i_channel,
return VLC_EGENERIC;
p_spu->i_channel = i_channel;
p_spu->i_start = i_start;
p_spu->i_stop = i_stop;
p_spu->i_start = mdate();
p_spu->i_stop = p_spu->i_start + i_duration;
p_spu->b_ephemer = true;
p_spu->b_absolute = false;
p_spu->b_fade = true;
......@@ -119,7 +93,6 @@ int vout_ShowTextAbsolute( vout_thread_t *p_vout, int i_channel,
return VLC_SUCCESS;
}
#undef vout_OSDMessage
/**
* \brief Write an informative message at the default location,
* for the default duration and only if the OSD option is enabled.
......@@ -127,31 +100,26 @@ int vout_ShowTextAbsolute( vout_thread_t *p_vout, int i_channel,
* \param i_channel Subpicture channel
* \param psz_format printf style formatting
**/
void vout_OSDMessage( vlc_object_t *p_caller, int i_channel,
void vout_OSDMessage( vout_thread_t *p_vout, int i_channel,
const char *psz_format, ... )
{
vout_thread_t *p_vout;
char *psz_string = NULL;
va_list args;
if( !var_InheritBool( p_vout, "osd" ) )
return;
if( !var_InheritBool( p_caller, "osd" ) ) return;
va_list args;
va_start( args, psz_format );
p_vout = vlc_object_find( p_caller, VLC_OBJECT_VOUT, FIND_ANYWHERE );
if( p_vout )
char *psz_string;
if( vasprintf( &psz_string, psz_format, args ) != -1 )
{
va_start( args, psz_format );
if( vasprintf( &psz_string, psz_format, args ) != -1 )
{
vout_ShowTextRelative( p_vout, i_channel, psz_string, NULL,
SUBPICTURE_ALIGN_TOP|SUBPICTURE_ALIGN_RIGHT,
30 + p_vout->p->fmt_in.i_width
- p_vout->p->fmt_in.i_visible_width
- p_vout->p->fmt_in.i_x_offset,
20 + p_vout->p->fmt_in.i_y_offset, 1000000 );
free( psz_string );
}
vlc_object_release( p_vout );
va_end( args );
vout_ShowTextRelative( p_vout, i_channel, psz_string, NULL,
SUBPICTURE_ALIGN_TOP|SUBPICTURE_ALIGN_RIGHT,
30 + p_vout->p->fmt_in.i_width
- p_vout->p->fmt_in.i_visible_width
- p_vout->p->fmt_in.i_x_offset,
20 + p_vout->p->fmt_in.i_y_offset, 1000000 );
free( psz_string );
}
va_end( args );
}
......@@ -42,47 +42,36 @@
* Displays an OSD slider.
* Types are: OSD_HOR_SLIDER and OSD_VERT_SLIDER.
*****************************************************************************/
void vout_OSDSlider( vlc_object_t *p_caller, int i_channel, int i_position,
void vout_OSDSlider( vout_thread_t *p_vout, int i_channel, int i_position,
short i_type )
{
vout_thread_t *p_vout = vlc_object_find( p_caller, VLC_OBJECT_VOUT,
FIND_ANYWHERE );
if( !var_InheritBool( p_vout, "osd" ) || i_position < 0 )
return;
if( p_vout && ( var_InheritBool( p_caller, "osd" ) && ( i_position >= 0 ) ) )
{
osd_Slider( p_caller, vout_GetSpu( p_vout ),
p_vout->p->fmt_render.i_width,
p_vout->p->fmt_render.i_height,
p_vout->p->fmt_in.i_x_offset,
p_vout->p->fmt_in.i_height - p_vout->p->fmt_in.i_visible_height
- p_vout->p->fmt_in.i_y_offset,
i_channel, i_position, i_type );
}
vlc_object_release( p_vout );
osd_Slider( VLC_OBJECT( p_vout ), vout_GetSpu( p_vout ),
p_vout->p->fmt_render.i_width,
p_vout->p->fmt_render.i_height,
p_vout->p->fmt_in.i_x_offset,
p_vout->p->fmt_in.i_height - p_vout->p->fmt_in.i_visible_height
- p_vout->p->fmt_in.i_y_offset,
i_channel, i_position, i_type );
}
/*****************************************************************************
* Displays an OSD icon.
* Types are: OSD_PLAY_ICON, OSD_PAUSE_ICON, OSD_SPEAKER_ICON, OSD_MUTE_ICON
*****************************************************************************/
void vout_OSDIcon( vlc_object_t *p_caller, int i_channel, short i_type )
void vout_OSDIcon( vout_thread_t *p_vout, int i_channel, short i_type )
{
vout_thread_t *p_vout = vlc_object_find( p_caller, VLC_OBJECT_VOUT,
FIND_ANYWHERE );
if( !p_vout ) return;
if( var_InheritBool( p_caller, "osd" ) )
{
osd_Icon( p_caller,
vout_GetSpu( p_vout ),
p_vout->p->fmt_render.i_width,
p_vout->p->fmt_render.i_height,
p_vout->p->fmt_in.i_width - p_vout->p->fmt_in.i_visible_width
- p_vout->p->fmt_in.i_x_offset,
p_vout->p->fmt_in.i_y_offset,
i_channel, i_type );
}
vlc_object_release( p_vout );
if( !var_InheritBool( p_vout, "osd" ) )
return;
osd_Icon( VLC_OBJECT( p_vout ),
vout_GetSpu( p_vout ),
p_vout->p->fmt_render.i_width,
p_vout->p->fmt_render.i_height,
p_vout->p->fmt_in.i_width - p_vout->p->fmt_in.i_visible_width
- p_vout->p->fmt_in.i_x_offset,
p_vout->p->fmt_in.i_y_offset,
i_channel, i_type );
}
......@@ -170,9 +170,7 @@ void vout_DisplayWrapper(vout_thread_t *, picture_t *);
int spu_ProcessMouse(spu_t *, const vlc_mouse_t *, const video_format_t *);
/* */
int vout_ShowTextRelative( vout_thread_t *, int, char *, const text_style_t *, int, int, int, mtime_t );
int vout_ShowTextAbsolute( vout_thread_t *, int, const char *, const text_style_t *, int, int, int, mtime_t, mtime_t );
int vout_ShowTextRelative( vout_thread_t *, int, const char *, const text_style_t *, int, int, int, mtime_t );
#endif
......@@ -395,7 +395,7 @@ static int VoutSnapshotPip( vout_thread_t *p_vout, picture_t *p_pic )
static void VoutOsdSnapshot( vout_thread_t *p_vout, picture_t *p_pic, const char *psz_filename )
{
msg_Dbg( p_vout, "snapshot taken (%s)", psz_filename );
vout_OSDMessage( VLC_OBJECT( p_vout ), SPU_DEFAULT_CHANNEL, "%s", psz_filename );
vout_OSDMessage( p_vout, SPU_DEFAULT_CHANNEL, "%s", psz_filename );
if( var_GetBool( p_vout, "snapshot-preview" ) )
{
......
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