[vlc-devel] [PATCH 05/10] libvlc: keep the crop geometry string in the libvlc_media_player_t
Steve Lhomme
robux4 at ycbcr.xyz
Mon May 27 15:38:17 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 72cc9d1d4b..01ad1cf849 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -1662,7 +1662,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 118bc26c36..5e69f410dd 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -696,6 +696,7 @@ libvlc_media_player_new( libvlc_instance_t *instance )
mp->p_md = NULL;
mp->psz_audio_devid = 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,
@@ -798,6 +799,8 @@ static void libvlc_media_player_destroy( libvlc_media_player_t *p_mi )
libvlc_media_release( p_mi->p_md );
free( p_mi->psz_audio_devid );
+ 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 e0b2849b9a..23d838682f 100644
--- a/lib/media_player_internal.h
+++ b/lib/media_player_internal.h
@@ -52,6 +52,7 @@ struct libvlc_media_player_t
/* strings read by the host and released with the media_player */
char *psz_audio_devid;
+ char *psz_crop_geometry;
};
libvlc_track_description_t * libvlc_get_track_description(
diff --git a/lib/video.c b/lib/video.c
index 9211e65bfd..55eae0f049 100644
--- a/lib/video.c
+++ b/lib/video.c
@@ -368,9 +368,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