[vlc-devel] [PATCH 4/4] libvlc: keep the crop geometry string in the libvlc_media_player_t

Steve Lhomme robux4 at ycbcr.xyz
Mon Jun 3 16:02:07 CEST 2019


It will be free'd with the media_player
---
 include/vlc/libvlc_media_player.h | 2 +-
 lib/media_player.c                | 3 +++
 lib/media_player_internal.h       | 1 +
 lib/video.c                       | 6 ++++--
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 5b6e14ea38..fd5d264fba 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -1656,7 +1656,7 @@ void libvlc_chapter_descriptions_release( libvlc_chapter_description_t **p_chapt
  * \param p_mi the media player
  * \return the crop filter geometry or NULL if unset
  */
-LIBVLC_API char *libvlc_video_get_crop_geometry( libvlc_media_player_t *p_mi );
+LIBVLC_API const char *libvlc_video_get_crop_geometry( libvlc_media_player_t *p_mi );
 
 /**
  * Set new crop filter geometry.
diff --git a/lib/media_player.c b/lib/media_player.c
index fd085c3793..51192d7671 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -695,6 +695,7 @@ libvlc_media_player_new( libvlc_instance_t *instance )
     }
 
     mp->p_md = NULL;
+    mp->psz_crop_geometry = NULL;
     mp->p_libvlc_instance = instance;
     /* use a reentrant lock to allow calling libvlc functions from callbacks */
     mp->player = vlc_player_New(VLC_OBJECT(mp), VLC_PLAYER_LOCK_REENTRANT,
@@ -796,6 +797,8 @@ static void libvlc_media_player_destroy( libvlc_media_player_t *p_mi )
     libvlc_event_manager_destroy(&p_mi->event_manager);
     libvlc_media_release( p_mi->p_md );
 
+    free( p_mi->psz_crop_geometry );
+
     vlc_http_cookie_jar_t *cookies = var_GetAddress( p_mi, "http-cookies" );
     if ( cookies )
     {
diff --git a/lib/media_player_internal.h b/lib/media_player_internal.h
index c2d5348e22..96fa6d7fd7 100644
--- a/lib/media_player_internal.h
+++ b/lib/media_player_internal.h
@@ -49,6 +49,7 @@ struct libvlc_media_player_t
     struct libvlc_instance_t * p_libvlc_instance; /* Parent instance */
     libvlc_media_t * p_md; /* current media descriptor */
     libvlc_event_manager_t event_manager;
+    char *psz_crop_geometry;
 };
 
 libvlc_track_description_t * libvlc_get_track_description(
diff --git a/lib/video.c b/lib/video.c
index ae774f51f6..711c4a23f1 100644
--- a/lib/video.c
+++ b/lib/video.c
@@ -376,9 +376,11 @@ int libvlc_video_set_spu_delay( libvlc_media_player_t *p_mi,
     return 0;
 }
 
-char *libvlc_video_get_crop_geometry (libvlc_media_player_t *p_mi)
+const char *libvlc_video_get_crop_geometry (libvlc_media_player_t *p_mi)
 {
-    return var_GetNonEmptyString (p_mi, "crop");
+    free( p_mi->psz_crop_geometry );
+    p_mi->psz_crop_geometry = var_GetNonEmptyString (p_mi, "crop");
+    return p_mi->psz_crop_geometry;
 }
 
 void libvlc_video_set_crop_geometry( libvlc_media_player_t *p_mi,
-- 
2.17.1



More information about the vlc-devel mailing list