[vlc-devel] commit: Load and unload the vout module in the vout thread. (Laurent Aimar )
git version control
git at videolan.org
Tue Sep 1 00:20:40 CEST 2009
vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Tue Sep 1 00:05:40 2009 +0200| [8eeb2a3026a47608d221b3a24fc9a19ac21f2c03] | committer: Laurent Aimar
Load and unload the vout module in the vout thread.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8eeb2a3026a47608d221b3a24fc9a19ac21f2c03
---
src/video_output/video_output.c | 63 +++++++++++++++++++------------------
src/video_output/vout_internal.h | 4 ++
2 files changed, 36 insertions(+), 31 deletions(-)
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index f4788b3..7e27b5e 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -494,31 +494,21 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt )
/* */
DeinterlaceEnable( p_vout );
- vlc_object_set_destructor( p_vout, vout_Destructor );
+ if( p_vout->p->psz_filter_chain && *p_vout->p->psz_filter_chain )
+ p_vout->p->psz_module_type = "video filter";
+ else
+ p_vout->p->psz_module_type = "video output";
+ p_vout->p->psz_module_name = psz_name;
+ p_vout->p_module = NULL;
/* */
- p_vout->p_module = module_need( p_vout,
- ( p_vout->p->psz_filter_chain && *p_vout->p->psz_filter_chain ) ?
- "video filter" : "video output", psz_name, p_vout->p->psz_filter_chain && *p_vout->p->psz_filter_chain );
- free( psz_name );
-
- if( p_vout->p_module == NULL )
- {
- msg_Err( p_vout, "no suitable vout module" );
- spu_Attach( p_vout->p_spu, VLC_OBJECT(p_vout), false );
- spu_Destroy( p_vout->p_spu );
- p_vout->p_spu = NULL;
- vlc_object_release( p_vout );
- return NULL;
- }
+ vlc_object_set_destructor( p_vout, vout_Destructor );
/* */
vlc_cond_init( &p_vout->p->change_wait );
if( vlc_clone( &p_vout->p->thread, RunThread, p_vout,
VLC_THREAD_PRIORITY_OUTPUT ) )
{
- module_unneed( p_vout, p_vout->p_module );
- p_vout->p_module = NULL;
spu_Attach( p_vout->p_spu, VLC_OBJECT(p_vout), false );
spu_Destroy( p_vout->p_spu );
p_vout->p_spu = NULL;
@@ -565,8 +555,6 @@ void vout_Close( vout_thread_t *p_vout )
vout_snapshot_End( &p_vout->p->snapshot );
vlc_join( p_vout->p->thread, NULL );
- module_unneed( p_vout, p_vout->p_module );
- p_vout->p_module = NULL;
}
/* */
@@ -577,6 +565,8 @@ static void vout_Destructor( vlc_object_t * p_this )
/* Make sure the vout was stopped first */
assert( !p_vout->p_module );
+ free( p_vout->p->psz_module_name );
+
/* */
if( p_vout->p_spu )
spu_Destroy( p_vout->p_spu );
@@ -985,26 +975,30 @@ static void* RunThread( void *p_this )
int i_idle_loops = 0; /* loops without displaying a picture */
int i_picture_qtype_last = QTYPE_NONE;
- bool b_drop_late;
+
+ vlc_mutex_lock( &p_vout->change_lock );
/*
* Initialize thread
*/
- vlc_mutex_lock( &p_vout->change_lock );
- p_vout->b_error = InitThread( p_vout );
-
- b_drop_late = var_CreateGetBool( p_vout, "drop-late-frames" );
+ p_vout->p_module = module_need( p_vout,
+ p_vout->p->psz_module_type,
+ p_vout->p->psz_module_name,
+ !strcmp(p_vout->p->psz_module_type, "video filter") );
+ if( p_vout->p_module )
+ p_vout->b_error = InitThread( p_vout );
+ else
+ p_vout->b_error = true;
/* signal the creation of the vout */
p_vout->p->b_ready = true;
vlc_cond_signal( &p_vout->p->change_wait );
if( p_vout->b_error )
- {
- EndThread( p_vout );
- vlc_mutex_unlock( &p_vout->change_lock );
- return NULL;
- }
+ goto exit_thread;
+
+ /* */
+ const bool b_drop_late = var_CreateGetBool( p_vout, "drop-late-frames" );
/*
* Main loop - it is not executed if an error occurred during
@@ -1311,7 +1305,7 @@ static void* RunThread( void *p_this )
if( p_vout->pf_init( p_vout ) )
{
msg_Err( p_vout, "cannot resize display" );
- /* FIXME: pf_end will be called again in EndThread() */
+ /* FIXME: pf_end will be called again in CleanThread()? */
p_vout->b_error = 1;
}
@@ -1396,11 +1390,18 @@ static void* RunThread( void *p_this )
if( p_vout->b_error )
ErrorThread( p_vout );
- /* End of thread */
+ /* Clean thread */
CleanThread( p_vout );
+
+exit_thread:
+ /* End of thread */
EndThread( p_vout );
vlc_mutex_unlock( &p_vout->change_lock );
+ if( p_vout->p_module )
+ module_unneed( p_vout, p_vout->p_module );
+ p_vout->p_module = NULL;
+
return NULL;
}
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index 1c3106e..c5750b3 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -40,6 +40,10 @@
/* */
struct vout_thread_sys_t
{
+ /* module */
+ const char *psz_module_type;
+ char *psz_module_name;
+
/* Thread & synchronization */
vlc_thread_t thread;
vlc_cond_t change_wait;
More information about the vlc-devel
mailing list