[vlc-commits] intf: change intf_Create argument

Thomas Guillem git at videolan.org
Fri Mar 8 09:36:21 CET 2019


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Mar  8 09:30:03 2019 +0100| [42e344eb8797ccc565d4bbb1f479932a0ecb423f] | committer: Thomas Guillem

intf: change intf_Create argument

Use a libvlc_int_t *. This will ease the playlist_t => vlc_playlist_t
transition.

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

 include/vlc_interface.h     |  2 +-
 modules/control/ntservice.c |  2 +-
 modules/control/oldrc.c     |  2 +-
 src/interface/interface.c   | 36 +++++++++++++++++++++++++-----------
 4 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/include/vlc_interface.h b/include/vlc_interface.h
index 488ad0532b..9794e5df34 100644
--- a/include/vlc_interface.h
+++ b/include/vlc_interface.h
@@ -87,7 +87,7 @@ struct intf_dialog_args_t
     struct interaction_dialog_t *p_dialog;
 };
 
-VLC_API int intf_Create( playlist_t *, const char * );
+VLC_API int intf_Create( libvlc_int_t *, const char * );
 
 VLC_API void libvlc_Quit( libvlc_int_t * );
 
diff --git a/modules/control/ntservice.c b/modules/control/ntservice.c
index 22f9fc7030..d61b73ad4f 100644
--- a/modules/control/ntservice.c
+++ b/modules/control/ntservice.c
@@ -340,7 +340,7 @@ static void WINAPI ServiceDispatch( DWORD numArgs, char **args )
         if( asprintf( &psz_temp, "%s,none", psz_module ) != -1 )
         {
             /* Try to create the interface */
-            if( intf_Create( pl_Get(p_intf), psz_temp ) )
+            if( intf_Create( vlc_object_instance(p_intf), psz_temp ) )
             {
                 msg_Err( p_intf, "interface \"%s\" initialization failed",
                          psz_temp );
diff --git a/modules/control/oldrc.c b/modules/control/oldrc.c
index 985091f130..f4ec8e37c4 100644
--- a/modules/control/oldrc.c
+++ b/modules/control/oldrc.c
@@ -1430,7 +1430,7 @@ static int Intf( vlc_object_t *p_this, char const *psz_cmd,
     intf_thread_t *intf = (intf_thread_t *)p_this;
 
     VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
-    return intf_Create(pl_Get(intf), newval.psz_string );
+    return intf_Create(vlc_object_instance(intf), newval.psz_string );
 }
 
 static int Volume( vlc_object_t *p_this, char const *psz_cmd,
diff --git a/src/interface/interface.c b/src/interface/interface.c
index e0a00e90b4..0342e7a1b5 100644
--- a/src/interface/interface.c
+++ b/src/interface/interface.c
@@ -83,15 +83,17 @@ static playlist_t *intf_GetPlaylist(libvlc_int_t *libvlc)
     return playlist;
 }
 
-/**
- * Create and start an interface.
- *
- * @param playlist playlist and parent object for the interface
- * @param chain configuration chain string
- * @return VLC_SUCCESS or an error code
- */
-int intf_Create( playlist_t *playlist, const char *chain )
+static int intf_CreateInternal( libvlc_int_t *libvlc, playlist_t *playlist,
+                                const char *chain )
 {
+    assert( !!libvlc != !!playlist );
+    if (!playlist)
+    {
+        playlist = intf_GetPlaylist(libvlc);
+        if (!playlist)
+            return VLC_EGENERIC;
+    }
+
     /* Allocate structure */
     intf_thread_t *p_intf = vlc_custom_create( playlist, sizeof( *p_intf ),
                                                "interface" );
@@ -147,6 +149,18 @@ error:
     return VLC_EGENERIC;
 }
 
+/**
+ * Create and start an interface.
+ *
+ * @param playlist playlist and parent object for the interface
+ * @param chain configuration chain string
+ * @return VLC_SUCCESS or an error code
+ */
+int intf_Create( libvlc_int_t *libvlc, const char *chain )
+{
+    return intf_CreateInternal( libvlc, NULL, chain );
+}
+
 static void
 PlaylistConfigureFromVariables(vlc_playlist_t *playlist, vlc_object_t *obj)
 {
@@ -267,7 +281,7 @@ int libvlc_InternalAddIntf(libvlc_int_t *libvlc, const char *name)
         ret = VLC_ENOMEM;
     else
     if (name != NULL)
-        ret = intf_Create(playlist, name);
+        ret = intf_CreateInternal(NULL, playlist, name);
     else
     {   /* Default interface */
         char *intf = var_InheritString(libvlc, "intf");
@@ -279,7 +293,7 @@ int libvlc_InternalAddIntf(libvlc_int_t *libvlc, const char *name)
                 msg_Info(libvlc, _("Running vlc with the default interface. "
                          "Use 'cvlc' to use vlc without interface."));
         }
-        ret = intf_Create(playlist, intf);
+        ret = intf_CreateInternal(NULL, playlist, intf);
         free(intf);
         name = "default";
     }
@@ -331,7 +345,7 @@ static int AddIntfCallback( vlc_object_t *obj, char const *var,
 {
     playlist_t *playlist = data;
 
-    int ret = intf_Create( playlist, cur.psz_string );
+    int ret = intf_CreateInternal( NULL, playlist, cur.psz_string );
     if( ret )
         msg_Err( obj, "interface \"%s\" initialization failed",
                  cur.psz_string );



More information about the vlc-commits mailing list