Skip to content

libvlc: assert and document media tracks selection API usage

Martin Finkel requested to merge mfkl/vlc:media-tracks-api-tests into master

Since the libvlc_media_tracklist_t type and data is shared between libvlc_media_player_t and libvlc_media_t, users may wrongly assume that they can use media tracks retrieved with libvlc_media_get_tracklist to feed the mediaplayer to select tracks with libvlc_media_player_select_track (while they should actually be using libvlc_media_player_get_tracklist).

This is not supported and causes a crash

>	libvlccore.dll!vlc_atomic_rc_inc(vlc_atomic_rc_t * rc) Line 53	C
 	libvlccore.dll!EsHold(es_out_id_t * es) Line 638	C
 	libvlccore.dll!vlc_es_id_Hold(vlc_es_id_t * id) Line 4506	C
 	libvlccore.dll!input_ControlPushEsHelper(input_thread_t * p_input, int i_type, vlc_es_id_t * id) Line 628	C
 	libvlccore.dll!vlc_player_SelectEsId(vlc_player_t * player, vlc_es_id_t * id, vlc_player_select_policy policy) Line 569	C
 	libvlc.dll!libvlc_media_player_select_track(libvlc_media_player_t * p_mi, const libvlc_media_track_t * track) Line 1863	C
 	[External Code]
 	libvlc.dll!libvlc_event_send(libvlc_event_manager_t * p_em, libvlc_event_t * p_event) Line 118	C
 	libvlc.dll!input_item_preparsed_changed(const vlc_event_t * p_event, void * user_data) Line 544	C
 	libvlccore.dll!vlc_event_send(vlc_event_manager_t * p_em, vlc_event_t * p_event) Line 108	C
 	libvlccore.dll!input_item_SetPreparsed(input_item_t * p_i, bool b_preparsed) Line 90	C
 	libvlccore.dll!EsOutMeta(es_out_t * p_out, const vlc_meta_t * p_meta, const vlc_meta_t * p_program_meta) Line 1935	C
 	libvlccore.dll!EsOutGlobalMeta(es_out_t * p_out, const vlc_meta_t * p_meta) Line 1944	C
 	libvlccore.dll!EsOutVaControlLocked(es_out_t * out, input_source_t * source, int i_query, char * args) Line 3503	C
 	libvlccore.dll!EsOutControl(es_out_t * out, input_source_t * source, int i_query, char * args) Line 3924	C
 	libvlccore.dll!es_out_in_vaControl(es_out_t * p_out, input_source_t * in, int i_query, char * args) Line 513	C
 	libvlccore.dll!es_out_in_Control(es_out_t * p_out, input_source_t * in, int i_query, ...) Line 523	C
 	libvlccore.dll!CmdExecuteControl(es_out_t * p_tsout, ts_cmd_control_t * p_cmd) Line 1696	C
 	libvlccore.dll!ControlLocked(es_out_t * p_out, input_source_t * in, int i_query, char * args) Line 684	C
 	libvlccore.dll!Control(es_out_t * p_tsout, input_source_t * in, int i_query, char * args) Line 772	C
 	libvlccore.dll!es_out_vaControl(es_out_t * out, int i_query, char * args) Line 166	C
 	libvlccore.dll!es_out_Control(es_out_t * out, int i_query, ...) Line 175	C
 	libvlccore.dll!es_out_ControlSetMeta(es_out_t * out, const vlc_meta_t * p_meta) Line 192	C
 	libvlccore.dll!Init(input_thread_t * p_input) Line 1391	C
 	libvlccore.dll!Preparse(void * data) Line 492	C
 	libvlccore.dll!vlc_entry(void * p) Line 354	C

We may not want to split the media tracks and/or list types into seperate media ones and mediaplayer ones, to keep the API simple and straightforward.

  • Updated the docs to warn users against this usage mfkl/vlc@5ca8230c
  • Added a NULL check which avoids the crash when the user mis-use the libvlc API in this way. mfkl/vlc@08d3450a

/cc @tguillem

Edited by Martin Finkel

Merge request reports

Loading