Commit c8209ec1 authored by Laurent Aimar's avatar Laurent Aimar

Converted more commands to vout_control.

parent e4e3c67e
......@@ -39,10 +39,6 @@ enum {
VOUT_CONTROL_STOP,
/* Controls */
VOUT_CONTROL_FULLSCREEN,
VOUT_CONTROL_DISPLAY_FILLED,
VOUT_CONTROL_ZOOM,
VOUT_CONTROL_ON_TOP,
VOUT_CONTROL_SOURCE_ASPECT,
VOUT_CONTROL_SOURCE_CROP_BORDER,
......@@ -63,6 +59,11 @@ enum {
VOUT_CONTROL_RESET,
VOUT_CONTROL_FLUSH, /* time */
VOUT_CONTROL_STEP, /* time_ptr */
VOUT_CONTROL_FULLSCREEN, /* bool */
VOUT_CONTROL_ON_TOP, /* bool */
VOUT_CONTROL_DISPLAY_FILLED, /* bool */
VOUT_CONTROL_ZOOM, /* pair */
};
typedef struct {
......
......@@ -51,6 +51,7 @@
#include "vout_internal.h"
#include "interlacing.h"
#include "postprocessing.h"
#include "display.h"
/*****************************************************************************
* Local prototypes
......@@ -283,7 +284,6 @@ vout_thread_t * (vout_Create)( vlc_object_t *p_parent, video_format_t *p_fmt )
/* Initialize misc stuff */
vout_control_Init( &p_vout->p->control );
p_vout->p->i_changes = 0;
p_vout->p->b_fullscreen = 0;
vout_chrono_Init( &p_vout->p->render, 5, 10000 ); /* Arbitrary initial time */
vout_statistic_Init( &p_vout->p->statistic );
p_vout->p->b_filter_change = 0;
......@@ -560,6 +560,28 @@ spu_t *vout_GetSpu( vout_thread_t *p_vout )
return p_vout->p->p_spu;
}
/* vout_Control* are usable by anyone at anytime */
void vout_ControlChangeFullscreen(vout_thread_t *vout, bool fullscreen)
{
vout_control_PushBool(&vout->p->control, VOUT_CONTROL_FULLSCREEN,
fullscreen);
}
void vout_ControlChangeOnTop(vout_thread_t *vout, bool is_on_top)
{
vout_control_PushBool(&vout->p->control, VOUT_CONTROL_ON_TOP,
is_on_top);
}
void vout_ControlChangeDisplayFilled(vout_thread_t *vout, bool is_filled)
{
vout_control_PushBool(&vout->p->control, VOUT_CONTROL_DISPLAY_FILLED,
is_filled);
}
void vout_ControlChangeZoom(vout_thread_t *vout, int num, int den)
{
vout_control_PushPair(&vout->p->control, VOUT_CONTROL_ZOOM,
num, den);
}
/*****************************************************************************
* InitThread: initialize video output thread
*****************************************************************************
......@@ -938,6 +960,36 @@ static void ThreadStep(vout_thread_t *vout, mtime_t *duration)
}
}
static void ThreadChangeFullscreen(vout_thread_t *vout, bool fullscreen)
{
/* FIXME not sure setting "fullscreen" is good ... */
var_SetBool(vout, "fullscreen", fullscreen);
vout_SetDisplayFullscreen(vout->p->display.vd, fullscreen);
}
static void ThreadChangeOnTop(vout_thread_t *vout, bool is_on_top)
{
vout_SetWindowState(vout->p->display.vd,
is_on_top ? VOUT_WINDOW_STATE_ABOVE :
VOUT_WINDOW_STATE_NORMAL);
}
static void ThreadChangeDisplayFilled(vout_thread_t *vout, bool is_filled)
{
vout_SetDisplayFilled(vout->p->display.vd, is_filled);
}
static void ThreadChangeZoom(vout_thread_t *vout, int num, int den)
{
if (num * 10 < den) {
num = den;
den *= 10;
} else if (num > den * 10) {
num = den * 10;
}
vout_SetDisplayZoom(vout->p->display.vd, num, den);
}
/*****************************************************************************
* Thread: video output thread
......@@ -1013,6 +1065,18 @@ static void *Thread(void *object)
case VOUT_CONTROL_STEP:
ThreadStep(vout, cmd.u.time_ptr);
break;
case VOUT_CONTROL_FULLSCREEN:
ThreadChangeFullscreen(vout, cmd.u.boolean);
break;
case VOUT_CONTROL_ON_TOP:
ThreadChangeOnTop(vout, cmd.u.boolean);
break;
case VOUT_CONTROL_DISPLAY_FILLED:
ThreadChangeDisplayFilled(vout, cmd.u.boolean);
break;
case VOUT_CONTROL_ZOOM:
ThreadChangeZoom(vout, cmd.u.pair.a, cmd.u.pair.b);
break;
default:
break;
}
......
......@@ -130,8 +130,6 @@ struct vout_thread_sys_t
uint16_t i_changes; /**< changes made to the thread.
\see \ref vout_changes */
unsigned b_fullscreen:1; /**< toogle fullscreen display */
unsigned b_on_top:1; /**< stay always on top of other windows */
};
/** \defgroup vout_changes Flags for changes
......@@ -139,20 +137,17 @@ struct vout_thread_sys_t
* thread changed a variable
* @{
*/
/** b_autoscale changed */
#define VOUT_SCALE_CHANGE 0x0008
/** b_on_top changed */
#define VOUT_ON_TOP_CHANGE 0x0010
/** b_fullscreen changed */
#define VOUT_FULLSCREEN_CHANGE 0x0040
/** i_zoom changed */
#define VOUT_ZOOM_CHANGE 0x0080
/** cropping parameters changed */
#define VOUT_CROP_CHANGE 0x1000
/** aspect ratio changed */
#define VOUT_ASPECT_CHANGE 0x2000
/**@}*/
/* TODO to move them to vlc_vout.h */
void vout_ControlChangeFullscreen(vout_thread_t *, bool fullscreen);
void vout_ControlChangeOnTop(vout_thread_t *, bool is_on_top);
void vout_ControlChangeDisplayFilled(vout_thread_t *, bool is_filled);
void vout_ControlChangeZoom(vout_thread_t *, int num, int den);
/* */
void vout_IntfInit( vout_thread_t * );
......
......@@ -334,16 +334,14 @@ void vout_IntfInit( vout_thread_t *p_vout )
text.psz_string = _("Always on top");
var_Change( p_vout, "video-on-top", VLC_VAR_SETTEXT, &text, NULL );
var_AddCallback( p_vout, "video-on-top", OnTopCallback, NULL );
var_TriggerCallback( p_vout, "video-on-top" );
/* Add a variable to indicate whether we want window decoration or not */
var_Create( p_vout, "video-deco", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
/* Add a fullscreen variable */
if( var_CreateGetBoolCommand( p_vout, "fullscreen" ) )
{
/* user requested fullscreen */
p_vout->p->i_changes |= VOUT_FULLSCREEN_CHANGE;
}
var_Create( p_vout, "fullscreen",
VLC_VAR_BOOL | VLC_VAR_DOINHERIT | VLC_VAR_ISCOMMAND );
text.psz_string = _("Fullscreen");
var_Change( p_vout, "fullscreen", VLC_VAR_SETTEXT, &text, NULL );
var_AddCallback( p_vout, "fullscreen", FullscreenCallback, NULL );
......@@ -855,18 +853,10 @@ static int ScalingCallback( vlc_object_t *p_this, char const *psz_cmd,
vout_thread_t *p_vout = (vout_thread_t *)p_this;
(void)oldval; (void)newval; (void)p_data;
vlc_mutex_lock( &p_vout->p->change_lock );
if( !strcmp( psz_cmd, "autoscale" ) )
{
p_vout->p->i_changes |= VOUT_SCALE_CHANGE;
}
vout_ControlChangeDisplayFilled( p_vout, newval.b_bool );
else if( !strcmp( psz_cmd, "scale" ) )
{
p_vout->p->i_changes |= VOUT_ZOOM_CHANGE;
}
vlc_mutex_unlock( &p_vout->p->change_lock );
vout_ControlChangeZoom( p_vout, 1000 * newval.f_float, 1000 );
return VLC_SUCCESS;
}
......@@ -875,13 +865,9 @@ static int OnTopCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
vout_thread_t *p_vout = (vout_thread_t *)p_this;
vlc_mutex_lock( &p_vout->p->change_lock );
p_vout->p->i_changes |= VOUT_ON_TOP_CHANGE;
p_vout->p->b_on_top = newval.b_bool;
vlc_mutex_unlock( &p_vout->p->change_lock );
(void)psz_cmd; (void)oldval; (void)p_data;
vout_ControlChangeOnTop( p_vout, newval.b_bool );
return VLC_SUCCESS;
}
......@@ -889,13 +875,10 @@ static int FullscreenCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
vout_thread_t *p_vout = (vout_thread_t *)p_this;
vlc_value_t val;
(void)psz_cmd; (void)p_data;
if( oldval.b_bool == newval.b_bool )
return VLC_SUCCESS; /* no-op */
p_vout->p->i_changes |= VOUT_FULLSCREEN_CHANGE;
if( oldval.b_bool != newval.b_bool )
vout_ControlChangeFullscreen( p_vout, newval.b_bool );
return VLC_SUCCESS;
}
......
......@@ -162,10 +162,6 @@ int vout_InitWrapper(vout_thread_t *vout)
vout->fmt_in.i_y_offset != source.i_y_offset )
sys->i_changes |= VOUT_CROP_CHANGE;
#warning "vout_InitWrapper: vout_SetWindowState should NOT be called there"
if (sys->b_on_top)
vout_SetWindowState(vd, VOUT_WINDOW_STATE_ABOVE);
/* XXX For non dr case, the current vout implementation force us to
* create at most 1 direct picture (otherwise the buffers will be kept
* referenced even through the Init/End.
......@@ -217,20 +213,9 @@ int vout_ManageWrapper(vout_thread_t *vout)
vout_thread_sys_t *sys = vout->p;
vout_display_t *vd = sys->display.vd;
while (sys->i_changes & (VOUT_FULLSCREEN_CHANGE |
VOUT_ASPECT_CHANGE |
VOUT_ZOOM_CHANGE |
VOUT_SCALE_CHANGE |
VOUT_ON_TOP_CHANGE |
while (sys->i_changes & (VOUT_ASPECT_CHANGE |
VOUT_CROP_CHANGE)) {
/* */
if (sys->i_changes & VOUT_FULLSCREEN_CHANGE) {
sys->b_fullscreen = !sys->b_fullscreen;
var_SetBool(vout, "fullscreen", sys->b_fullscreen);
vout_SetDisplayFullscreen(vd, sys->b_fullscreen);
sys->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
}
if (sys->i_changes & VOUT_ASPECT_CHANGE) {
vout->fmt_out.i_sar_num = vout->fmt_in.i_sar_num;
vout->fmt_out.i_sar_den = vout->fmt_in.i_sar_den;
......@@ -239,34 +224,6 @@ int vout_ManageWrapper(vout_thread_t *vout)
sys->i_changes &= ~VOUT_ASPECT_CHANGE;
}
if (sys->i_changes & VOUT_ZOOM_CHANGE) {
const float zoom = var_GetFloat(vout, "scale");
unsigned den = ZOOM_FP_FACTOR;
unsigned num = den * zoom;
if (num < (ZOOM_FP_FACTOR+9) / 10)
num = (ZOOM_FP_FACTOR+9) / 10;
else if (num > ZOOM_FP_FACTOR * 10)
num = ZOOM_FP_FACTOR * 10;
vout_SetDisplayZoom(vd, num, den);
sys->i_changes &= ~VOUT_ZOOM_CHANGE;
}
if (sys->i_changes & VOUT_SCALE_CHANGE) {
const bool is_display_filled = var_GetBool(vout, "autoscale");
vout_SetDisplayFilled(vd, is_display_filled);
sys->i_changes &= ~VOUT_SCALE_CHANGE;
}
if (sys->i_changes & VOUT_ON_TOP_CHANGE) {
vout_SetWindowState(vd, sys->b_on_top
? VOUT_WINDOW_STATE_ABOVE
: VOUT_WINDOW_STATE_NORMAL);
sys->i_changes &= ~VOUT_ON_TOP_CHANGE;
}
if (sys->i_changes & VOUT_CROP_CHANGE) {
const video_format_t crop = vout->fmt_in;
const video_format_t org = vout->fmt_render;
......
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