Commit acbdb684 authored by Laurent Aimar's avatar Laurent Aimar

Prepared for a better vout reuse.

parent 933b7aa1
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
enum { enum {
VOUT_CONTROL_INIT, VOUT_CONTROL_INIT,
VOUT_CONTROL_CLEAN, VOUT_CONTROL_CLEAN,
VOUT_CONTROL_REINIT, /* reinit */
#if 0 #if 0
/* */ /* */
...@@ -89,6 +90,9 @@ typedef struct { ...@@ -89,6 +90,9 @@ typedef struct {
unsigned width; unsigned width;
unsigned height; unsigned height;
} window; } window;
struct {
const video_format_t *fmt;
} reinit;
} u; } u;
} vout_control_cmd_t; } vout_control_cmd_t;
......
...@@ -98,63 +98,38 @@ static int VoutValidateFormat(video_format_t *dst, ...@@ -98,63 +98,38 @@ static int VoutValidateFormat(video_format_t *dst,
* This function looks for a video output thread matching the current * This function looks for a video output thread matching the current
* properties. If not found, it spawns a new one. * properties. If not found, it spawns a new one.
*****************************************************************************/ *****************************************************************************/
vout_thread_t *(vout_Request)( vlc_object_t *p_this, vout_thread_t *p_vout, vout_thread_t *(vout_Request)( vlc_object_t *object, vout_thread_t *vout,
const video_format_t *p_fmt ) const video_format_t *fmt )
{ {
if( !p_fmt ) if (!fmt) {
{ if (vout)
/* Video output is no longer used. vout_CloseAndRelease(vout);
* TODO: support for reusing video outputs with proper _thread-safe_
* reference handling. */
if( p_vout )
vout_CloseAndRelease( p_vout );
return NULL; return NULL;
} }
/* If a video output was provided, lock it, otherwise look for one. */ /* If a vout is provided, try reusing it */
if( p_vout ) if (vout) {
{ spu_Attach(vout->p->p_spu, VLC_OBJECT(vout), false);
vlc_object_hold( p_vout ); vlc_object_detach(vout);
}
/* TODO: find a suitable unused video output */
/* If we now have a video output, check it has the right properties */
if( p_vout )
{
if( !video_format_IsSimilar( &p_vout->p->original, p_fmt ) )
{
/* We are not interested in this format, close this vout */
vout_CloseAndRelease( p_vout );
vlc_object_release( p_vout );
p_vout = NULL;
}
else
{
/* This video output is cool! Hijack it. */
vlc_object_release( p_vout );
}
if( p_vout ) vout_control_cmd_t cmd;
{ vout_control_cmd_Init(&cmd, VOUT_CONTROL_REINIT);
msg_Dbg( p_this, "reusing provided vout" ); cmd.u.reinit.fmt = fmt;
spu_Attach( p_vout->p->p_spu, VLC_OBJECT(p_vout), false ); vout_control_Push(&vout->p->control, &cmd);
vlc_object_detach( p_vout ); vout_control_WaitEmpty(&vout->p->control);
if (!vout->p->dead) {
vlc_object_attach(vout, object);
spu_Attach(vout->p->p_spu, VLC_OBJECT(vout), true);
vlc_object_attach( p_vout, p_this ); msg_Dbg(object, "reusing provided vout");
spu_Attach( p_vout->p->p_spu, VLC_OBJECT(p_vout), true ); return vout;
} }
} vout_CloseAndRelease(vout);
if( !p_vout )
{
msg_Dbg( p_this, "no usable vout present, spawning one" );
p_vout = vout_Create( p_this, p_fmt ); msg_Warn(object, "cannot reuse provided vout");
} }
return vout_Create(object, fmt);
return p_vout;
} }
/***************************************************************************** /*****************************************************************************
...@@ -958,6 +933,18 @@ static void ThreadClean(vout_thread_t *vout) ...@@ -958,6 +933,18 @@ static void ThreadClean(vout_thread_t *vout)
vout->p->dead = true; vout->p->dead = true;
vout_control_Dead(&vout->p->control); vout_control_Dead(&vout->p->control);
} }
static int ThreadReinit(vout_thread_t *vout,
const video_format_t *fmt)
{
video_format_t original;
if (VoutValidateFormat(&original, fmt))
return VLC_EGENERIC;
if (video_format_IsSimilar(&original, &vout->p->original))
return VLC_SUCCESS;
/* TODO */
return VLC_EGENERIC;
}
/***************************************************************************** /*****************************************************************************
* Thread: video output thread * Thread: video output thread
...@@ -995,6 +982,12 @@ static void *Thread(void *object) ...@@ -995,6 +982,12 @@ static void *Thread(void *object)
case VOUT_CONTROL_CLEAN: case VOUT_CONTROL_CLEAN:
ThreadClean(vout); ThreadClean(vout);
return NULL; return NULL;
case VOUT_CONTROL_REINIT:
if (ThreadReinit(vout, cmd.u.reinit.fmt)) {
ThreadClean(vout);
return NULL;
}
break;
case VOUT_CONTROL_OSD_TITLE: case VOUT_CONTROL_OSD_TITLE:
ThreadDisplayOsdTitle(vout, cmd.u.string); ThreadDisplayOsdTitle(vout, cmd.u.string);
break; break;
......
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