[vlc-commits] lib: media_track: assert that tracks are deleted correctly
Thomas Guillem
git at videolan.org
Thu Jun 11 14:45:48 CEST 2020
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Jun 11 14:24:04 2020 +0200| [e597536f311e1d7cffa0103207a2e7e3e741a606] | committer: Thomas Guillem
lib: media_track: assert that tracks are deleted correctly
This debug code assert that a track should not not deleted with
libvlc_media_track_delete() when it comes from a list.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e597536f311e1d7cffa0103207a2e7e3e741a606
---
lib/media_internal.h | 3 +++
lib/media_track.c | 17 +++++++++++++++--
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/lib/media_internal.h b/lib/media_internal.h
index 8acb116e8f..9807985179 100644
--- a/lib/media_internal.h
+++ b/lib/media_internal.h
@@ -83,6 +83,9 @@ typedef struct libvlc_media_trackpriv_t
libvlc_subtitle_track_t subtitle;
};
vlc_es_id_t *es_id;
+#ifndef NDEBUG
+ bool from_list; /* true if the track is allocated from a tracklist */
+#endif
} libvlc_media_trackpriv_t;
static inline const libvlc_media_trackpriv_t *
diff --git a/lib/media_track.c b/lib/media_track.c
index b7b575698a..feca38f7ef 100644
--- a/lib/media_track.c
+++ b/lib/media_track.c
@@ -137,6 +137,7 @@ libvlc_media_track_delete( libvlc_media_track_t *track )
{
libvlc_media_trackpriv_t *trackpriv =
container_of( track, libvlc_media_trackpriv_t, t );
+ assert( !trackpriv->from_list );
libvlc_media_track_clean( track );
if( trackpriv->es_id )
vlc_es_id_Release( trackpriv->es_id );
@@ -183,8 +184,13 @@ libvlc_media_tracklist_from_es_array( es_format_t **es_array,
for( size_t i = 0; i < es_count; ++i )
{
if( es_array[i]->i_cat == cat )
- libvlc_media_trackpriv_from_es( &list->tracks[count++],
- es_array[i] );
+ {
+ libvlc_media_trackpriv_t *trackpriv = &list->tracks[count++];
+ libvlc_media_trackpriv_from_es( trackpriv, es_array[i] );
+#ifndef NDEBUG
+ trackpriv->from_list = true;
+#endif
+ }
}
return list;
@@ -211,6 +217,9 @@ libvlc_media_track_create_from_player_track( const struct vlc_player_track *trac
if( trackpriv == NULL )
return NULL;
libvlc_media_trackpriv_from_player_track( trackpriv, track );
+#ifndef NDEBUG
+ trackpriv->from_list = false;
+#endif
return &trackpriv->t;
}
@@ -231,6 +240,9 @@ libvlc_media_tracklist_from_player( vlc_player_t *player,
libvlc_media_trackpriv_t *trackpriv = &list->tracks[i];
libvlc_media_trackpriv_from_player_track( trackpriv, track );
+#ifndef NDEBUG
+ trackpriv->from_list = true;
+#endif
}
return list;
@@ -255,6 +267,7 @@ libvlc_media_tracklist_delete( libvlc_media_tracklist_t *list )
for( size_t i = 0; i < list->count; ++i )
{
libvlc_media_trackpriv_t *trackpriv = &list->tracks[i];
+ assert( trackpriv->from_list );
libvlc_media_track_clean( &trackpriv->t );
if( trackpriv->es_id != NULL )
More information about the vlc-commits
mailing list