[vlc-commits] input: introduce input_Hold() and input_Release()

Rémi Denis-Courmont git at videolan.org
Wed Mar 6 21:57:48 CET 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Mar  6 20:03:08 2019 +0200| [d55765b605d26e89bb81deaca98cfe0fec7916db] | committer: Rémi Denis-Courmont

input: introduce input_Hold() and input_Release()

Type-safe replacements for vlc_object_hold() and vlc_object_release()
(as discussed during the last workshop).

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

 include/vlc_interface.h                            |  2 +-
 include/vlc_objects.h                              | 12 +++++
 lib/audio.c                                        | 10 ++--
 lib/media_player.c                                 | 54 +++++++++++-----------
 lib/video.c                                        | 26 +++++------
 modules/control/dbus/dbus.c                        |  8 ++--
 modules/control/dbus/dbus_player.c                 | 18 ++++----
 modules/control/gestures.c                         | 10 ++--
 modules/control/hotkeys.c                          |  8 ++--
 modules/control/oldrc.c                            | 14 +++---
 .../macosx/coreinteraction/VLCCoreInteraction.m    | 44 +++++++++---------
 .../gui/macosx/coreinteraction/VLCInputManager.m   |  8 ++--
 modules/gui/macosx/extensions/helpers.h            |  2 +-
 modules/gui/macosx/menus/VLCMainMenu.m             |  8 ++--
 modules/gui/macosx/os-integration/applescript.m    | 12 ++---
 .../macosx/panels/VLCBookmarksWindowController.m   | 26 +++++------
 .../VLCTrackSynchronizationWindowController.m      | 12 ++---
 .../windows/mainwindow/VLCControlsBarCommon.m      |  2 +-
 .../gui/macosx/windows/mainwindow/VLCMainWindow.m  |  4 +-
 .../windows/mainwindow/VLCMainWindowControlsBar.m  |  2 +-
 .../macosx/windows/video/VLCFSPanelController.m    |  4 +-
 .../macosx/windows/video/VLCVideoOutputProvider.m  |  2 +-
 modules/gui/ncurses.c                              |  2 +-
 modules/gui/qt/adapters/seekpoints.cpp             |  6 +--
 modules/gui/qt/dialogs/epg.cpp                     |  2 +-
 modules/gui/qt/input_manager.cpp                   |  8 ++--
 modules/gui/qt/menus.cpp                           |  2 +-
 modules/gui/skins2/commands/cmd_dvd.cpp            | 10 ++--
 modules/gui/skins2/commands/cmd_input.cpp          |  2 +-
 modules/gui/skins2/src/vlcproc.cpp                 |  4 +-
 modules/lua/extension.c                            |  7 ++-
 modules/lua/libs/input.c                           | 14 +++---
 modules/lua/libs/objects.c                         | 12 ++++-
 modules/lua/libs/osd.c                             | 12 ++---
 modules/lua/libs/video.c                           |  3 +-
 modules/misc/audioscrobbler.c                      |  6 +--
 src/playlist_legacy/engine.c                       |  2 +-
 37 files changed, 199 insertions(+), 181 deletions(-)

diff --git a/include/vlc_interface.h b/include/vlc_interface.h
index acf82e5938..488ad0532b 100644
--- a/include/vlc_interface.h
+++ b/include/vlc_interface.h
@@ -101,7 +101,7 @@ vlc_intf_GetMainPlaylist(intf_thread_t *intf);
 
 /**
  * Retrieves the current input thread from the playlist.
- * @note The returned object must be released with vlc_object_release().
+ * @note The returned object must be released with input_Release().
  */
 #define pl_CurrentInput(intf) (playlist_CurrentInput(pl_Get(intf)))
 
diff --git a/include/vlc_objects.h b/include/vlc_objects.h
index 843a321e71..de251735cf 100644
--- a/include/vlc_objects.h
+++ b/include/vlc_objects.h
@@ -173,6 +173,18 @@ static inline libvlc_int_t *vlc_object_instance(vlc_object_t *obj)
 }
 #define vlc_object_instance(o) vlc_object_instance(VLC_OBJECT(o))
 
+/* Here for backward compatibility. TODO: Move to <vlc_input.h>! */
+static inline input_thread_t *input_Hold(input_thread_t *input)
+{
+    vlc_object_hold((vlc_object_t *)input);
+    return input;
+}
+
+static inline void input_Release(input_thread_t *input)
+{
+    vlc_object_release((vlc_object_t *)input);
+}
+
 /**
  * @defgroup objres Object resources
  *
diff --git a/lib/audio.c b/lib/audio.c
index f642cee9ee..1842de34f1 100644
--- a/lib/audio.c
+++ b/lib/audio.c
@@ -348,7 +348,7 @@ int libvlc_audio_get_track_count( libvlc_media_player_t *p_mi )
 
     i_track_count = var_CountChoices( p_input_thread, "audio-es" );
 
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
     return i_track_count;
 }
 
@@ -371,7 +371,7 @@ int libvlc_audio_get_track( libvlc_media_player_t *p_mi )
         return -1;
 
     int id = var_GetInteger( p_input_thread, "audio-es" );
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
     return id;
 }
 
@@ -403,7 +403,7 @@ int libvlc_audio_set_track( libvlc_media_player_t *p_mi, int i_track )
     libvlc_printerr( "Track identifier not found" );
 end:
     free( val_list );
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
     return i_ret;
 }
 
@@ -451,7 +451,7 @@ int64_t libvlc_audio_get_delay( libvlc_media_player_t *p_mi )
     if( p_input_thread != NULL )
     {
       val = US_FROM_VLC_TICK( var_GetInteger( p_input_thread, "audio-delay" ) );
-      vlc_object_release( p_input_thread );
+      input_Release(p_input_thread);
     }
     return val;
 }
@@ -466,7 +466,7 @@ int libvlc_audio_set_delay( libvlc_media_player_t *p_mi, int64_t i_delay )
     if( p_input_thread != NULL )
     {
       var_SetInteger( p_input_thread, "audio-delay", VLC_TICK_FROM_US( i_delay ) );
-      vlc_object_release( p_input_thread );
+      input_Release(p_input_thread);
     }
     else
     {
diff --git a/lib/media_player.c b/lib/media_player.c
index c6658270ae..3ffceacf52 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -199,7 +199,7 @@ input_thread_t *libvlc_get_input_thread( libvlc_media_player_t *p_mi )
     lock_input(p_mi);
     p_input_thread = p_mi->input.p_thread;
     if( p_input_thread )
-        vlc_object_hold( p_input_thread );
+        input_Hold(p_input_thread);
     else
         libvlc_printerr( "No active input" );
     unlock_input(p_mi);
@@ -1066,7 +1066,7 @@ void libvlc_media_player_set_pause( libvlc_media_player_t *p_mi, int paused )
         var_SetInteger( p_input_thread, "state", PLAYING_S );
     }
 
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
 }
 
 /**************************************************************************
@@ -1375,7 +1375,7 @@ libvlc_time_t libvlc_media_player_get_length(
         return -1;
 
     i_time = from_mtime(var_GetInteger( p_input_thread, "length" ));
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
 
     return i_time;
 }
@@ -1390,7 +1390,7 @@ libvlc_time_t libvlc_media_player_get_time( libvlc_media_player_t *p_mi )
         return -1;
 
     i_time = from_mtime(var_GetInteger( p_input_thread , "time" ));
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
     return i_time;
 }
 
@@ -1404,7 +1404,7 @@ int libvlc_media_player_set_time( libvlc_media_player_t *p_mi,
         return -1;
 
     input_SetTime( p_input_thread, to_mtime(i_time), b_fast );
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
     return 0;
 }
 
@@ -1418,7 +1418,7 @@ int libvlc_media_player_set_position( libvlc_media_player_t *p_mi,
         return -1;
 
     input_SetPosition( p_input_thread, position, b_fast );
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
     return 0;
 }
 
@@ -1432,7 +1432,7 @@ float libvlc_media_player_get_position( libvlc_media_player_t *p_mi )
         return -1.0;
 
     f_position = var_GetFloat( p_input_thread, "position" );
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
 
     return f_position;
 }
@@ -1447,7 +1447,7 @@ void libvlc_media_player_set_chapter( libvlc_media_player_t *p_mi,
         return;
 
     var_SetInteger( p_input_thread, "chapter", chapter );
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
 }
 
 int libvlc_media_player_get_chapter( libvlc_media_player_t *p_mi )
@@ -1460,7 +1460,7 @@ int libvlc_media_player_get_chapter( libvlc_media_player_t *p_mi )
         return -1;
 
     i_chapter = var_GetInteger( p_input_thread, "chapter" );
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
 
     return i_chapter;
 }
@@ -1475,7 +1475,7 @@ int libvlc_media_player_get_chapter_count( libvlc_media_player_t *p_mi )
         return -1;
 
     int i_ret = var_Change( p_input_thread, "chapter", VLC_VAR_CHOICESCOUNT, &val );
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
 
     return i_ret == VLC_SUCCESS ? (ssize_t)val : -1;
 }
@@ -1494,7 +1494,7 @@ int libvlc_media_player_get_chapter_count_for_title(
     sprintf( psz_name, "title %2u", i_title );
 
     int i_ret = var_Change( p_input_thread, psz_name, VLC_VAR_CHOICESCOUNT, &val );
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
 
     return i_ret == VLC_SUCCESS ? (ssize_t)val : -1;
 }
@@ -1509,7 +1509,7 @@ void libvlc_media_player_set_title( libvlc_media_player_t *p_mi,
         return;
 
     var_SetInteger( p_input_thread, "title", i_title );
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
 
     //send event
     libvlc_event_t event;
@@ -1528,7 +1528,7 @@ int libvlc_media_player_get_title( libvlc_media_player_t *p_mi )
         return -1;
 
     i_title = var_GetInteger( p_input_thread, "title" );
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
 
     return i_title;
 }
@@ -1543,7 +1543,7 @@ int libvlc_media_player_get_title_count( libvlc_media_player_t *p_mi )
         return -1;
 
     int i_ret = var_Change( p_input_thread, "title", VLC_VAR_CHOICESCOUNT, &val );
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
 
     return i_ret == VLC_SUCCESS ? (ssize_t)val : -1;
 }
@@ -1564,7 +1564,7 @@ int libvlc_media_player_get_full_title_descriptions( libvlc_media_player_t *p_mi
     /* fetch data */
     int ret = input_Control( p_input_thread, INPUT_GET_FULL_TITLE_INFO,
                              &p_input_title, &count );
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
     if( ret != VLC_SUCCESS )
         return -1;
 
@@ -1628,7 +1628,7 @@ int libvlc_media_player_get_full_chapter_descriptions( libvlc_media_player_t *p_
     int i_title_count = 0, ci_chapter_count = 0;
     int ret = input_Control( p_input_thread, INPUT_GET_FULL_TITLE_INFO, &pp_title,
                              &i_title_count );
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
 
     if( ret != VLC_SUCCESS || i_chapters_of_title >= i_title_count )
         goto error;
@@ -1722,7 +1722,7 @@ void libvlc_media_player_next_chapter( libvlc_media_player_t *p_mi )
     var_TriggerCallback( p_input_thread, (i_type & VLC_VAR_TYPE) != 0 ?
                             "next-chapter":"next-title" );
 
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
 }
 
 void libvlc_media_player_previous_chapter( libvlc_media_player_t *p_mi )
@@ -1737,7 +1737,7 @@ void libvlc_media_player_previous_chapter( libvlc_media_player_t *p_mi )
     var_TriggerCallback( p_input_thread, (i_type & VLC_VAR_TYPE) != 0 ?
                             "prev-chapter":"prev-title" );
 
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
 }
 
 int libvlc_media_player_will_play( libvlc_media_player_t *p_mi )
@@ -1748,7 +1748,7 @@ int libvlc_media_player_will_play( libvlc_media_player_t *p_mi )
         return false;
 
     int state = var_GetInteger( p_input_thread, "state" );
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
 
     return state != END_S && state != ERROR_S;
 }
@@ -1761,7 +1761,7 @@ int libvlc_media_player_set_rate( libvlc_media_player_t *p_mi, float rate )
     if( !p_input_thread )
         return 0;
     var_SetFloat( p_input_thread, "rate", rate );
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
     return 0;
 }
 
@@ -1787,7 +1787,7 @@ int libvlc_media_player_is_seekable( libvlc_media_player_t *p_mi )
     if ( !p_input_thread )
         return false;
     b_seekable = var_GetBool( p_input_thread, "can-seek" );
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
 
     return b_seekable;
 }
@@ -1809,7 +1809,7 @@ void libvlc_media_player_navigate( libvlc_media_player_t* p_mi,
       return;
 
     input_Control( p_input, map[navigate], NULL );
-    vlc_object_release( p_input );
+    input_Release(p_input);
 }
 
 /* internal function, used by audio, video */
@@ -1850,7 +1850,7 @@ libvlc_track_description_t *
     *pp = NULL;
     free(val_list);
     free(text_list);
-    vlc_object_release( p_input );
+    input_Release(p_input);
 
     return ret;
 }
@@ -1878,7 +1878,7 @@ int libvlc_media_player_can_pause( libvlc_media_player_t *p_mi )
     if ( !p_input_thread )
         return false;
     b_can_pause = var_GetBool( p_input_thread, "can-pause" );
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
 
     return b_can_pause;
 }
@@ -1892,7 +1892,7 @@ int libvlc_media_player_program_scrambled( libvlc_media_player_t *p_mi )
     if ( !p_input_thread )
         return false;
     b_program_scrambled = var_GetBool( p_input_thread, "program-scrambled" );
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
 
     return b_program_scrambled;
 }
@@ -1903,7 +1903,7 @@ void libvlc_media_player_next_frame( libvlc_media_player_t *p_mi )
     if( p_input_thread != NULL )
     {
         var_TriggerCallback( p_input_thread, "frame-next" );
-        vlc_object_release( p_input_thread );
+        input_Release(p_input_thread);
     }
 }
 
@@ -1959,7 +1959,7 @@ int libvlc_media_player_add_slave( libvlc_media_player_t *p_mi,
     {
         int i_ret = input_AddSlave( p_input_thread, (enum slave_type) i_type,
                                     psz_uri, b_select, false, false );
-        vlc_object_release( p_input_thread );
+        input_Release(p_input_thread);
 
         return i_ret == VLC_SUCCESS ? 0 : -1;
     }
diff --git a/lib/video.c b/lib/video.c
index f3445f351b..e5c2d72406 100644
--- a/lib/video.c
+++ b/lib/video.c
@@ -63,7 +63,7 @@ static vout_thread_t **GetVouts( libvlc_media_player_t *p_mi, size_t *n )
         *n = 0;
         pp_vouts = NULL;
     }
-    vlc_object_release (p_input);
+    input_Release(p_input);
     return pp_vouts;
 }
 
@@ -292,10 +292,10 @@ int libvlc_video_update_viewpoint( libvlc_media_player_t *p_mi,
         if( input_UpdateViewpoint( p_input_thread, &update,
                                    b_absolute ) != VLC_SUCCESS )
         {
-            vlc_object_release( p_input_thread );
+            input_Release(p_input_thread);
             return -1;
         }
-        vlc_object_release( p_input_thread );
+        input_Release(p_input_thread);
         return 0;
     }
 
@@ -326,7 +326,7 @@ int libvlc_video_get_spu( libvlc_media_player_t *p_mi )
     }
 
     int i_spu = var_GetInteger( p_input_thread, "spu-es" );
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
     return i_spu;
 }
 
@@ -339,7 +339,7 @@ int libvlc_video_get_spu_count( libvlc_media_player_t *p_mi )
         return 0;
 
     i_spu_count = var_CountChoices( p_input_thread, "spu-es" );
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
     return i_spu_count;
 }
 
@@ -373,7 +373,7 @@ int libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu )
     }
     libvlc_printerr( "Track identifier not found" );
 end:
-    vlc_object_release (p_input_thread);
+    input_Release(p_input_thread);
     free(list);
     return i_ret;
 }
@@ -386,7 +386,7 @@ int64_t libvlc_video_get_spu_delay( libvlc_media_player_t *p_mi )
     if( p_input_thread )
     {
         val = US_FROM_VLC_TICK( var_GetInteger( p_input_thread, "spu-delay" ) );
-        vlc_object_release( p_input_thread );
+        input_Release(p_input_thread);
     }
     else
     {
@@ -405,7 +405,7 @@ int libvlc_video_set_spu_delay( libvlc_media_player_t *p_mi,
     if( p_input_thread )
     {
         var_SetInteger( p_input_thread, "spu-delay", VLC_TICK_FROM_US( i_delay ) );
-        vlc_object_release( p_input_thread );
+        input_Release(p_input_thread);
         ret = 0;
     }
     else
@@ -503,7 +503,7 @@ void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page )
 
     if( var_CountChoices( p_input_thread, "teletext-es" ) <= 0 )
     {
-        vlc_object_release( p_input_thread );
+        input_Release(p_input_thread);
         return;
     }
 
@@ -531,7 +531,7 @@ void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page )
         else
             libvlc_printerr("Key action sent while the teletext is disabled");
     }
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
 }
 
 int libvlc_video_get_track_count( libvlc_media_player_t *p_mi )
@@ -544,7 +544,7 @@ int libvlc_video_get_track_count( libvlc_media_player_t *p_mi )
 
     i_track_count = var_CountChoices( p_input_thread, "video-es" );
 
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
     return i_track_count;
 }
 
@@ -562,7 +562,7 @@ int libvlc_video_get_track( libvlc_media_player_t *p_mi )
         return -1;
 
     int id = var_GetInteger( p_input_thread, "video-es" );
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
     return id;
 }
 
@@ -591,7 +591,7 @@ int libvlc_video_set_track( libvlc_media_player_t *p_mi, int i_track )
     libvlc_printerr( "Track identifier not found" );
 end:
     free(val_list);
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
     return i_ret;
 }
 
diff --git a/modules/control/dbus/dbus.c b/modules/control/dbus/dbus.c
index b8e16805c8..47a67a7f6c 100644
--- a/modules/control/dbus/dbus.c
+++ b/modules/control/dbus/dbus.c
@@ -306,7 +306,7 @@ static void Close   ( vlc_object_t *p_this )
         var_DelCallback( p_sys->p_input, "intf-event", InputCallback, p_intf );
         var_DelCallback( p_sys->p_input, "can-pause", AllCallback, p_intf );
         var_DelCallback( p_sys->p_input, "can-seek", AllCallback, p_intf );
-        vlc_object_release( p_sys->p_input );
+        input_Release(p_sys->p_input);
     }
 
     /* The dbus connection is private, so we are responsible
@@ -592,7 +592,7 @@ static void ProcessEvents( intf_thread_t *p_intf,
             if( p_input )
             {
                 p_item = input_GetItem( p_input );
-                vlc_object_release( p_input );
+                input_Release(p_input);
 
                 if( p_item )
                     vlc_dictionary_insert( &player_properties,
@@ -1080,7 +1080,7 @@ static int TrackChange( intf_thread_t *p_intf )
         var_DelCallback( p_sys->p_input, "intf-event", InputCallback, p_intf );
         var_DelCallback( p_sys->p_input, "can-pause", AllCallback, p_intf );
         var_DelCallback( p_sys->p_input, "can-seek", AllCallback, p_intf );
-        vlc_object_release( p_sys->p_input );
+        input_Release(p_sys->p_input);
         p_sys->p_input = NULL;
     }
 
@@ -1095,7 +1095,7 @@ static int TrackChange( intf_thread_t *p_intf )
     p_item = input_GetItem( p_input );
     if( !p_item )
     {
-        vlc_object_release( p_input );
+        input_Release(p_input);
         return VLC_EGENERIC;
     }
 
diff --git a/modules/control/dbus/dbus_player.c b/modules/control/dbus/dbus_player.c
index 5664b50664..be23a7e83a 100644
--- a/modules/control/dbus/dbus_player.c
+++ b/modules/control/dbus/dbus_player.c
@@ -51,7 +51,7 @@ MarshalPosition( intf_thread_t *p_intf, DBusMessageIter *container )
     else
     {
         i_pos = US_FROM_VLC_TICK(var_GetInteger( p_input, "time" ));
-        vlc_object_release( p_input );
+        input_Release(p_input);
     }
 
     if( !dbus_message_iter_append_basic( container, DBUS_TYPE_INT64, &i_pos ) )
@@ -99,7 +99,7 @@ DBUS_METHOD( SetPosition )
     if( input != NULL )
     {
         var_SetInteger( input, "time", VLC_TICK_FROM_US(i_pos) );
-        vlc_object_release( input );
+        input_Release(input);
     }
 
     REPLY_SEND;
@@ -133,7 +133,7 @@ DBUS_METHOD( Seek )
     }
 
     if( p_input )
-        vlc_object_release( p_input );
+        input_Release(p_input);
 
     REPLY_SEND;
 }
@@ -286,7 +286,7 @@ MarshalCanPause( intf_thread_t *p_intf, DBusMessageIter *container )
     if( p_input )
     {
         b_can_pause = var_GetBool( p_input, "can-pause" );
-        vlc_object_release( p_input );
+        input_Release(p_input);
     }
 
     if( !dbus_message_iter_append_basic( container, DBUS_TYPE_BOOLEAN,
@@ -318,7 +318,7 @@ MarshalCanSeek( intf_thread_t *p_intf, DBusMessageIter *container )
     if( p_input )
     {
         b_can_seek = var_GetBool( p_input, "can-seek" );
-        vlc_object_release( p_input );
+        input_Release(p_input);
     }
 
     if( !dbus_message_iter_append_basic( container, DBUS_TYPE_BOOLEAN,
@@ -374,7 +374,7 @@ MarshalPlaybackStatus( intf_thread_t *p_intf, DBusMessageIter *container )
                 psz_playback_status = PLAYBACK_STATUS_STOPPED;
         }
 
-        vlc_object_release( (vlc_object_t*) p_input );
+        input_Release(p_input);
     }
     else
         psz_playback_status = PLAYBACK_STATUS_STOPPED;
@@ -395,7 +395,7 @@ MarshalRate( intf_thread_t *p_intf, DBusMessageIter *container )
     if( p_input != NULL )
     {
         d_rate = var_GetFloat( p_input, "rate" );
-        vlc_object_release( (vlc_object_t*) p_input );
+        input_Release(p_input);
     }
     else
         d_rate = 1.0;
@@ -420,7 +420,7 @@ DBUS_METHOD( RateSet )
     if( p_input != NULL )
     {
         var_SetFloat( p_input, "rate", (float) d_rate );
-        vlc_object_release( (vlc_object_t*) p_input );
+        input_Release(p_input);
     }
     else
         return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -547,7 +547,7 @@ DBUS_SIGNAL( SeekedSignal )
     if( p_input )
     {
         i_pos = US_FROM_VLC_TICK(var_GetInteger( p_input, "time" ));
-        vlc_object_release( p_input );
+        input_Release(p_input);
     }
 
     ADD_INT64( &i_pos );
diff --git a/modules/control/gestures.c b/modules/control/gestures.c
index 58ecac7bdc..758cbdf39f 100644
--- a/modules/control/gestures.c
+++ b/modules/control/gestures.c
@@ -201,7 +201,7 @@ static void ProcessGesture( intf_thread_t *p_intf )
             int it = var_InheritInteger( p_intf , "short-jump-size" );
             if( it > 0 )
                 var_SetInteger( p_input, "time-offset", vlc_tick_from_sec( -it ) );
-            vlc_object_release( p_input );
+            input_Release(p_input);
             break;
         }
 
@@ -216,7 +216,7 @@ static void ProcessGesture( intf_thread_t *p_intf )
             int it = var_InheritInteger( p_intf , "short-jump-size" );
             if( it > 0 )
                 var_SetInteger( p_input, "time-offset", vlc_tick_from_sec( it ) );
-            vlc_object_release( p_input );
+            input_Release(p_input);
             break;
         }
 
@@ -242,7 +242,7 @@ static void ProcessGesture( intf_thread_t *p_intf )
             int i_state = var_GetInteger( p_input, "state" );
             i_state = (i_state == PLAYING_S) ? PAUSE_S : PLAYING_S;
             var_SetInteger( p_input, "state", i_state );
-            vlc_object_release( p_input );
+            input_Release(p_input);
             break;
         }
 
@@ -304,7 +304,7 @@ static void ProcessGesture( intf_thread_t *p_intf )
                 var_SetInteger( p_input, "audio-es", list[i].i_int );
             }
             free(list);
-            vlc_object_release( p_input );
+            input_Release(p_input);
             break;
         }
 
@@ -342,7 +342,7 @@ static void ProcessGesture( intf_thread_t *p_intf )
                 var_SetInteger( p_input, "audio-es", list[i].i_int );
             }
             free(list);
-            vlc_object_release( p_input );
+            input_Release(p_input);
             break;
         }
 
diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
index 4f211a0f64..46be8124f6 100644
--- a/modules/control/hotkeys.c
+++ b/modules/control/hotkeys.c
@@ -299,7 +299,7 @@ static void ChangeInput( intf_thread_t *p_intf, input_thread_t *p_input )
 
     /* Replace input and vout locked */
     vlc_mutex_lock( &p_sys->lock );
-    p_sys->p_input = p_input ? vlc_object_hold( p_input ) : NULL;
+    p_sys->p_input = p_input ? input_Hold(p_input) : NULL;
     p_sys->p_vout = NULL;
     p_sys->vrnav.b_can_change = false;
     vlc_mutex_unlock( &p_sys->lock );
@@ -309,7 +309,7 @@ static void ChangeInput( intf_thread_t *p_intf, input_thread_t *p_input )
     {
         if( p_old_vout != NULL )
             vlc_object_release( p_old_vout );
-        vlc_object_release( p_old_input );
+        input_Release(p_old_input);
     }
 
     /* Register input events */
@@ -1444,7 +1444,7 @@ static int ActionEvent( vlc_object_t *libvlc, char const *psz_var,
     (void)oldval;
 
     vlc_mutex_lock( &p_intf->p_sys->lock );
-    input_thread_t *p_input = p_sys->p_input ? vlc_object_hold( p_sys->p_input )
+    input_thread_t *p_input = p_sys->p_input ? input_Hold(p_sys->p_input)
                                              : NULL;
     vout_thread_t *p_vout = p_sys->p_vout ? vlc_object_hold( p_sys->p_vout )
                                           : NULL;
@@ -1456,7 +1456,7 @@ static int ActionEvent( vlc_object_t *libvlc, char const *psz_var,
                            newval.i_int );
 
     if( p_input != NULL )
-        vlc_object_release( p_input );
+        input_Release(p_input);
     if( p_vout != NULL )
         vlc_object_release( p_vout );
 
diff --git a/modules/control/oldrc.c b/modules/control/oldrc.c
index 8ee6935830..97d41795bb 100644
--- a/modules/control/oldrc.c
+++ b/modules/control/oldrc.c
@@ -405,7 +405,7 @@ static void Deactivate( vlc_object_t *p_this )
     if( p_sys->p_input != NULL )
     {
         var_DelCallback( p_sys->p_input, "intf-event", InputEvent, p_intf );
-        vlc_object_release( p_sys->p_input );
+        input_Release(p_sys->p_input);
     }
 
     net_ListenClose( p_sys->pi_socket_listen );
@@ -564,7 +564,7 @@ static void *Run( void *data )
           || state == END_S) )
         {
             var_DelCallback( p_sys->p_input, "intf-event", InputEvent, p_intf );
-            vlc_object_release( p_sys->p_input );
+            input_Release(p_sys->p_input);
             p_sys->p_input = NULL;
 
             p_sys->i_last_state = PLAYLIST_STOPPED;
@@ -1164,7 +1164,7 @@ static int Input( vlc_object_t *p_this, char const *psz_cmd,
         free( name );
     }
 out:
-    vlc_object_release( p_input );
+    input_Release(p_input);
     return i_error;
 }
 
@@ -1198,7 +1198,7 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
     if( p_input )
     {
         int state = var_GetInteger( p_input, "state" );
-        vlc_object_release( p_input );
+        input_Release(p_input);
 
         if( state == PAUSE_S )
         {
@@ -1369,7 +1369,7 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
             /* Replay the current state of the system. */
             char *psz_uri =
                     input_item_GetURI( input_GetItem( p_input ) );
-            vlc_object_release( p_input );
+            input_Release(p_input);
             if( likely(psz_uri != NULL) )
             {
                 msg_rc( STATUS_CHANGE "( new input: %s )", psz_uri );
@@ -1498,7 +1498,7 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd,
         return VLC_ENOOBJ;
 
     p_vout = input_GetVout( p_input );
-    vlc_object_release( p_input );
+    input_Release(p_input);
     if( !p_vout )
         return VLC_ENOOBJ;
 
@@ -1705,7 +1705,7 @@ static int Statistics ( vlc_object_t *p_this, char const *psz_cmd,
         return VLC_ENOOBJ;
 
     updateStatistics( p_intf, input_GetItem(p_input) );
-    vlc_object_release( p_input );
+    input_Release(p_input);
     return VLC_SUCCESS;
 }
 
diff --git a/modules/gui/macosx/coreinteraction/VLCCoreInteraction.m b/modules/gui/macosx/coreinteraction/VLCCoreInteraction.m
index e278889e75..e2be092a19 100644
--- a/modules/gui/macosx/coreinteraction/VLCCoreInteraction.m
+++ b/modules/gui/macosx/coreinteraction/VLCCoreInteraction.m
@@ -168,7 +168,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
     p_input = pl_CurrentInput(p_intf);
     if (p_input) {
         var_ToggleBool(p_input, "record");
-        vlc_object_release(p_input);
+        input_Release(p_input);
     }
 }
 
@@ -194,7 +194,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
     p_input = pl_CurrentInput(p_intf);
     if (p_input) {
         f_rate = var_GetFloat(p_input, "rate");
-        vlc_object_release(p_input);
+        input_Release(p_input);
     } else {
         playlist_t * p_playlist = pl_Get(getIntf());
         f_rate = var_GetFloat(p_playlist, "rate");
@@ -234,7 +234,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
         return -1;
 
     i_duration = var_GetInteger(p_input, "length");
-    vlc_object_release(p_input);
+    input_Release(p_input);
 
     return SEC_FROM_VLC_TICK(i_duration);
 }
@@ -251,20 +251,20 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
 
     input_item_t *p_item = input_GetItem(p_input);
     if (!p_item) {
-        vlc_object_release(p_input);
+        input_Release(p_input);
         return nil;
     }
 
     char *psz_uri = input_item_GetURI(p_item);
     if (!psz_uri) {
-        vlc_object_release(p_input);
+        input_Release(p_input);
         return nil;
     }
 
     NSURL *o_url;
     o_url = [NSURL URLWithString:toNSStr(psz_uri)];
     free(psz_uri);
-    vlc_object_release(p_input);
+    input_Release(p_input);
 
     return o_url;
 }
@@ -281,13 +281,13 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
 
     input_item_t *p_item = input_GetItem(p_input);
     if (!p_item) {
-        vlc_object_release(p_input);
+        input_Release(p_input);
         return nil;
     }
 
     char *psz_uri = input_item_GetURI(p_item);
     if (!psz_uri) {
-        vlc_object_release(p_input);
+        input_Release(p_input);
         return nil;
     }
 
@@ -309,7 +309,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
         else
             o_name = [o_url absoluteString];
     }
-    vlc_object_release(p_input);
+    input_Release(p_input);
     return o_name;
 }
 
@@ -326,7 +326,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
             val = val * -1;
         var_SetInteger( p_input, "time-offset", val );
     }
-    vlc_object_release(p_input);
+    input_Release(p_input);
 }
 
 - (void)forwardExtraShort
@@ -434,7 +434,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
             msg_Dbg(getIntf(), "Setting A value");
 
             timeA = var_GetInteger(p_input, "time");
-            vlc_object_release(p_input);
+            input_Release(p_input);
         }
     } else if (!timeB) {
         input_thread_t * p_input = pl_CurrentInput(getIntf());
@@ -442,7 +442,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
             msg_Dbg(getIntf(), "Setting B value");
 
             timeB = var_GetInteger(p_input, "time");
-            vlc_object_release(p_input);
+            input_Release(p_input);
         }
     } else
         [self resetAtoB];
@@ -463,7 +463,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
             vlc_tick_t currentTime = var_GetInteger(p_input, "time");
             if ( currentTime >= timeB || currentTime < timeA)
                 var_SetInteger(p_input, "time", timeA);
-            vlc_object_release(p_input);
+            input_Release(p_input);
         }
     }
 }
@@ -473,7 +473,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
     input_thread_t * p_input = pl_CurrentInput(getIntf());
     if (p_input) {
         var_SetInteger(p_input, "time", time);
-        vlc_object_release(p_input);
+        input_Release(p_input);
     }
 }
 
@@ -568,7 +568,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
             msg_Err(getIntf(), "unable to load subtitles from '%s'", mrl);
         free(mrl);
     }
-    vlc_object_release(p_input);
+    input_Release(p_input);
 }
 
 - (void)showPosition
@@ -580,7 +580,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
             var_SetInteger(vlc_object_instance(getIntf()), "key-action", ACTIONID_POSITION);
             vlc_object_release(p_vout);
         }
-        vlc_object_release(p_input);
+        input_Release(p_input);
     }
 }
 
@@ -621,7 +621,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
         return;
 
     input_Control(p_input_thread, INPUT_NAV_ACTIVATE, NULL );
-    vlc_object_release(p_input_thread);
+    input_Release(p_input_thread);
 }
 
 - (void)moveMenuFocusLeft
@@ -631,7 +631,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
         return;
 
     input_Control(p_input_thread, INPUT_NAV_LEFT, NULL );
-    vlc_object_release(p_input_thread);
+    input_Release(p_input_thread);
 }
 
 - (void)moveMenuFocusRight
@@ -641,7 +641,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
         return;
 
     input_Control(p_input_thread, INPUT_NAV_RIGHT, NULL );
-    vlc_object_release(p_input_thread);
+    input_Release(p_input_thread);
 }
 
 - (void)moveMenuFocusUp
@@ -651,7 +651,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
         return;
 
     input_Control(p_input_thread, INPUT_NAV_UP, NULL );
-    vlc_object_release(p_input_thread);
+    input_Release(p_input_thread);
 }
 
 - (void)moveMenuFocusDown
@@ -661,7 +661,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
         return;
 
     input_Control(p_input_thread, INPUT_NAV_DOWN, NULL );
-    vlc_object_release(p_input_thread);
+    input_Release(p_input_thread);
 }
 
 #pragma mark -
@@ -695,7 +695,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
                     }
                     vlc_object_release(p_vout);
                 }
-                vlc_object_release(p_input);
+                input_Release(p_input);
             }
         }
     }
diff --git a/modules/gui/macosx/coreinteraction/VLCInputManager.m b/modules/gui/macosx/coreinteraction/VLCInputManager.m
index 86115241e3..e9bf60e97e 100644
--- a/modules/gui/macosx/coreinteraction/VLCInputManager.m
+++ b/modules/gui/macosx/coreinteraction/VLCInputManager.m
@@ -197,7 +197,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
         [self storePlaybackPositionForItem:p_current_input];
 
         var_DelCallback(p_current_input, "intf-event", InputEvent, (__bridge void *)self);
-        vlc_object_release(p_current_input);
+        input_Release(p_current_input);
         p_current_input = NULL;
     }
 
@@ -212,7 +212,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
 {
     if (p_current_input) {
         var_DelCallback(p_current_input, "intf-event", InputEvent, (__bridge void *)self);
-        vlc_object_release(p_current_input);
+        input_Release(p_current_input);
         p_current_input = NULL;
 
         [[o_main mainMenu] setRateControlsEnabled: NO];
@@ -237,7 +237,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
             [[o_main mainWindow] changePlaylistState: psPlaylistItemChangedEvent];
         }
 
-        p_input_changed = vlc_object_hold(p_current_input);
+        p_input_changed = input_Hold(p_current_input);
 
 //        [[o_main playlist] currentlyPlayingItemChanged];
 
@@ -261,7 +261,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
     dispatch_async(informInputChangedQueue, ^{
         [[self->o_main extensionsManager] inputChanged:p_input_changed];
         if (p_input_changed)
-            vlc_object_release(p_input_changed);
+            input_Release(p_input_changed);
     });
 }
 
diff --git a/modules/gui/macosx/extensions/helpers.h b/modules/gui/macosx/extensions/helpers.h
index 76c5a2e520..b28e54161e 100644
--- a/modules/gui/macosx/extensions/helpers.h
+++ b/modules/gui/macosx/extensions/helpers.h
@@ -38,7 +38,7 @@ static inline vout_thread_t *getVout(void)
     if (!p_input)
         return NULL;
     vout_thread_t *p_vout = input_GetVout(p_input);
-    vlc_object_release(p_input);
+    input_Release(p_input);
     return p_vout;
 }
 
diff --git a/modules/gui/macosx/menus/VLCMainMenu.m b/modules/gui/macosx/menus/VLCMainMenu.m
index c100b44f4c..e5321af3fc 100644
--- a/modules/gui/macosx/menus/VLCMainMenu.m
+++ b/modules/gui/macosx/menus/VLCMainMenu.m
@@ -602,7 +602,7 @@
             [self refreshVoutDeviceMenu:nil];
         }
         [_postprocessing setEnabled:YES];
-        vlc_object_release(p_input);
+        input_Release(p_input);
     } else {
         [_postprocessing setEnabled:NO];
     }
@@ -965,7 +965,7 @@
 
             vlc_object_release(p_vout);
         }
-        vlc_object_release(p_input);
+        input_Release(p_input);
     }
 }
 
@@ -1021,7 +1021,7 @@
 
     input_item_t *p_item = input_GetItem(p_input);
     if (!p_item) {
-        vlc_object_release(p_input);
+        input_Release(p_input);
         return;
     }
 
@@ -1041,7 +1041,7 @@
     url = [url URLByDeletingLastPathComponent];
     [openPanel setDirectoryURL: url];
     free(path);
-    vlc_object_release(p_input);
+    input_Release(p_input);
 
     i_returnValue = [openPanel runModal];
 
diff --git a/modules/gui/macosx/os-integration/applescript.m b/modules/gui/macosx/os-integration/applescript.m
index 3373e2e5b7..0c92cb3f74 100644
--- a/modules/gui/macosx/os-integration/applescript.m
+++ b/modules/gui/macosx/os-integration/applescript.m
@@ -189,7 +189,7 @@
         return NO;
 
     input_state_e i_state = var_GetInteger(p_input, "state");
-    vlc_object_release(p_input);
+    input_Release(p_input);
 
     return ((i_state == OPENING_S) || (i_state == PLAYING_S));
 }
@@ -210,7 +210,7 @@
         return -1;
 
     i_delay = var_GetInteger(p_input, "audio-delay");
-    vlc_object_release(p_input);
+    input_Release(p_input);
 
     return MS_FROM_VLC_TICK( i_delay );
 }
@@ -221,7 +221,7 @@
         return;
 
     var_SetInteger(p_input, "audio-delay", VLC_TICK_FROM_MS( i_audioDesync ));
-    vlc_object_release(p_input);
+    input_Release(p_input);
 }
 
 - (int) currentTime {
@@ -232,7 +232,7 @@
         return -1;
 
     i_currentTime = var_GetInteger(p_input, "time");
-    vlc_object_release(p_input);
+    input_Release(p_input);
 
     return (int)SEC_FROM_VLC_TICK(i_currentTime);
 }
@@ -247,7 +247,7 @@
 
         input_SetTime(p_input, vlc_tick_from_sec(i64_value),
                       var_GetBool(p_input, "input-fast-seek"));
-        vlc_object_release(p_input);
+        input_Release(p_input);
     }
 }
 
@@ -277,7 +277,7 @@
     /* fetch data */
     int coreret = input_Control(p_input_thread, INPUT_GET_FULL_TITLE_INFO,
                                 &p_input_title, &count);
-    vlc_object_release(p_input_thread);
+    input_Release(p_input_thread);
 
     if (coreret != VLC_SUCCESS)
         return NO;
diff --git a/modules/gui/macosx/panels/VLCBookmarksWindowController.m b/modules/gui/macosx/panels/VLCBookmarksWindowController.m
index 9992050f04..4d9cf88500 100644
--- a/modules/gui/macosx/panels/VLCBookmarksWindowController.m
+++ b/modules/gui/macosx/panels/VLCBookmarksWindowController.m
@@ -59,7 +59,7 @@
 - (void)dealloc
 {
     if (p_old_input)
-        vlc_object_release(p_old_input);
+        input_Release(p_old_input);
 
     [[NSNotificationCenter defaultCenter] removeObserver:self];
 }
@@ -132,7 +132,7 @@
         input_Control(p_input, INPUT_ADD_BOOKMARK, &bookmark);
     }
 
-    vlc_object_release(p_input);
+    input_Release(p_input);
 
     [_dataTable reloadData];
 }
@@ -147,7 +147,7 @@
 
     input_Control(p_input, INPUT_CLEAR_BOOKMARKS);
 
-    vlc_object_release(p_input);
+    input_Release(p_input);
 
     [_dataTable reloadData];
 }
@@ -166,12 +166,12 @@
         return;
 
     if (row < 0) {
-        vlc_object_release(p_input);
+        input_Release(p_input);
         return;
     }
 
     if (input_Control(p_input, INPUT_GET_BOOKMARKS, &pp_bookmarks, &i_bookmarks) != VLC_SUCCESS) {
-        vlc_object_release(p_input);
+        input_Release(p_input);
         return;
     }
 
@@ -182,7 +182,7 @@
      * changes. Note, we don't need to keep a reference to the object.
      * so release it now. */
     p_old_input = p_input;
-    vlc_object_release(p_input);
+    input_Release(p_input);
 
     [self.window beginSheet:_editBookmarksWindow completionHandler:nil];
 
@@ -223,12 +223,12 @@
         [alert setInformativeText:_NS("Input has changed, unable to save bookmark. Suspending playback with \"Pause\" while editing bookmarks to ensure to keep the same input.")];
         [alert beginSheetModalForWindow:self.window
                       completionHandler:nil];
-        vlc_object_release(p_input);
+        input_Release(p_input);
         return;
     }
 
     if (input_Control(p_input, INPUT_GET_BOOKMARKS, &pp_bookmarks, &i_bookmarks) != VLC_SUCCESS) {
-        vlc_object_release(p_input);
+        input_Release(p_input);
         return;
     }
 
@@ -257,7 +257,7 @@
     }
 
     [_dataTable reloadData];
-    vlc_object_release(p_input);
+    input_Release(p_input);
 
     [NSApp endSheet: _editBookmarksWindow];
     [_editBookmarksWindow close];
@@ -279,7 +279,7 @@ clear:
 
     input_Control(p_input, INPUT_SET_BOOKMARK, [_dataTable selectedRow]);
 
-    vlc_object_release(p_input);
+    input_Release(p_input);
 }
 
 - (IBAction)remove:(id)sender
@@ -294,7 +294,7 @@ clear:
     if (i_focused >= 0)
         input_Control(p_input, INPUT_DEL_BOOKMARK, i_focused);
 
-    vlc_object_release(p_input);
+    input_Release(p_input);
 
     [_dataTable reloadData];
 }
@@ -326,7 +326,7 @@ clear:
         return 0;
 
     int returnValue = input_Control(p_input, INPUT_GET_BOOKMARKS, &pp_bookmarks, &i_bookmarks);
-    vlc_object_release(p_input);
+    input_Release(p_input);
 
     if (returnValue != VLC_SUCCESS)
         return 0;
@@ -365,7 +365,7 @@ clear:
             vlc_seekpoint_Delete(pp_bookmarks[i]);
         free(pp_bookmarks);
     }
-    vlc_object_release(p_input);
+    input_Release(p_input);
     return ret;
 }
 
diff --git a/modules/gui/macosx/panels/VLCTrackSynchronizationWindowController.m b/modules/gui/macosx/panels/VLCTrackSynchronizationWindowController.m
index 1aab2b5626..c426b67ed5 100644
--- a/modules/gui/macosx/panels/VLCTrackSynchronizationWindowController.m
+++ b/modules/gui/macosx/panels/VLCTrackSynchronizationWindowController.m
@@ -123,7 +123,7 @@
         var_SetInteger(p_input, "spu-delay", 0);
         var_SetFloat(p_input, "sub-fps", 1.0);
         [self svDurationValueChanged:nil];
-        vlc_object_release(p_input);
+        input_Release(p_input);
     }
 }
 
@@ -135,7 +135,7 @@
         [_av_advanceTextField setDoubleValue: secf_from_vlc_tick(var_GetInteger(p_input, "audio-delay"))];
         [_sv_advanceTextField setDoubleValue: secf_from_vlc_tick(var_GetInteger(p_input, "spu-delay"))];
         [_sv_speedTextField setFloatValue: var_GetFloat(p_input, "sub-fps")];
-        vlc_object_release(p_input);
+        input_Release(p_input);
     }
     [_avStepper setDoubleValue: [_av_advanceTextField doubleValue]];
     [_sv_advanceStepper setDoubleValue: [_sv_advanceTextField doubleValue]];
@@ -153,7 +153,7 @@
 
     if (p_input) {
         var_SetInteger(p_input, "audio-delay", vlc_tick_from_sec([_av_advanceTextField doubleValue]));
-        vlc_object_release(p_input);
+        input_Release(p_input);
     }
 }
 
@@ -168,7 +168,7 @@
 
     if (p_input) {
         var_SetInteger(p_input, "spu-delay", vlc_tick_from_sec([_sv_advanceTextField doubleValue]));
-        vlc_object_release(p_input);
+        input_Release(p_input);
     }
 }
 
@@ -183,7 +183,7 @@
 
     if (p_input) {
         var_SetFloat(p_input, "sub-fps", [_sv_speedTextField floatValue]);
-        vlc_object_release(p_input);
+        input_Release(p_input);
     }
 }
 
@@ -209,7 +209,7 @@
             }
         [VLCVideoFilterHelper setVideoFilter: "subsdelay" on: f_factor > 0];
 
-        vlc_object_release(p_input);
+        input_Release(p_input);
     }
 }
 
diff --git a/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m b/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m
index c9aaf38c3c..cfdc2c6d2a 100644
--- a/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m
+++ b/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m
@@ -340,7 +340,7 @@
         /* chapters & titles */
         //FIXME! b_chapters = p_input->stream.i_area_nb > 1;
 
-        vlc_object_release(p_input);
+        input_Release(p_input);
     }
 
     [self.timeSlider setEnabled: b_seekable];
diff --git a/modules/gui/macosx/windows/mainwindow/VLCMainWindow.m b/modules/gui/macosx/windows/mainwindow/VLCMainWindow.m
index 2581ace9c5..52c38cc741 100644
--- a/modules/gui/macosx/windows/mainwindow/VLCMainWindow.m
+++ b/modules/gui/macosx/windows/mainwindow/VLCMainWindow.m
@@ -628,7 +628,7 @@ static const float f_min_window_height = 307.;
             [self setRepresentedURL: nil];
         }
 
-        vlc_object_release(p_input);
+        input_Release(p_input);
     } else {
         [self setTitle: _NS("VLC media player")];
         [self setRepresentedURL: nil];
@@ -650,7 +650,7 @@ static const float f_min_window_height = 307.;
         /* seekable streams */
         b_seekable = var_GetBool(p_input, "can-seek");
 
-        vlc_object_release(p_input);
+        input_Release(p_input);
     }
 
     if ([self.fspanel respondsToSelector:@selector(setSeekable:)])
diff --git a/modules/gui/macosx/windows/mainwindow/VLCMainWindowControlsBar.m b/modules/gui/macosx/windows/mainwindow/VLCMainWindowControlsBar.m
index 5e9e2ce2b2..dc996fd7e5 100644
--- a/modules/gui/macosx/windows/mainwindow/VLCMainWindowControlsBar.m
+++ b/modules/gui/macosx/windows/mainwindow/VLCMainWindowControlsBar.m
@@ -426,7 +426,7 @@
         /* chapters & titles */
         //FIXME! b_chapters = p_input->stream.i_area_nb > 1;
 
-        vlc_object_release(p_input);
+        input_Release(p_input);
     }
 
     [self.stopButton setEnabled: b_input];
diff --git a/modules/gui/macosx/windows/video/VLCFSPanelController.m b/modules/gui/macosx/windows/video/VLCFSPanelController.m
index ccd8007da1..1c44138dfc 100644
--- a/modules/gui/macosx/windows/video/VLCFSPanelController.m
+++ b/modules/gui/macosx/windows/video/VLCFSPanelController.m
@@ -204,7 +204,7 @@ static NSString *kAssociatedFullscreenRect = @"VLCFullscreenAssociatedWindowRect
         vlc_value_t pos;
         pos.f_float = [_timeSlider floatValue] / 10000.;
         var_Set(p_input, "position", pos);
-        vlc_object_release(p_input);
+        input_Release(p_input);
     }
     [[[VLCMain sharedInstance] mainWindow] updateTimeSlider];
 }
@@ -280,7 +280,7 @@ static NSString *kAssociatedFullscreenRect = @"VLCFullscreenAssociatedWindowRect
     NSString *playbackPosition = toNSStr(secstotimestr(psz_time, (int)SEC_FROM_VLC_TICK(t)));
 
     [_elapsedTime setStringValue:playbackPosition];
-    vlc_object_release(p_input);
+    input_Release(p_input);
 }
 
 - (void)setSeekable:(BOOL)seekable
diff --git a/modules/gui/macosx/windows/video/VLCVideoOutputProvider.m b/modules/gui/macosx/windows/video/VLCVideoOutputProvider.m
index b9e7f0b161..111ee6ab1c 100644
--- a/modules/gui/macosx/windows/video/VLCVideoOutputProvider.m
+++ b/modules/gui/macosx/windows/video/VLCVideoOutputProvider.m
@@ -511,7 +511,7 @@ int WindowOpen(vout_window_t *p_wnd)
 
             }
             if (p_input)
-                vlc_object_release(p_input);
+                input_Release(p_input);
         } else {
             // leaving fullscreen is always allowed
             [o_current_window leaveFullscreenWithAnimation:YES];
diff --git a/modules/gui/ncurses.c b/modules/gui/ncurses.c
index a12a45b853..746ca2c69f 100644
--- a/modules/gui/ncurses.c
+++ b/modules/gui/ncurses.c
@@ -1747,7 +1747,7 @@ static void *Run(void *data)
         Redraw(intf, input);
         HandleKey(intf, input);
         if (input)
-            vlc_object_release(input);
+            input_Release(input);
         vlc_restorecancel(canc);
     }
     vlc_assert_unreachable();
diff --git a/modules/gui/qt/adapters/seekpoints.cpp b/modules/gui/qt/adapters/seekpoints.cpp
index a75012bbf3..a42e91e100 100644
--- a/modules/gui/qt/adapters/seekpoints.cpp
+++ b/modules/gui/qt/adapters/seekpoints.cpp
@@ -44,12 +44,12 @@ void SeekPoints::update()
     if ( input_Control( p_input_thread, INPUT_GET_FULL_TITLE_INFO, &pp_title,
                         &i_title_count ) != VLC_SUCCESS )
     {
-        vlc_object_release( p_input_thread );
+        input_Release(p_input_thread);
         pointsList.clear();
         return;
     }
 
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
 
     if( i_title_id < i_title_count )
         p_title = pp_title[i_title_id];
@@ -93,6 +93,6 @@ bool SeekPoints::jumpTo( int i_chapterindex )
     input_thread_t *p_input_thread = playlist_CurrentInput( THEPL );
     if( !p_input_thread ) return false;
     bool b_succ = var_Set( p_input_thread, "chapter", val );
-    vlc_object_release( p_input_thread );
+    input_Release(p_input_thread);
     return ( b_succ == VLC_SUCCESS );
 }
diff --git a/modules/gui/qt/dialogs/epg.cpp b/modules/gui/qt/dialogs/epg.cpp
index 604752c4ea..2b4b294991 100644
--- a/modules/gui/qt/dialogs/epg.cpp
+++ b/modules/gui/qt/dialogs/epg.cpp
@@ -184,7 +184,7 @@ void EpgDialog::updateInfos()
         p_input_item = input_GetItem( p_input_thread );
         if ( p_input_item ) input_item_Hold( p_input_item );
         PL_UNLOCK;
-        vlc_object_release( p_input_thread );
+        input_Release( p_input_thread );
         if ( p_input_item )
         {
             epg->updateEPG( p_input_item );
diff --git a/modules/gui/qt/input_manager.cpp b/modules/gui/qt/input_manager.cpp
index 67012f4c0e..ade9e328f4 100644
--- a/modules/gui/qt/input_manager.cpp
+++ b/modules/gui/qt/input_manager.cpp
@@ -100,7 +100,7 @@ void InputManager::setInput( input_thread_t *_p_input )
     if( p_input != NULL )
     {
         msg_Dbg( p_intf, "IM: Setting an input" );
-        vlc_object_hold( p_input );
+        input_Hold(p_input);
         addCallbacks();
 
         UpdateStatus();
@@ -187,7 +187,7 @@ void InputManager::delInput()
         p_input_vbi = NULL;
     }
 
-    vlc_object_release( p_input );
+    input_Release( p_input );
     p_input = NULL;
 
     emit positionUpdated( -1.0, 0 ,0 );
@@ -1005,7 +1005,7 @@ MainInputManager::~MainInputManager()
 {
     if( p_input )
     {
-       vlc_object_release( p_input );
+       input_Release(p_input);
        p_input = NULL;
        emit inputChanged( false );
     }
@@ -1086,7 +1086,7 @@ void MainInputManager::customEvent( QEvent *event )
 void MainInputManager::probeCurrentInput()
 {
     if( p_input != NULL )
-        vlc_object_release( p_input );
+        input_Release(p_input);
     p_input = playlist_CurrentInput( THEPL );
     emit inputChanged( p_input != NULL );
 }
diff --git a/modules/gui/qt/menus.cpp b/modules/gui/qt/menus.cpp
index 7efffb4290..0ebfa136b0 100644
--- a/modules/gui/qt/menus.cpp
+++ b/modules/gui/qt/menus.cpp
@@ -1531,7 +1531,7 @@ void VLCMenuBar::DoAction( QObject *data )
         if( input != NULL )
         {
             vout_thread_t *vout = input_GetVout( input );
-            vlc_object_release( input );
+            input_Release(input);
             if( vout != NULL )
             {
                 var_Set( vout, var, val ); /* never void class */
diff --git a/modules/gui/skins2/commands/cmd_dvd.cpp b/modules/gui/skins2/commands/cmd_dvd.cpp
index f540482d1f..eeb180cf40 100644
--- a/modules/gui/skins2/commands/cmd_dvd.cpp
+++ b/modules/gui/skins2/commands/cmd_dvd.cpp
@@ -31,7 +31,7 @@ void CmdDvdNextTitle::execute()
     if( p_input )
     {
         var_TriggerCallback( p_input, "next-title" );
-        vlc_object_release( p_input );
+        input_Release(p_input);
     }
 }
 
@@ -43,7 +43,7 @@ void CmdDvdPreviousTitle::execute()
     if( p_input )
     {
         var_TriggerCallback( p_input, "prev-title" );
-        vlc_object_release( p_input );
+        input_Release(p_input);
     }
 }
 
@@ -55,7 +55,7 @@ void CmdDvdNextChapter::execute()
     if( p_input )
     {
         var_TriggerCallback( p_input, "next-chapter" );
-        vlc_object_release( p_input );
+        input_Release(p_input);
     }
 }
 
@@ -67,7 +67,7 @@ void CmdDvdPreviousChapter::execute()
     if( p_input )
     {
         var_TriggerCallback( p_input, "prev-chapter" );
-        vlc_object_release( p_input );
+        input_Release(p_input);
     }
 }
 
@@ -79,7 +79,7 @@ void CmdDvdRootMenu::execute()
     if( p_input )
     {
         var_SetInteger( p_input, "title  0", 2);
-        vlc_object_release( p_input );
+        input_Release(p_input);
     }
 }
 
diff --git a/modules/gui/skins2/commands/cmd_input.cpp b/modules/gui/skins2/commands/cmd_input.cpp
index e220108784..47ff9094c0 100644
--- a/modules/gui/skins2/commands/cmd_input.cpp
+++ b/modules/gui/skins2/commands/cmd_input.cpp
@@ -35,7 +35,7 @@ void CmdPlay::execute()
     if( pInput )
     {
         var_SetFloat( getPL(), "rate", 1.0 );
-        vlc_object_release( pInput );
+        input_Release(pInput);
     }
 
     playlist_Lock( pPlaylist );
diff --git a/modules/gui/skins2/src/vlcproc.cpp b/modules/gui/skins2/src/vlcproc.cpp
index 7c3223d2ea..86deb91c1a 100644
--- a/modules/gui/skins2/src/vlcproc.cpp
+++ b/modules/gui/skins2/src/vlcproc.cpp
@@ -437,7 +437,7 @@ void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
         msg_Dbg( getIntf(), "new input %p detected", (void *)pInput );
 
         getIntf()->p_sys->p_input = pInput;
-        vlc_object_hold( pInput );
+        input_Hold(pInput);
 
         // update global variables pertaining to this input
         update_current_input();
@@ -535,7 +535,7 @@ void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
             var_DelCallback( pInput, "bit-rate", onGenericCallback, this );
             var_DelCallback( pInput, "sample-rate", onGenericCallback, this );
             var_DelCallback( pInput, "can-record" , onGenericCallback, this );
-            vlc_object_release( pInput );
+            input_Release(pInput);
             getIntf()->p_sys->p_input = NULL;
             reset_input();
             break;
diff --git a/modules/lua/extension.c b/modules/lua/extension.c
index 2d3c9813a9..79ba23b961 100644
--- a/modules/lua/extension.c
+++ b/modules/lua/extension.c
@@ -592,11 +592,10 @@ static int Control( extensions_manager_t *p_mgr, int i_control, va_list args )
                                       p_ext );
                     input_item_Release( p_item );
                 }
-                vlc_object_release( old );
+                input_Release(old);
             }
 
-            p_ext->p_sys->p_input = p_input ? vlc_object_hold( p_input )
-                                            : p_input;
+            p_ext->p_sys->p_input = p_input ? input_Hold(p_input) : NULL;
 
             // Tell the script the input changed
             if( p_ext->p_sys->i_capabilities & EXT_INPUT_LISTENER )
@@ -669,7 +668,7 @@ int lua_ExtensionDeactivate( extensions_manager_t *p_mgr, extension_t *p_ext )
             input_item_t *p_item = input_GetItem( p_ext->p_sys->p_input );
             input_item_Release( p_item );
         }
-        vlc_object_release( p_ext->p_sys->p_input );
+        input_Release(p_ext->p_sys->p_input);
         p_ext->p_sys->p_input = NULL;
     }
 
diff --git a/modules/lua/libs/input.c b/modules/lua/libs/input.c
index ec4679bb38..90a8b5878c 100644
--- a/modules/lua/libs/input.c
+++ b/modules/lua/libs/input.c
@@ -53,7 +53,7 @@ input_thread_t * vlclua_get_input_internal( lua_State *L )
         input_thread_t *p_input = p_extension->p_sys->p_input;
         if( p_input )
         {
-            vlc_object_hold(p_input);
+            input_Hold(p_input);
             return p_input;
         }
     }
@@ -92,7 +92,7 @@ static int vlclua_input_is_playing( lua_State *L )
     input_thread_t * p_input = vlclua_get_input_internal( L );
     lua_pushboolean( L, !!p_input );
     if( p_input )
-        vlc_object_release( p_input );
+        input_Release(p_input);
     return 1;
 }
 
@@ -222,7 +222,7 @@ static int vlclua_input_add_subtitle( lua_State *L, bool b_path )
         return luaL_error( L, "can't add subtitle: no current input" );
     if( !lua_isstring( L, 1 ) )
     {
-        vlc_object_release( p_input );
+        input_Release(p_input);
         return luaL_error( L, "vlc.input.add_subtitle() usage: (path)" );
     }
     if( lua_gettop( L ) >= 2 )
@@ -239,7 +239,7 @@ static int vlclua_input_add_subtitle( lua_State *L, bool b_path )
             free( psz_mrl );
         }
     }
-    vlc_object_release( p_input );
+    input_Release(p_input);
     return 1;
 }
 
@@ -290,13 +290,15 @@ static int vlclua_input_item_get_current( lua_State *L )
     if( !p_item )
     {
         lua_pushnil( L );
-        if( p_input ) vlc_object_release( p_input );
+        if (p_input != NULL)
+            input_Release(p_input);
         return 1;
     }
 
     vlclua_input_item_get( L, p_item );
 
-    if( p_input ) vlc_object_release( p_input );
+    if (p_input != NULL)
+        input_Release(p_input);
     return 1;
 }
 
diff --git a/modules/lua/libs/objects.c b/modules/lua/libs/objects.c
index 4896cda44e..b93a3a0c4e 100644
--- a/modules/lua/libs/objects.c
+++ b/modules/lua/libs/objects.c
@@ -74,6 +74,14 @@ static int vlclua_push_vlc_object(lua_State *L, vlc_object_t *p_obj,
     return 1;
 }
 
+static int vlclua_input_release(lua_State *L)
+{
+    vlc_object_t **pp = luaL_checkudata( L, 1, "vlc_object" );
+    lua_pop(L, 1);
+    input_Release((input_thread_t *)*pp);
+    return 0;
+}
+
 static int vlclua_object_find( lua_State *L )
 {
     lua_pushnil( L );
@@ -101,7 +109,7 @@ static int vlclua_get_input( lua_State *L )
     {
         /* NOTE: p_input is already held by vlclua_get_input_internal() */
         vlclua_push_vlc_object(L, VLC_OBJECT(p_input),
-                               vlclua_object_release);
+                               vlclua_input_release);
     }
     else lua_pushnil( L );
     return 1;
@@ -113,7 +121,7 @@ static int vlclua_get_vout( lua_State *L )
     if( p_input )
     {
         vout_thread_t *p_vout = input_GetVout( p_input );
-        vlc_object_release( p_input );
+        input_Release(p_input);
         if(p_vout)
         {
             vlclua_push_vlc_object(L, VLC_OBJECT(p_vout),
diff --git a/modules/lua/libs/osd.c b/modules/lua/libs/osd.c
index 72a26fd6e3..3757431638 100644
--- a/modules/lua/libs/osd.c
+++ b/modules/lua/libs/osd.c
@@ -79,7 +79,7 @@ static int vlclua_osd_icon( lua_State *L )
             vout_OSDIcon( p_vout, i_chan, i_icon );
             vlc_object_release( p_vout );
         }
-        vlc_object_release( p_input );
+        input_Release(p_input);
     }
     return 0;
 }
@@ -127,7 +127,7 @@ static int vlclua_osd_message( lua_State *L )
                           duration, psz_message );
             vlc_object_release( p_vout );
         }
-        vlc_object_release( p_input );
+        input_Release(p_input);
     }
     return 0;
 }
@@ -170,7 +170,7 @@ static int vlclua_osd_slider( lua_State *L )
             vout_OSDSlider( p_vout, i_chan, i_position, i_type );
             vlc_object_release( p_vout );
         }
-        vlc_object_release( p_input );
+        input_Release(p_input);
     }
     return 0;
 }
@@ -182,15 +182,14 @@ static int vlclua_spu_channel_register( lua_State *L )
         return luaL_error( L, "Unable to find input." );
 
     vout_thread_t *p_vout = input_GetVout( p_input );
+    input_Release(p_input);
     if( !p_vout )
     {
-        vlc_object_release( p_input );
         return luaL_error( L, "Unable to find vout." );
     }
 
     int i_chan = vout_RegisterSubpictureChannel( p_vout );
     vlc_object_release( p_vout );
-    vlc_object_release( p_input );
     lua_pushinteger( L, i_chan );
     return 1;
 }
@@ -202,15 +201,14 @@ static int vlclua_spu_channel_clear( lua_State *L )
     if( !p_input )
         return luaL_error( L, "Unable to find input." );
     vout_thread_t *p_vout = input_GetVout( p_input );
+    input_Release(p_input);
     if( !p_vout )
     {
-        vlc_object_release( p_input );
         return luaL_error( L, "Unable to find vout." );
     }
 
     vout_FlushSubpictureChannel( p_vout, i_chan );
     vlc_object_release( p_vout );
-    vlc_object_release( p_input );
     return 0;
 }
 
diff --git a/modules/lua/libs/video.c b/modules/lua/libs/video.c
index e3d29cbd20..110f56a68f 100644
--- a/modules/lua/libs/video.c
+++ b/modules/lua/libs/video.c
@@ -50,16 +50,15 @@ static int vlclua_fullscreen( lua_State *L )
     if( !p_input ) return vlclua_error( L );
 
     p_vout = input_GetVout( p_input );
+    input_Release(p_input);
     if( !p_vout )
     {
-        vlc_object_release( p_input );
         return vlclua_error( L );
     }
 
     i_ret = vlclua_var_toggle_or_set( L, p_vout, "fullscreen" );
 
     vlc_object_release( p_vout );
-    vlc_object_release( p_input );
     return i_ret;
 }
 
diff --git a/modules/misc/audioscrobbler.c b/modules/misc/audioscrobbler.c
index 1f6bb91b48..10b9b094d2 100644
--- a/modules/misc/audioscrobbler.c
+++ b/modules/misc/audioscrobbler.c
@@ -351,7 +351,7 @@ static int ItemChange(vlc_object_t *p_this, const char *psz_var,
     if (p_sys->p_input != NULL)
     {
         var_DelCallback(p_sys->p_input, "intf-event", PlayingChange, p_intf);
-        vlc_object_release(p_sys->p_input);
+        input_Release(p_sys->p_input);
         p_sys->p_input = NULL;
     }
 
@@ -372,7 +372,7 @@ static int ItemChange(vlc_object_t *p_this, const char *psz_var,
     time(&p_sys->p_current_song.date);        /* to be sent to last.fm */
     p_sys->p_current_song.i_start = vlc_tick_now();    /* only used locally */
 
-    p_sys->p_input = vlc_object_hold(p_input);
+    p_sys->p_input = input_Hold(p_input);
     var_AddCallback(p_input, "intf-event", PlayingChange, p_intf);
 
     if (input_item_IsPreparsed(p_item))
@@ -428,7 +428,7 @@ static void Close(vlc_object_t *p_this)
     if (p_sys->p_input != NULL)
     {
         var_DelCallback(p_sys->p_input, "intf-event", PlayingChange, p_intf);
-        vlc_object_release(p_sys->p_input);
+        input_Release(p_sys->p_input);
     }
 
     int i;
diff --git a/src/playlist_legacy/engine.c b/src/playlist_legacy/engine.c
index 59a6611a11..cac6c16a98 100644
--- a/src/playlist_legacy/engine.c
+++ b/src/playlist_legacy/engine.c
@@ -353,7 +353,7 @@ input_thread_t *playlist_CurrentInputLocked( playlist_t *p_playlist )
 
     input_thread_t *p_input = pl_priv(p_playlist)->p_input;
     if( p_input != NULL )
-        vlc_object_hold( p_input );
+        input_Hold( p_input );
     return p_input;
 }
 



More information about the vlc-commits mailing list