[vlc-devel] [PATCH 08/10] libvlc: keep the marquee strings in the libvlc_media_player_t
Steve Lhomme
robux4 at ycbcr.xyz
Mon May 27 15:38:20 CEST 2019
They will be free'd with the media_player
---
include/vlc/libvlc_media_player.h | 5 +++--
lib/media_player.c | 4 ++++
lib/media_player_internal.h | 1 +
lib/video.c | 8 +++++---
4 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 4e942771a1..148ff77a65 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -1777,9 +1777,10 @@ LIBVLC_API int libvlc_video_get_marquee_int( libvlc_media_player_t *p_mi,
*
* \param p_mi libvlc media player
* \param option marq option to get
+ * \return the string corresponding to the marquee option
*/
-LIBVLC_API char *libvlc_video_get_marquee_string( libvlc_media_player_t *p_mi,
- libvlc_video_marquee_option_t option );
+LIBVLC_API const char *libvlc_video_get_marquee_string( libvlc_media_player_t *p_mi,
+ libvlc_video_marquee_option_t option );
/**
* Enable, disable or set an integer marquee option
diff --git a/lib/media_player.c b/lib/media_player.c
index bdf11d3c7e..d0984c2e11 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -698,6 +698,8 @@ libvlc_media_player_new( libvlc_instance_t *instance )
mp->psz_audio_devid = NULL;
mp->psz_crop_geometry = NULL;
mp->psz_aspect_ratio = NULL;
+ for (size_t i=0; i<ARRAY_SIZE(mp->psz_marquee); i++)
+ mp->psz_marquee[i] = 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,
@@ -799,6 +801,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 );
+ for (size_t i=0; i<ARRAY_SIZE(p_mi->psz_marquee); i++)
+ free( p_mi->psz_marquee[i] );
free( p_mi->psz_audio_devid );
free( p_mi->psz_crop_geometry );
free( p_mi->psz_aspect_ratio );
diff --git a/lib/media_player_internal.h b/lib/media_player_internal.h
index 7564f46743..91d0befa7d 100644
--- a/lib/media_player_internal.h
+++ b/lib/media_player_internal.h
@@ -54,6 +54,7 @@ struct libvlc_media_player_t
char *psz_audio_devid;
char *psz_crop_geometry;
char *psz_aspect_ratio;
+ char *psz_marquee[ libvlc_video_marquee_Last+1 ];
};
libvlc_track_description_t * libvlc_get_track_description(
diff --git a/lib/video.c b/lib/video.c
index 6c26d33bac..0ce6e837e0 100644
--- a/lib/video.c
+++ b/lib/video.c
@@ -786,10 +786,12 @@ int libvlc_video_get_marquee_int( libvlc_media_player_t *p_mi,
/*****************************************************************************
* libvlc_video_get_marquee_string : get a marq option value
*****************************************************************************/
-char * libvlc_video_get_marquee_string( libvlc_media_player_t *p_mi,
- libvlc_video_marquee_option_t option )
+const char * libvlc_video_get_marquee_string( libvlc_media_player_t *p_mi,
+ libvlc_video_marquee_option_t option )
{
- return get_string( p_mi, "marq", marq_option_bynumber(option) );
+ free( p_mi->psz_marquee[option] );
+ p_mi->psz_marquee[option] = get_string( p_mi, "marq", marq_option_bynumber(option) );
+ return p_mi->psz_marquee[option];
}
/*****************************************************************************
--
2.17.1
More information about the vlc-devel
mailing list