[vlc-devel] [PATCH 02/14] vlm: remove unnecessary vlc_object

Romain Vimont rom1v at videolabs.io
Tue Sep 15 19:37:34 CEST 2020


A vlm_media_sys_t need not be a VLC object.
---
 src/input/vlm.c          | 17 ++++++-----------
 src/input/vlm_internal.h |  3 +--
 2 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/src/input/vlm.c b/src/input/vlm.c
index bd7205a0a3..a51d8eef99 100644
--- a/src/input/vlm.c
+++ b/src/input/vlm.c
@@ -60,7 +60,7 @@ static void player_on_state_changed(vlc_player_t *player,
                                     enum vlc_player_state new_state, void *data)
 {
     vlm_media_sys_t *p_media = data;
-    vlm_t *p_vlm = libvlc_priv( vlc_object_instance(p_media) )->p_vlm;
+    vlm_t *p_vlm = p_media->vlm;
     assert( p_vlm );
     const char *psz_instance_name = NULL;
 
@@ -469,11 +469,12 @@ static int vlm_ControlMediaAdd( vlm_t *p_vlm, vlm_media_t *p_cfg, int64_t *p_id
         return VLC_EGENERIC;
     }
 
-    p_media = vlc_custom_create( VLC_OBJECT(p_vlm), sizeof( *p_media ),
-                                 "media" );
+    p_media = malloc(sizeof(*p_media));
     if( !p_media )
         return VLC_ENOMEM;
 
+    p_media->vlm = p_vlm;
+
     vlm_media_Copy( &p_media->cfg, p_cfg );
     p_media->cfg.id = p_vlm->i_id++;
     /* FIXME do we do something here if enabled is true ? */
@@ -507,7 +508,7 @@ static int vlm_ControlMediaDel( vlm_t *p_vlm, int64_t id )
     vlm_media_Clean( &p_media->cfg );
 
     TAB_REMOVE( p_vlm->i_media, p_vlm->media, p_media );
-    vlc_object_delete(p_media);
+    free(p_media);
 
     return VLC_SUCCESS;
 }
@@ -582,11 +583,8 @@ static vlm_media_instance_sys_t *vlm_MediaInstanceNew( vlm_media_sys_t *p_media,
         goto error;
 
     p_instance->i_index = 0;
-    p_instance->p_parent = vlc_object_create( p_media, sizeof (vlc_object_t) );
-    if (!p_instance->p_parent)
-        goto error;
 
-    p_instance->player = vlc_player_New(p_instance->p_parent,
+    p_instance->player = vlc_player_New(VLC_OBJECT(p_media->vlm),
                                         VLC_PLAYER_LOCK_NORMAL, NULL, NULL);
     if (!p_instance->player)
         goto error;
@@ -606,8 +604,6 @@ static vlm_media_instance_sys_t *vlm_MediaInstanceNew( vlm_media_sys_t *p_media,
 error:
     if (p_instance->player)
         vlc_player_Delete(p_instance->player);
-    if (p_instance->p_parent)
-        vlc_object_delete(p_instance->p_parent);
     if (p_instance->p_item)
         input_item_Release(p_instance->p_item);
     free(p_instance->psz_name);
@@ -627,7 +623,6 @@ static void vlm_MediaInstanceDelete( vlm_t *p_vlm, int64_t id, vlm_media_instanc
 
     if (had_media)
         vlm_SendEventMediaInstanceStopped( p_vlm, id, p_media->cfg.psz_name );
-    vlc_object_delete(p_instance->p_parent);
 
     TAB_REMOVE( p_media->i_instance, p_media->instance, p_instance );
     input_item_Release( p_instance->p_item );
diff --git a/src/input/vlm_internal.h b/src/input/vlm_internal.h
index 2a74930343..150bf4acd4 100644
--- a/src/input/vlm_internal.h
+++ b/src/input/vlm_internal.h
@@ -36,7 +36,6 @@ typedef struct
     /* "playlist" index */
     int i_index;
 
-    vlc_object_t *p_parent;
     input_item_t      *p_item;
     vlc_player_t *player;
     vlc_player_listener_id *listener;
@@ -46,7 +45,7 @@ typedef struct
 
 typedef struct
 {
-    struct vlc_object_t obj;
+    vlm_t *vlm;
     vlm_media_t cfg;
 
     /* actual input instances */
-- 
2.28.0



More information about the vlc-devel mailing list