vlc | branch: master | Hugo Beauzée-Luyssen <[email protected]> | Wed Mar 29 16:57:13 2017 +0200| [6a627ce841e9f9d8eb4bc921963b3b77e9ab99ca] | committer: Hugo Beauzée-Luyssen
lua: Properly support reactivation of the extension > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6a627ce841e9f9d8eb4bc921963b3b77e9ab99ca --- modules/lua/extension.c | 20 ++++++++++++++++---- modules/lua/extension_thread.c | 28 ++++++++++++++++++++-------- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/modules/lua/extension.c b/modules/lua/extension.c index e6612e9..0a7d5a3 100644 --- a/modules/lua/extension.c +++ b/modules/lua/extension.c @@ -140,11 +140,23 @@ void Close_Extension( vlc_object_t *p_this ) break; vlc_mutex_lock( &p_ext->p_sys->command_lock ); - bool b_activated = p_ext->p_sys->b_activated; - vlc_mutex_unlock( &p_ext->p_sys->command_lock ); - - if( b_activated == true ) + if( p_ext->p_sys->b_activated == true ) + { + p_ext->p_sys->b_exiting = true; + vlc_mutex_unlock( &p_ext->p_sys->command_lock ); + // DeactivateCommand will signal the wait condition. Deactivate( p_mgr, p_ext ); + } + else + { + if ( p_ext->p_sys->L != NULL ) + vlclua_fd_interrupt( &p_ext->p_sys->dtable ); + // however here we need to manually signal the wait cond, since no command is queued. + p_ext->p_sys->b_exiting = true; + vlc_cond_signal( &p_ext->p_sys->wait ); + vlc_mutex_unlock( &p_ext->p_sys->command_lock ); + } + if( p_ext->p_sys->b_thread_running == true ) vlc_join( p_ext->p_sys->thread, NULL ); diff --git a/modules/lua/extension_thread.c b/modules/lua/extension_thread.c index ef66edc..ed8e431 100644 --- a/modules/lua/extension_thread.c +++ b/modules/lua/extension_thread.c @@ -52,17 +52,30 @@ int Activate( extensions_manager_t *p_mgr, extension_t *p_ext ) struct extension_sys_t *p_sys = p_ext->p_sys; assert( p_sys != NULL ); - msg_Dbg( p_mgr, "Activating extension '%s'", p_ext->psz_title ); + vlc_mutex_lock( &p_sys->command_lock ); + if ( p_sys->b_activated == false ) + { + /* Prepare first command */ + assert(p_sys->command == NULL); + p_sys->command = calloc( 1, sizeof( struct command_t ) ); + if( !p_sys->command ) + { + vlc_mutex_unlock( &p_sys->command_lock ); + return VLC_ENOMEM; + } + p_sys->command->i_command = CMD_ACTIVATE; /* No params */ + if (p_sys->b_thread_running == true) + { + msg_Dbg( p_mgr, "Reactivating extension %s", p_ext->psz_title); + vlc_cond_signal( &p_sys->wait ); + } + } + vlc_mutex_unlock( &p_sys->command_lock ); if (p_sys->b_thread_running == true) return VLC_SUCCESS; - /* Prepare first command */ - p_sys->command = calloc( 1, sizeof( struct command_t ) ); - if( !p_sys->command ) - return VLC_ENOMEM; - p_sys->command->i_command = CMD_ACTIVATE; /* No params */ - + msg_Dbg( p_mgr, "Activating extension '%s'", p_ext->psz_title ); /* Start thread */ p_sys->b_exiting = false; p_sys->b_thread_running = true; @@ -293,7 +306,6 @@ static void* Run( void *data ) p_ext->psz_title ); } vlc_mutex_lock( &p_ext->p_sys->command_lock ); - p_ext->p_sys->b_exiting = true; p_ext->p_sys->b_activated = false; vlc_mutex_unlock( &p_ext->p_sys->command_lock ); break; _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
