Commit b56c9993 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

lua: Use QueueDeactivateCommand when suitable

parent 6e266f5e
...@@ -140,12 +140,11 @@ void Close_Extension( vlc_object_t *p_this ) ...@@ -140,12 +140,11 @@ void Close_Extension( vlc_object_t *p_this )
break; break;
vlc_mutex_lock( &p_ext->p_sys->command_lock ); 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; p_ext->p_sys->b_exiting = true;
vlc_mutex_unlock( &p_ext->p_sys->command_lock ); // QueueDeactivateCommand will signal the wait condition.
// DeactivateCommand will signal the wait condition. QueueDeactivateCommand( p_ext );
Deactivate( p_mgr, p_ext );
} }
else else
{ {
...@@ -154,9 +153,8 @@ void Close_Extension( vlc_object_t *p_this ) ...@@ -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. // however here we need to manually signal the wait cond, since no command is queued.
p_ext->p_sys->b_exiting = true; p_ext->p_sys->b_exiting = true;
vlc_cond_signal( &p_ext->p_sys->wait ); 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 ) if( p_ext->p_sys->b_thread_running == true )
vlc_join( p_ext->p_sys->thread, NULL ); vlc_join( p_ext->p_sys->thread, NULL );
...@@ -1061,8 +1059,10 @@ extension_t *vlclua_extension_get( lua_State *L ) ...@@ -1061,8 +1059,10 @@ extension_t *vlclua_extension_get( lua_State *L )
int vlclua_extension_deactivate( lua_State *L ) int vlclua_extension_deactivate( lua_State *L )
{ {
extension_t *p_ext = vlclua_extension_get( L ); extension_t *p_ext = vlclua_extension_get( L );
int i_ret = Deactivate( p_ext->p_sys->p_mgr, p_ext ); vlc_mutex_lock( &p_ext->p_sys->command_lock );
return ( i_ret == VLC_SUCCESS ) ? 1 : 0; 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 /** Keep an extension alive. This resets the watch timer to 0
......
...@@ -93,6 +93,7 @@ struct extension_sys_t ...@@ -93,6 +93,7 @@ struct extension_sys_t
/* Extensions: manager functions */ /* Extensions: manager functions */
int Activate( extensions_manager_t *p_mgr, extension_t * ); int Activate( extensions_manager_t *p_mgr, extension_t * );
int Deactivate( 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 ); 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 ); int PushCommand__( extension_t *ext, bool unique, command_type_e cmd, va_list options );
static inline int PushCommand( extension_t *ext, int cmd, ... ) static inline int PushCommand( extension_t *ext, int cmd, ... )
......
...@@ -115,7 +115,7 @@ static void FreeCommands( struct command_t *command ) ...@@ -115,7 +115,7 @@ static void FreeCommands( struct command_t *command )
FreeCommands( next ); 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 ) ); struct command_t *cmd = calloc( 1, sizeof( struct command_t ) );
if( unlikely( cmd == NULL ) ) if( unlikely( cmd == NULL ) )
...@@ -297,7 +297,9 @@ static void* Run( void *data ) ...@@ -297,7 +297,9 @@ static void* Run( void *data )
if( lua_ExecuteFunction( p_mgr, p_ext, "activate", LUA_END ) < 0 ) if( lua_ExecuteFunction( p_mgr, p_ext, "activate", LUA_END ) < 0 )
{ {
msg_Err( p_mgr, "Could not activate extension!" ); 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; break;
} }
vlc_mutex_lock( &p_ext->p_sys->command_lock ); vlc_mutex_lock( &p_ext->p_sys->command_lock );
......
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