[vlc-commits] lua: Use QueueDeactivateCommand when suitable

Hugo Beauzée-Luyssen git at videolan.org
Thu Mar 30 13:56:34 CEST 2017


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Thu Mar 30 13:47:45 2017 +0200| [b56c999353e1d554736a43bb6593e155bcf3a9cf] | committer: Hugo Beauzée-Luyssen

lua: Use QueueDeactivateCommand when suitable

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b56c999353e1d554736a43bb6593e155bcf3a9cf
---

 modules/lua/extension.c        | 16 ++++++++--------
 modules/lua/extension.h        |  1 +
 modules/lua/extension_thread.c |  6 ++++--
 3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/modules/lua/extension.c b/modules/lua/extension.c
index 0a7d5a3..e094799 100644
--- a/modules/lua/extension.c
+++ b/modules/lua/extension.c
@@ -140,12 +140,11 @@ void Close_Extension( vlc_object_t *p_this )
             break;
 
         vlc_mutex_lock( &p_ext->p_sys->command_lock );
-        if( p_ext->p_sys->b_activated == true )
+        if( p_ext->p_sys->b_activated == true && p_ext->p_sys->p_progress_id == NULL )
         {
             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 );
+            // QueueDeactivateCommand will signal the wait condition.
+            QueueDeactivateCommand( p_ext );
         }
         else
         {
@@ -154,9 +153,8 @@ void Close_Extension( vlc_object_t *p_this )
             // 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 );
         }
-
+        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 );
@@ -1061,8 +1059,10 @@ extension_t *vlclua_extension_get( lua_State *L )
 int vlclua_extension_deactivate( lua_State *L )
 {
     extension_t *p_ext = vlclua_extension_get( L );
-    int i_ret = Deactivate( p_ext->p_sys->p_mgr, p_ext );
-    return ( i_ret == VLC_SUCCESS ) ? 1 : 0;
+    vlc_mutex_lock( &p_ext->p_sys->command_lock );
+    bool b_ret = QueueDeactivateCommand( p_ext );
+    vlc_mutex_unlock( &p_ext->p_sys->command_lock );
+    return ( b_ret == true ) ? 1 : 0;
 }
 
 /** Keep an extension alive. This resets the watch timer to 0
diff --git a/modules/lua/extension.h b/modules/lua/extension.h
index 5971ea7..a6ab6a6 100644
--- a/modules/lua/extension.h
+++ b/modules/lua/extension.h
@@ -93,6 +93,7 @@ struct extension_sys_t
 /* Extensions: manager functions */
 int Activate( extensions_manager_t *p_mgr, extension_t * );
 int Deactivate( extensions_manager_t *p_mgr, extension_t * );
+bool QueueDeactivateCommand( extension_t *p_ext );
 void KillExtension( extensions_manager_t *p_mgr, extension_t *p_ext );
 int PushCommand__( extension_t *ext, bool unique, command_type_e cmd, va_list options );
 static inline int PushCommand( extension_t *ext, int cmd, ... )
diff --git a/modules/lua/extension_thread.c b/modules/lua/extension_thread.c
index 92077b2..99b87c3 100644
--- a/modules/lua/extension_thread.c
+++ b/modules/lua/extension_thread.c
@@ -115,7 +115,7 @@ static void FreeCommands( struct command_t *command )
     FreeCommands( next );
 }
 
-static bool QueueDeactivateCommand( extension_t *p_ext )
+bool QueueDeactivateCommand( extension_t *p_ext )
 {
     struct command_t *cmd = calloc( 1, sizeof( struct command_t ) );
     if( unlikely( cmd == NULL ) )
@@ -297,7 +297,9 @@ static void* Run( void *data )
                     if( lua_ExecuteFunction( p_mgr, p_ext, "activate", LUA_END ) < 0 )
                     {
                         msg_Err( p_mgr, "Could not activate extension!" );
-                        Deactivate( p_mgr, p_ext );
+                        vlc_mutex_lock( &p_ext->p_sys->command_lock );
+                        QueueDeactivateCommand( p_ext );
+                        vlc_mutex_unlock( &p_ext->p_sys->command_lock );
                         break;
                     }
                     vlc_mutex_lock( &p_ext->p_sys->command_lock );



More information about the vlc-commits mailing list