- if (old)
- vlc_object_release(old);
- p_ext->p_sys->p_input = p_input ? vlc_object_hold(p_input) : p_input;
- UnlockExtension(p_ext);
+ input_item_t *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_InputItemMetaChanged,
+ inputItemMetaChanged,
+ p_ext );
+ vlc_gc_decref( p_item );
+ }
+ vlc_object_release( old );
+ }
+
+ p_ext->p_sys->p_input = p_input ? vlc_object_hold( p_input )
+ : p_input;
+
+ // Tell the script the input changed
+ if( p_ext->p_sys->i_capabilities & EXT_INPUT_LISTENER )
+ {
+ PushCommandUnique( p_ext, CMD_SET_INPUT );
+ }
+
+ // Track meta fetched events
+ if( p_ext->p_sys->p_input &&
+ p_ext->p_sys->i_capabilities & EXT_META_LISTENER )
+ {
+ p_item = input_GetItem( p_ext->p_sys->p_input );
+ vlc_gc_incref( p_item );
+ vlc_event_attach( &p_item->event_manager,
+ vlc_InputItemMetaChanged,
+ inputItemMetaChanged,
+ p_ext );
+ }