* @{
*/
+/**
+ * Vout configuration
+ */
+typedef struct {
+ vout_thread_t *vout;
+ const video_format_t *fmt;
+} vout_configuration_t;
+
/**
* Video ouput thread private structure
*/
* is represented by a video output thread, and described using the following
* structure.
*/
-struct vout_thread_t
-{
+struct vout_thread_t {
VLC_COMMON_MEMBERS
/* Private vout_thread data */
*****************************************************************************/
/**
- * This function will
- * - returns a suitable vout (if requested by a non NULL p_fmt)
- * - recycles an old vout (if given) by either destroying it or by saving it
- * for latter usage.
+ * Returns a suitable vout or release the given one.
*
- * The purpose of this function is to avoid unnecessary creation/destruction of
- * vout (and to allow optional vout reusing).
+ * If cfg->fmt is non NULL and valid, a vout will be returned, reusing cfg->vout
+ * is possible, otherwise it returns NULL.
+ * If cfg->vout is not used, it will be closed and released.
*
- * You can call vout_Request on a vout created by vout_Create or by a previous
- * call to vout_Request.
* You can release the returned value either by vout_Request or vout_Close()
* followed by a vlc_object_release() or shorter vout_CloseAndRelease()
*
- * \param p_this a vlc object
- * \param p_vout a vout candidate
- * \param p_fmt the video format requested or NULL
- * \return a vout if p_fmt is non NULL and the request is successfull, NULL
- * otherwise
- */
-VLC_EXPORT( vout_thread_t *, vout_Request, ( vlc_object_t *p_this, vout_thread_t *p_vout, const video_format_t *p_fmt ) );
-#define vout_Request(a,b,c) vout_Request(VLC_OBJECT(a),b,c)
-
-/**
- * This function will create a suitable vout for a given p_fmt. It will never
- * reuse an already existing unused vout.
- *
- * You have to call either vout_Close or vout_Request on the returned value
- * \param p_this a vlc object to which the returned vout will be attached
- * \param p_fmt the video format requested
- * \return a vout if the request is successfull, NULL otherwise
+ * \param object a vlc object
+ * \param cfg the video configuration requested.
+ * \return a vout
*/
-VLC_EXPORT( vout_thread_t *, vout_Create, ( vlc_object_t *p_this, const video_format_t *p_fmt ) );
-#define vout_Create(a,b) vout_Create(VLC_OBJECT(a),b)
+VLC_EXPORT( vout_thread_t *, vout_Request, ( vlc_object_t *object, const vout_configuration_t *cfg ) );
+#define vout_Request(a,b) vout_Request(VLC_OBJECT(a),b)
/**
- * This function will close a vout created by vout_Create or vout_Request.
+ * This function will close a vout created by vout_Request.
* The associated vout module is closed.
* Note: It is not released yet, you'll have to call vlc_object_release()
* or use the convenient vout_CloseAndRelease().
return VLC_SUCCESS;
}
-/*****************************************************************************
- * vout_Request: find a video output thread, create one, or destroy one.
- *****************************************************************************
- * This function looks for a video output thread matching the current
- * properties. If not found, it spawns a new one.
- *****************************************************************************/
-vout_thread_t *(vout_Request)(vlc_object_t *object, vout_thread_t *vout,
- const video_format_t *fmt)
-{
- if (!fmt) {
- if (vout)
- vout_CloseAndRelease(vout);
- return NULL;
- }
-
- /* If a vout is provided, try reusing it */
- if (vout) {
- spu_Attach(vout->p->p_spu, VLC_OBJECT(vout), false);
- vlc_object_detach(vout);
- vlc_object_attach(vout, object);
- spu_Attach(vout->p->p_spu, VLC_OBJECT(vout), true);
-
- vout_control_cmd_t cmd;
- vout_control_cmd_Init(&cmd, VOUT_CONTROL_REINIT);
- cmd.u.reinit.fmt = fmt;
-
- vout_control_Push(&vout->p->control, &cmd);
- vout_control_WaitEmpty(&vout->p->control);
- if (!vout->p->dead) {
- msg_Dbg(object, "reusing provided vout");
- return vout;
- }
- vout_CloseAndRelease(vout);
-
- msg_Warn(object, "cannot reuse provided vout");
- }
- return vout_Create(object, fmt);
-}
-
-/*****************************************************************************
- * vout_Create: creates a new video output thread
- *****************************************************************************
- * This function creates a new video output thread, and returns a pointer
- * to its description. On error, it returns NULL.
- *****************************************************************************/
-vout_thread_t *(vout_Create)(vlc_object_t *object, const video_format_t *fmt)
+static vout_thread_t *VoutCreate(vlc_object_t *object,
+ const vout_configuration_t *cfg)
{
video_format_t original;
- if (VoutValidateFormat(&original, fmt))
+ if (VoutValidateFormat(&original, cfg->fmt))
return NULL;
/* Allocate descriptor */
return vout;
}
+vout_thread_t *(vout_Request)(vlc_object_t *object,
+ const vout_configuration_t *cfg)
+{
+ vout_thread_t *vout = cfg->vout;
+ if (!cfg->fmt) {
+ if (vout)
+ vout_CloseAndRelease(vout);
+ return NULL;
+ }
+
+ /* If a vout is provided, try reusing it */
+ if (vout) {
+ spu_Attach(vout->p->p_spu, VLC_OBJECT(vout), false);
+ vlc_object_detach(vout);
+ vlc_object_attach(vout, object);
+ spu_Attach(vout->p->p_spu, VLC_OBJECT(vout), true);
+
+ vout_control_cmd_t cmd;
+ vout_control_cmd_Init(&cmd, VOUT_CONTROL_REINIT);
+ cmd.u.cfg = cfg;
+
+ vout_control_Push(&vout->p->control, &cmd);
+ vout_control_WaitEmpty(&vout->p->control);
+ if (!vout->p->dead) {
+ msg_Dbg(object, "reusing provided vout");
+ return vout;
+ }
+ vout_CloseAndRelease(vout);
+
+ msg_Warn(object, "cannot reuse provided vout");
+ }
+ return VoutCreate(object, cfg);
+}
+
/*****************************************************************************
- * vout_Close: Close a vout created by vout_Create.
+ * vout_Close: Close a vout created by VoutCreate.
*****************************************************************************
- * You HAVE to call it on vout created by vout_Create before vlc_object_release.
- * You should NEVER call it on vout not obtained through vout_Create
+ * You HAVE to call it on vout created by VoutCreate before vlc_object_release.
+ * You should NEVER call it on vout not obtained through VoutCreate
* (like with vout_Request or vlc_object_find.)
* You can use vout_CloseAndRelease() as a convenience method.
*****************************************************************************/
}
static int ThreadReinit(vout_thread_t *vout,
- const video_format_t *fmt)
+ const vout_configuration_t *cfg)
{
video_format_t original;
- if (VoutValidateFormat(&original, fmt)) {
+ if (VoutValidateFormat(&original, cfg->fmt)) {
ThreadStop(vout, NULL);
ThreadClean(vout);
return VLC_EGENERIC;
ThreadClean(vout);
return NULL;
case VOUT_CONTROL_REINIT:
- if (ThreadReinit(vout, cmd.u.reinit.fmt))
+ if (ThreadReinit(vout, cmd.u.cfg))
return NULL;
break;
case VOUT_CONTROL_OSD_TITLE: