Commit dd066314 authored by Laurent Aimar's avatar Laurent Aimar

Revived vout_Destroy from the dead.

No you CANNOT release a vout by vlc_object_release if you have created
it by vout_Request or vout_Create.
parent 8006b9d9
...@@ -524,12 +524,49 @@ struct vout_thread_t ...@@ -524,12 +524,49 @@ struct vout_thread_t
/***************************************************************************** /*****************************************************************************
* Prototypes * Prototypes
*****************************************************************************/ *****************************************************************************/
/**
* 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.
*
* The purpose of this function is to avoid unnecessary creation/destruction of
* vout (and to allow optional vout reusing).
*
* 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_Destroy.
*
* \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
*/
#define vout_Request(a,b,c) __vout_Request(VLC_OBJECT(a),b,c) #define vout_Request(a,b,c) __vout_Request(VLC_OBJECT(a),b,c)
VLC_EXPORT( vout_thread_t *, __vout_Request, ( vlc_object_t *, vout_thread_t *, video_format_t * ) ); VLC_EXPORT( vout_thread_t *, __vout_Request, ( vlc_object_t *p_this, vout_thread_t *p_vout, video_format_t *p_fmt ) );
/**
* 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_Destroy 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
*/
#define vout_Create(a,b) __vout_Create(VLC_OBJECT(a),b) #define vout_Create(a,b) __vout_Create(VLC_OBJECT(a),b)
VLC_EXPORT( vout_thread_t *, __vout_Create, ( vlc_object_t *, video_format_t * ) ); VLC_EXPORT( vout_thread_t *, __vout_Create, ( vlc_object_t *p_this, video_format_t *p_fmt ) );
VLC_EXPORT( int, vout_VarCallback, ( vlc_object_t *, const char *, vlc_value_t, vlc_value_t, void * ) );
/**
* This function will destroy a vout created by vout_Create or vout_Request.
*
* \param p_vout the vout to destroy
*/
VLC_EXPORT( void, vout_Destroy, ( vout_thread_t *p_vout ) );
/* */
VLC_EXPORT( int, vout_ChromaCmp, ( uint32_t, uint32_t ) ); VLC_EXPORT( int, vout_ChromaCmp, ( uint32_t, uint32_t ) );
VLC_EXPORT( picture_t *, vout_CreatePicture, ( vout_thread_t *, bool, bool, unsigned int ) ); VLC_EXPORT( picture_t *, vout_CreatePicture, ( vout_thread_t *, bool, bool, unsigned int ) );
......
...@@ -481,6 +481,7 @@ vout_ChromaCmp ...@@ -481,6 +481,7 @@ vout_ChromaCmp
vout_ControlWindow vout_ControlWindow
__vout_CopyPicture __vout_CopyPicture
__vout_Create __vout_Create
vout_Destroy
vout_CreatePicture vout_CreatePicture
vout_DatePicture vout_DatePicture
vout_DestroyPicture vout_DestroyPicture
...@@ -501,6 +502,5 @@ vout_ShowTextRelative ...@@ -501,6 +502,5 @@ vout_ShowTextRelative
vout_Snapshot vout_Snapshot
vout_UnlinkPicture vout_UnlinkPicture
vout_vaControlDefault vout_vaControlDefault
vout_VarCallback
__xml_Create __xml_Create
xml_Delete xml_Delete
...@@ -129,13 +129,7 @@ vout_thread_t *__vout_Request( vlc_object_t *p_this, vout_thread_t *p_vout, ...@@ -129,13 +129,7 @@ vout_thread_t *__vout_Request( vlc_object_t *p_this, vout_thread_t *p_vout,
* TODO: support for reusing video outputs with proper _thread-safe_ * TODO: support for reusing video outputs with proper _thread-safe_
* reference handling. */ * reference handling. */
if( p_vout ) if( p_vout )
{ vout_Destroy( p_vout );
spu_Attach( p_vout->p_spu, p_this, false );
vlc_object_kill( p_vout );
vlc_thread_join( p_vout );
module_Unneed( p_vout, p_vout->p_module );
vlc_object_release( p_vout );
}
return NULL; return NULL;
} }
...@@ -447,18 +441,31 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt ) ...@@ -447,18 +441,31 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt )
if( p_vout->b_error ) if( p_vout->b_error )
{ {
msg_Err( p_vout, "video output creation failed" ); msg_Err( p_vout, "video output creation failed" );
vout_Destroy( p_vout );
/* Make sure the thread is destroyed and data released */
vlc_object_kill( p_vout );
vlc_thread_join( p_vout );
module_Unneed( p_vout, p_vout->p_module );
vlc_object_release( p_vout );
return NULL; return NULL;
} }
return p_vout; return p_vout;
} }
/*****************************************************************************
* vout_Destroy: destroys a vout created by vout_Create.
*****************************************************************************
* You HAVE to call it on vout created by vout_Create. You should NEVER call
* it on vout not obtained though vout_Create (like with vout_Request or
* vlc_object_find.)
*****************************************************************************/
void vout_Destroy( vout_thread_t *p_vout )
{
assert( p_vout );
vlc_object_kill( p_vout );
vlc_thread_join( p_vout );
module_Unneed( p_vout, p_vout->p_module );
vlc_object_release( p_vout );
}
/* */
static void vout_Destructor( vlc_object_t * p_this ) static void vout_Destructor( vlc_object_t * p_this )
{ {
vout_thread_t *p_vout = (vout_thread_t *)p_this; vout_thread_t *p_vout = (vout_thread_t *)p_this;
...@@ -1386,21 +1393,6 @@ static void MaskToShift( int *pi_left, int *pi_right, uint32_t i_mask ) ...@@ -1386,21 +1393,6 @@ static void MaskToShift( int *pi_left, int *pi_right, uint32_t i_mask )
*pi_right = (8 - i_high + i_low); *pi_right = (8 - i_high + i_low);
} }
/*****************************************************************************
* vout_VarCallback: generic callback for intf variables
*****************************************************************************/
int vout_VarCallback( vlc_object_t * p_this, const char * psz_variable,
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_variable; (void)newval; (void)oldval; (void)p_data;
val.b_bool = true;
var_Set( p_vout, "intf-change", val );
return VLC_SUCCESS;
}
/***************************************************************************** /*****************************************************************************
* Helper thread for object variables callbacks. * Helper thread for object variables callbacks.
* Only used to avoid deadlocks when using the video embedded mode. * Only used to avoid deadlocks when using the video embedded mode.
......
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