Commit 6c1771b4 authored by Steve Lhomme's avatar Steve Lhomme
Browse files

display: use an optional callback to reset the pictures

Only 4 modules actually use the Reset Pictures feature to create a new filter
pipeline when they can't handle the source anymore. It's still faster than
closing the module and probing for a new display module.
parent a225373d
......@@ -146,19 +146,6 @@ typedef struct {
* Control query for vout_display_t
*/
enum vout_display_query {
/**
* Asks to reset the internal buffers and picture format.
*
* This occurs after a
* \ref VOUT_DISPLAY_CHANGE_DISPLAY_SIZE,
* \ref VOUT_DISPLAY_CHANGE_DISPLAY_FILLED,
* \ref VOUT_DISPLAY_CHANGE_ZOOM,
* \ref VOUT_DISPLAY_CHANGE_SOURCE_ASPECT or
* \ref VOUT_DISPLAY_CHANGE_SOURCE_CROP
* control query returns an error.
*/
VOUT_DISPLAY_RESET_PICTURES, /* video_format_t * */
#if defined(__OS2__)
/* Ask the module to acknowledge/refuse the fullscreen state change after
* being requested (externally or by VOUT_DISPLAY_EVENT_FULLSCREEN */
......@@ -171,8 +158,7 @@ enum vout_display_query {
* Notifies a change in display size.
*
* \retval VLC_SUCCESS if the display handled the change
* \retval VLC_EGENERIC if a \ref VOUT_DISPLAY_RESET_PICTURES request
* is necessary
* \retval VLC_EGENERIC if a \ref reset_pictures request is necessary
*/
VOUT_DISPLAY_CHANGE_DISPLAY_SIZE,
......@@ -180,8 +166,7 @@ enum vout_display_query {
* Notifies a change of the display fill display flag by the user.
*
* \retval VLC_SUCCESS if the display handled the change
* \retval VLC_EGENERIC if a \ref VOUT_DISPLAY_RESET_PICTURES request
* is necessary
* \retval VLC_EGENERIC if a \ref reset_pictures request is necessary
*/
VOUT_DISPLAY_CHANGE_DISPLAY_FILLED,
......@@ -189,8 +174,7 @@ enum vout_display_query {
* Notifies a change of the user zoom factor.
*
* \retval VLC_SUCCESS if the display handled the change
* \retval VLC_EGENERIC if a \ref VOUT_DISPLAY_RESET_PICTURES request
* is necessary
* \retval VLC_EGENERIC if a \ref reset_pictures request is necessary
*/
VOUT_DISPLAY_CHANGE_ZOOM,
......@@ -198,8 +182,7 @@ enum vout_display_query {
* Notifies a change of the sample aspect ratio.
*
* \retval VLC_SUCCESS if the display handled the change
* \retval VLC_EGENERIC if a \ref VOUT_DISPLAY_RESET_PICTURES request
* is necessary
* \retval VLC_EGENERIC if a \ref reset_pictures request is necessary
*/
VOUT_DISPLAY_CHANGE_SOURCE_ASPECT,
......@@ -210,8 +193,7 @@ enum vout_display_query {
* and video_format_t::i_visible_width/height
*
* \retval VLC_SUCCESS if the display handled the change
* \retval VLC_EGENERIC if a \ref VOUT_DISPLAY_RESET_PICTURES request
* is necessary
* \retval VLC_EGENERIC if a \ref reset_pictures request is necessary
*/
VOUT_DISPLAY_CHANGE_SOURCE_CROP,
};
......@@ -243,9 +225,7 @@ struct vout_display_owner_t {
*
* @param vd vout display context
* @param cfg Initial and current configuration.
* @param fmtp By default, it is equal to vd->source except for the aspect
* ratio which is undefined(0) and is ignored. It can be changed by the module
* to request a different format.
* @param fmtp It can be changed by the module to request a different format.
* @param context XXX: to be defined.
* @return VLC_SUCCESS or a VLC error code
*/
......@@ -318,6 +298,20 @@ struct vlc_display_operations
*/
int (*control)(vout_display_t *, int query, va_list);
/**
* Reset the picture format handled by the module.
* This occurs after a
* \ref VOUT_DISPLAY_CHANGE_DISPLAY_SIZE,
* \ref VOUT_DISPLAY_CHANGE_DISPLAY_FILLED,
* \ref VOUT_DISPLAY_CHANGE_ZOOM,
* \ref VOUT_DISPLAY_CHANGE_SOURCE_ASPECT or
* \ref VOUT_DISPLAY_CHANGE_SOURCE_CROP
* control query returns an error.
*
* \param ftmp video format that the module expects as input
*/
int (*reset_pictures)(vout_display_t *, video_format_t *fmtp);
/**
* Notifies a change of VR/360° viewpoint.
*
......@@ -357,7 +351,7 @@ struct vout_display_t {
* or as close as possible as \ref source.
*
* This can only be changed from the display module activation callback,
* or within a VOUT_DISPLAY_RESET_PICTURES control request.
* or within a \ref reset_pictures request.
*
* By default, it is equal to ::source except for the aspect ratio
* which is undefined(0) and is ignored.
......
......@@ -693,6 +693,16 @@ fail:
sys->next_phase_check = (sys->next_phase_check + 1) % PHASE_CHECK_INTERVAL;
}
static int vd_reset_pictures(vout_display_t *vd, video_format_t *fmt)
{
vout_display_sys_t * const sys = vd->sys;
msg_Warn(vd, "Reset Pictures");
kill_pool(sys);
*fmt = *vd->source; // Take (nearly) whatever source wants to give us
fmt->i_chroma = req_chroma(fmt); // Adjust chroma to something we can actually deal with
return VLC_SUCCESS;
}
static int vd_control(vout_display_t *vd, int query, va_list args)
{
vout_display_sys_t * const sys = vd->sys;
......@@ -713,17 +723,6 @@ static int vd_control(vout_display_t *vd, int query, va_list args)
ret = VLC_SUCCESS;
break;
case VOUT_DISPLAY_RESET_PICTURES:
{
msg_Warn(vd, "Reset Pictures");
kill_pool(sys);
video_format_t *fmt = va_arg(args, video_format_t *);
*fmt = *vd->source; // Take (nearly) whatever source wants to give us
fmt->i_chroma = req_chroma(fmt); // Adjust chroma to something we can actually deal with
ret = VLC_SUCCESS;
break;
}
case VOUT_DISPLAY_CHANGE_ZOOM:
msg_Warn(vd, "Unsupported control query %d", query);
ret = VLC_SUCCESS;
......@@ -1097,7 +1096,7 @@ static int find_display_num(const char * name)
}
static const struct vlc_display_operations ops = {
CloseMmalVout, vd_prepare, vd_display, vd_control, NULL,
CloseMmalVout, vd_prepare, vd_display, vd_control, vd_reset_pictures, NULL,
};
static int OpenMmalVout(vout_display_t *vd, const vout_display_cfg_t *cfg,
......
......@@ -223,36 +223,38 @@ out:
free(ev);
}
static int ResetPictures(vout_display_t *vd, video_format_t *fmt)
{
vout_display_sys_t *sys = vd->sys;
const video_format_t *src= vd->source;
vout_display_place_t place;
msg_Dbg(vd, "resetting pictures");
vout_display_PlacePicture(&place, src, vd->cfg);
fmt->i_width = src->i_width * place.width / src->i_visible_width;
fmt->i_height = src->i_height * place.height / src->i_visible_height;
sys->width = fmt->i_visible_width = place.width;
sys->height = fmt->i_visible_height = place.height;
fmt->i_x_offset = src->i_x_offset * place.width / src->i_visible_width;
fmt->i_y_offset = src->i_y_offset * place.height / src->i_visible_height;
const uint32_t values[] = { place.x, place.y,
place.width, place.height, };
xcb_configure_window(sys->conn, sys->window,
XCB_CONFIG_WINDOW_X|XCB_CONFIG_WINDOW_Y|
XCB_CONFIG_WINDOW_WIDTH|XCB_CONFIG_WINDOW_HEIGHT,
values);
xcb_flush (sys->conn);
return VLC_SUCCESS;
}
static int Control(vout_display_t *vd, int query, va_list ap)
{
vout_display_sys_t *sys = vd->sys;
switch (query)
{
case VOUT_DISPLAY_RESET_PICTURES:
{
video_format_t *fmt = va_arg(ap, video_format_t *);
const video_format_t *src= vd->source;
vout_display_place_t place;
msg_Dbg(vd, "resetting pictures");
vout_display_PlacePicture(&place, src, vd->cfg);
fmt->i_width = src->i_width * place.width / src->i_visible_width;
fmt->i_height = src->i_height * place.height / src->i_visible_height;
sys->width = fmt->i_visible_width = place.width;
sys->height = fmt->i_visible_height = place.height;
fmt->i_x_offset = src->i_x_offset * place.width / src->i_visible_width;
fmt->i_y_offset = src->i_y_offset * place.height / src->i_visible_height;
const uint32_t values[] = { place.x, place.y,
place.width, place.height, };
xcb_configure_window(sys->conn, sys->window,
XCB_CONFIG_WINDOW_X|XCB_CONFIG_WINDOW_Y|
XCB_CONFIG_WINDOW_WIDTH|XCB_CONFIG_WINDOW_HEIGHT,
values);
break;
}
case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
{
vout_display_place_t place;
......@@ -284,7 +286,7 @@ static int Control(vout_display_t *vd, int query, va_list ap)
}
static const struct vlc_display_operations ops = {
Close, Queue, Wait, Control, NULL,
Close, Queue, Wait, Control, ResetPictures, NULL,
};
static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
......
......@@ -477,7 +477,7 @@ static void SetRGBMask(video_format_t *p_fmt)
}
static const struct vlc_display_operations ops = {
Close, Prepare, Display, Control, NULL,
Close, Prepare, Display, Control, NULL, NULL,
};
static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
......@@ -924,8 +924,6 @@ static int Control(vout_display_t *vd, int query, va_list args)
FixSubtitleFormat(sys);
return VLC_SUCCESS;
}
case VOUT_DISPLAY_RESET_PICTURES:
vlc_assert_unreachable();
default:
msg_Warn(vd, "Unknown request in android-display: %d", query);
return VLC_EGENERIC;
......
......@@ -373,7 +373,7 @@ static void Close(vout_display_t *vd)
}
static const struct vlc_display_operations ops = {
Close, Prepare, PictureDisplay, Control, NULL,
Close, Prepare, PictureDisplay, Control, NULL, NULL,
};
/**
......
......@@ -119,7 +119,7 @@ static int SetViewpoint(vout_display_t *vd, const vlc_viewpoint_t *vp)
}
static const struct vlc_display_operations ops = {
Close, PictureRender, PictureDisplay, Control, SetViewpoint,
Close, PictureRender, PictureDisplay, Control, NULL, SetViewpoint,
};
/*****************************************************************************
......@@ -342,7 +342,7 @@ static int Control (vout_display_t *vd, int query, va_list ap)
vout_display_place_t place;
vout_display_PlacePicture(&place, vd->source, &cfg_tmp);
if (unlikely(OpenglLock(sys->gl)))
// don't return an error or we need to handle VOUT_DISPLAY_RESET_PICTURES
// don't return an error or we need to handle reset_pictures
return VLC_SUCCESS;
vout_display_opengl_SetWindowAspectRatio(sys->vgl, (float)place.width / place.height);
......@@ -353,8 +353,6 @@ static int Control (vout_display_t *vd, int query, va_list ap)
return VLC_SUCCESS;
}
case VOUT_DISPLAY_RESET_PICTURES:
vlc_assert_unreachable ();
default:
msg_Err (vd, "Unhandled request %d", query);
return VLC_EGENERIC;
......
......@@ -769,7 +769,7 @@ static int ControlVideo(vout_display_t *vd, int query, va_list args)
}
static const struct vlc_display_operations ops = {
CloseVideo, PrepareVideo, NULL, ControlVideo, NULL,
CloseVideo, PrepareVideo, NULL, ControlVideo, NULL, NULL,
};
static int OpenVideo(vout_display_t *vd, const vout_display_cfg_t *cfg,
......
......@@ -162,7 +162,7 @@ static void ClearScreen(vout_display_sys_t *sys)
}
static const struct vlc_display_operations ops = {
Close, NULL, Display, Control, NULL,
Close, NULL, Display, Control, NULL, NULL,
};
/**
......
......@@ -82,7 +82,7 @@ static void Display(vout_display_t *, picture_t *);
static int Control(vout_display_t *, int, va_list);
static const struct vlc_display_operations ops = {
Close, NULL, Display, Control, NULL,
Close, NULL, Display, Control, NULL, NULL,
};
/*****************************************************************************
......
......@@ -152,7 +152,7 @@ static int SetViewpoint(vout_display_t *vd, const vlc_viewpoint_t *vp)
}
static const struct vlc_display_operations ops = {
Close, PictureRender, PictureDisplay, Control, SetViewpoint,
Close, PictureRender, PictureDisplay, Control, NULL, SetViewpoint,
};
static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
......@@ -281,8 +281,6 @@ static int Control(vout_display_t *vd, int query, va_list ap)
return VLC_SUCCESS;
}
case VOUT_DISPLAY_RESET_PICTURES:
vlc_assert_unreachable ();
default:
msg_Err(vd, "Unknown request %d", query);
return VLC_EGENERIC;
......
......@@ -663,7 +663,7 @@ static void Close(vout_display_t *vd)
}
static const struct vlc_display_operations ops = {
Close, Prepare, Display, Control, NULL,
Close, Prepare, Display, Control, NULL, NULL,
};
/**
......
......@@ -156,7 +156,7 @@ static void Prepare(vout_display_t *vd, picture_t *pic, subpicture_t *subpic, vl
}
static const struct vlc_display_operations ops = {
Close, Prepare, Display, Control, NULL,
Close, Prepare, Display, Control, NULL, NULL,
};
static void PMThread( void *arg )
......@@ -449,9 +449,6 @@ static int Control( vout_display_t *vd, int query, va_list args )
kvaSetup( &sys->kvas );
return VLC_SUCCESS;
}
case VOUT_DISPLAY_RESET_PICTURES:
vlc_assert_unreachable();
}
msg_Err(vd, "Unsupported query(=%d) in vout display KVA", query);
......
......@@ -138,7 +138,7 @@ static int SetViewpoint(vout_display_t *vd, const vlc_viewpoint_t *vp)
}
static const struct vlc_display_operations ops = {
Close, PictureRender, PictureDisplay, Control, SetViewpoint,
Close, PictureRender, PictureDisplay, Control, NULL, SetViewpoint,
};
static int Open (vout_display_t *vd, const vout_display_cfg_t *cfg,
......@@ -394,8 +394,6 @@ static int Control (vout_display_t *vd, int query, va_list ap)
return VLC_SUCCESS;
}
case VOUT_DISPLAY_RESET_PICTURES:
vlc_assert_unreachable ();
default:
msg_Err (vd, "Unknown request in Mac OS X vout display");
return VLC_EGENERIC;
......
......@@ -94,7 +94,7 @@ static int SetViewpoint(vout_display_t *vd, const vlc_viewpoint_t *vp)
}
static const struct vlc_display_operations ops = {
Close, PictureRender, PictureDisplay, Control, SetViewpoint,
Close, PictureRender, PictureDisplay, Control, NULL, SetViewpoint,
};
/**
......@@ -235,10 +235,6 @@ static int Control (vout_display_t *vd, int query, va_list ap)
switch (query)
{
#ifndef NDEBUG
case VOUT_DISPLAY_RESET_PICTURES: // not needed
vlc_assert_unreachable();
#endif
case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
......
......@@ -220,7 +220,7 @@ static vout_window_t *video_splitter_CreateWindow(vlc_object_t *obj,
}
static const struct vlc_display_operations ops = {
vlc_vidsplit_Close, vlc_vidsplit_Prepare, vlc_vidsplit_Display, vlc_vidsplit_Control, NULL,
vlc_vidsplit_Close, vlc_vidsplit_Prepare, vlc_vidsplit_Display, vlc_vidsplit_Control, NULL, NULL,
};
static int vlc_vidsplit_Open(vout_display_t *vd,
......
......@@ -85,7 +85,7 @@ static void Open(vout_display_t *vd, video_format_t *fmt)
}
static const struct vlc_display_operations ops_dummy = {
NULL, NULL, NULL, Control, NULL,
NULL, NULL, NULL, Control, NULL, NULL,
};
static int OpenDummy(vout_display_t *vd, const vout_display_cfg_t *cfg,
......@@ -98,7 +98,7 @@ static int OpenDummy(vout_display_t *vd, const vout_display_cfg_t *cfg,
}
static const struct vlc_display_operations ops_stats = {
NULL, NULL, DisplayStat, Control, NULL,
NULL, NULL, DisplayStat, Control, NULL, NULL,
};
static int OpenStats(vout_display_t *vd, const vout_display_cfg_t *cfg,
......
......@@ -106,7 +106,7 @@ static void Display(vout_display_t *, picture_t *);
static int Control(vout_display_t *, int, va_list);
static const struct vlc_display_operations ops = {
Close, Prepare, Display, Control, NULL,
Close, Prepare, Display, Control, NULL, NULL,
};
/*****************************************************************************
......
......@@ -78,7 +78,7 @@ static void Close(vout_display_t *);
static void UpdateParams(vout_display_t *);
static const struct vlc_display_operations ops = {
Close, PictureRender, PictureDisplay, Control, NULL,
Close, PictureRender, PictureDisplay, Control, NULL, NULL,
};
// Allocates a Vulkan surface and instance for video output.
......@@ -340,9 +340,6 @@ static int Control(vout_display_t *vd, int query, va_list ap)
switch (query)
{
case VOUT_DISPLAY_RESET_PICTURES:
assert(!"VOUT_DISPLAY_RESET_PICTURES");
case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
......
......@@ -152,35 +152,35 @@ static void Display(vout_display_t *vd, picture_t *pic)
(void) pic;
}
static int ResetPictures(vout_display_t *vd, video_format_t *fmt)
{
vout_display_place_t place;
video_format_t src;
vout_display_sys_t *sys = vd->sys;
assert(sys->viewport == NULL);
vout_display_PlacePicture(&place, vd->source, vd->cfg);
video_format_ApplyRotation(&src, vd->source);
fmt->i_width = src.i_width * place.width
/ src.i_visible_width;
fmt->i_height = src.i_height * place.height
/ src.i_visible_height;
fmt->i_visible_width = place.width;
fmt->i_visible_height = place.height;
fmt->i_x_offset = src.i_x_offset * place.width
/ src.i_visible_width;
fmt->i_y_offset = src.i_y_offset * place.height
/ src.i_visible_height;
return VLC_SUCCESS;
}
static int Control(vout_display_t *vd, int query, va_list ap)
{
vout_display_sys_t *sys = vd->sys;
switch (query)
{
case VOUT_DISPLAY_RESET_PICTURES:
{
video_format_t *fmt = va_arg(ap, video_format_t *);
vout_display_place_t place;
video_format_t src;
assert(sys->viewport == NULL);
vout_display_PlacePicture(&place, vd->source, vd->cfg);
video_format_ApplyRotation(&src, vd->source);
fmt->i_width = src.i_width * place.width
/ src.i_visible_width;
fmt->i_height = src.i_height * place.height
/ src.i_visible_height;
fmt->i_visible_width = place.width;
fmt->i_visible_height = place.height;
fmt->i_x_offset = src.i_x_offset * place.width
/ src.i_visible_width;
fmt->i_y_offset = src.i_y_offset * place.height
/ src.i_visible_height;
break;
}
case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
case VOUT_DISPLAY_CHANGE_ZOOM:
......@@ -263,7 +263,7 @@ static void Close(vout_display_t *vd)
}
static const struct vlc_display_operations ops = {
Close, Prepare, Display, Control, NULL,
Close, Prepare, Display, Control, ResetPictures, NULL, NULL,
};
static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
......
......@@ -153,9 +153,6 @@ int CommonControl(vout_display_t *vd, display_win32_area_t *area, vout_display_s
return VLC_SUCCESS;
}
case VOUT_DISPLAY_RESET_PICTURES:
vlc_assert_unreachable();
default:
return VLC_EGENERIC;
}
......
Supports Markdown
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