extensions: extension_SetInput: use input_item_t

This commit is contained in:
Thomas Guillem 2019-05-31 15:13:55 +02:00
parent 0b288e399c
commit 1cd778c182
3 changed files with 19 additions and 25 deletions

View File

@ -75,7 +75,7 @@ enum
EXTENSION_TRIGGER_ONLY, /**< arg1: extension_t*, arg2: bool* */
EXTENSION_TRIGGER, /**< arg1: extension_t* */
EXTENSION_TRIGGER_MENU, /**< arg1: extension_t*, int (uint16_t) */
EXTENSION_SET_INPUT, /**< arg1: extension_t*, arg2 (input_thread_t*) */
EXTENSION_SET_INPUT, /**< arg1: extension_t*, arg2 (input_item_t*) */
EXTENSION_PLAYING_CHANGED, /**< arg1: extension_t*, arg2 int( playing status ) */
EXTENSION_META_CHANGED, /**< arg1: extension_t*, arg2 (input_item_t*) */
};
@ -149,11 +149,11 @@ static inline int extension_TriggerMenu( extensions_manager_t *p_mgr,
}
/** Trigger an entry of the extension menu */
/* TODO: use player */
static inline int extension_SetInput( extensions_manager_t *p_mgr,
extension_t *p_ext,
struct input_thread_t *p_input )
extension_t *p_ext, input_item_t *p_item )
{
return extension_Control( p_mgr, EXTENSION_SET_INPUT, p_ext, p_input );
return extension_Control( p_mgr, EXTENSION_SET_INPUT, p_ext, p_item );
}
static inline int extension_PlayingChanged( extensions_manager_t *p_mgr,

View File

@ -562,7 +562,7 @@ static int Control( extensions_manager_t *p_mgr, int i_control, va_list args )
case EXTENSION_SET_INPUT:
{
p_ext = va_arg( args, extension_t* );
input_thread_t *p_input = va_arg( args, struct input_thread_t * );
input_item_t *p_item = va_arg( args, struct input_item_t * );
if( p_ext == NULL )
return VLC_EGENERIC;
@ -577,24 +577,21 @@ static int Control( extensions_manager_t *p_mgr, int i_control, va_list args )
vlc_mutex_lock( &p_ext->p_sys->running_lock );
// Change input
input_thread_t *old = p_ext->p_sys->p_input;
input_item_t *p_item;
input_item_t *old = p_ext->p_sys->p_item;
if( old )
{
// Untrack meta fetched events
if( p_ext->p_sys->i_capabilities & EXT_META_LISTENER )
{
p_item = input_GetItem( old );
vlc_event_detach( &p_item->event_manager,
vlc_event_detach( &old->event_manager,
vlc_InputItemMetaChanged,
inputItemMetaChanged,
p_ext );
input_item_Release( p_item );
}
input_Release(old);
input_item_Release( old );
}
p_ext->p_sys->p_input = p_input ? input_Hold(p_input) : NULL;
p_ext->p_sys->p_item = p_item ? input_item_Hold(p_item) : NULL;
// Tell the script the input changed
if( p_ext->p_sys->i_capabilities & EXT_INPUT_LISTENER )
@ -603,11 +600,9 @@ static int Control( extensions_manager_t *p_mgr, int i_control, va_list args )
}
// Track meta fetched events
if( p_ext->p_sys->p_input &&
if( p_ext->p_sys->p_item &&
p_ext->p_sys->i_capabilities & EXT_META_LISTENER )
{
p_item = input_GetItem( p_ext->p_sys->p_input );
input_item_Hold( p_item );
vlc_event_attach( &p_item->event_manager,
vlc_InputItemMetaChanged,
inputItemMetaChanged,
@ -659,16 +654,15 @@ int lua_ExtensionDeactivate( extensions_manager_t *p_mgr, extension_t *p_ext )
vlclua_fd_interrupt( &p_ext->p_sys->dtable );
// Unset and release input objects
if( p_ext->p_sys->p_input )
if( p_ext->p_sys->p_item )
{
if( p_ext->p_sys->i_capabilities & EXT_META_LISTENER )
{
// Release item
input_item_t *p_item = input_GetItem( p_ext->p_sys->p_input );
input_item_Release( p_item );
}
input_Release(p_ext->p_sys->p_input);
p_ext->p_sys->p_input = NULL;
vlc_event_detach( &p_ext->p_sys->p_item->event_manager,
vlc_InputItemMetaChanged,
inputItemMetaChanged,
p_ext );
input_item_Release(p_ext->p_sys->p_item);
p_ext->p_sys->p_item = NULL;
}
int i_ret = lua_ExecuteFunction( p_mgr, p_ext, "deactivate", LUA_END );

View File

@ -66,9 +66,9 @@ struct extension_sys_t
vlc_mutex_t running_lock;
vlc_cond_t wait;
/* The input this extension should use for vlc.input
/* The item this extension should use for vlc.input
* or NULL if it should use playlist's current input */
struct input_thread_t *p_input;
struct input_item_t *p_item;
extensions_manager_t *p_mgr; ///< Parent
/* Queue of commands to execute */