[vlc-commits] [Git][videolan/vlc][master] 17 commits: lib/media: remove some deprecated functions
Rémi Denis-Courmont (@Courmisch)
gitlab at videolan.org
Fri Jun 17 15:57:22 UTC 2022
Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC
Commits:
a6d45a47 by Rémi Denis-Courmont at 2022-06-17T15:31:35+00:00
lib/media: remove some deprecated functions
- - - - -
65a7d782 by Rémi Denis-Courmont at 2022-06-17T15:31:35+00:00
lib/media: remove constant parameter
- - - - -
c887a007 by Rémi Denis-Courmont at 2022-06-17T15:31:35+00:00
lib/media: remove never waited on condition
- - - - -
804c8405 by Rémi Denis-Courmont at 2022-06-17T15:31:35+00:00
lib/media: inline media_parse()
- - - - -
12e01a2d by Rémi Denis-Courmont at 2022-06-17T15:31:35+00:00
lib/media: pass explicit instance for parsing
- - - - -
13c9e59e by Rémi Denis-Courmont at 2022-06-17T15:31:35+00:00
lib/media: rename libvlc_media_parse_with_options()
The prototype has changed anyhow, and the variants without options no
longer exist.
- - - - -
f2032724 by Rémi Denis-Courmont at 2022-06-17T15:31:35+00:00
lib/media: remove gratuitous parse request cancellation
Media parsing can occur on any instance, and in all likelihood, a freed
media is not being parsed by any instance.
Note: to cancel parsing, libvlc_media_parse_stop() can be used.
- - - - -
d6d17eab by Rémi Denis-Courmont at 2022-06-17T15:31:35+00:00
lib/media: remove deprecated libvlc_media_is_parsed()
- - - - -
730279b8 by Rémi Denis-Courmont at 2022-06-17T15:31:35+00:00
lib/media: remove write-only is_parsed
- - - - -
7dd8a753 by Rémi Denis-Courmont at 2022-06-17T15:31:35+00:00
lib/media: remove (last) deprecated functions
This remove the old API for preparsed tracks.
- - - - -
d902907a by Rémi Denis-Courmont at 2022-06-17T15:31:35+00:00
lib/media_track: privatise one function
- - - - -
6e786053 by Rémi Denis-Courmont at 2022-06-17T15:31:35+00:00
lib/media: deindent
No functional changes.
- - - - -
e7b9687f by Rémi Denis-Courmont at 2022-06-17T15:31:35+00:00
lib/media: name the initial parse status
No functional change.
- - - - -
e5736594 by Rémi Denis-Courmont at 2022-06-17T15:31:35+00:00
lib/media: distinguish pending and initial parse status
Note that this shifts all the values by one, but binary compatibility is
already broken anyway.
- - - - -
15009fbb by Rémi Denis-Courmont at 2022-06-17T15:31:35+00:00
lib/media: remove has_asked_parse
This can now be determined unambiguously from the parsed status.
- - - - -
02fe78a4 by Rémi Denis-Courmont at 2022-06-17T15:31:35+00:00
lib/media: make parsed status atomic
- - - - -
699fb535 by Rémi Denis-Courmont at 2022-06-17T15:31:35+00:00
lib/media: remove the parsed lock
- - - - -
12 changed files:
- include/vlc/deprecated.h
- include/vlc/libvlc_events.h
- include/vlc/libvlc_media.h
- include/vlc/libvlc_media_player.h
- lib/libvlc.sym
- lib/media.c
- lib/media_internal.h
- lib/media_track.c
- test/libvlc/media.c
- test/libvlc/media_utils.h
- test/libvlc/meta.c
- test/libvlc/slaves.c
Changes:
=====================================
include/vlc/deprecated.h
=====================================
@@ -28,101 +28,6 @@
extern "C" {
# endif
-/**
- * \ingroup libvlc_media
- * @{
- */
-
-/**
- * Parse a media.
- *
- * This fetches (local) art, meta data and tracks information.
- * The method is synchronous.
- *
- * \deprecated This function could block indefinitely.
- * Use libvlc_media_parse_with_options() instead
- *
- * \see libvlc_media_parse_with_options
- * \see libvlc_media_get_meta
- *
- * \param p_md media descriptor object
- */
-LIBVLC_DEPRECATED LIBVLC_API void
-libvlc_media_parse( libvlc_media_t *p_md );
-
-/**
- * Parse a media.
- *
- * This fetches (local) art, meta data and tracks information.
- * The method is the asynchronous of libvlc_media_parse().
- *
- * To track when this is over you can listen to libvlc_MediaParsedChanged
- * event. However if the media was already parsed you will not receive this
- * event.
- *
- * \deprecated You can't be sure to receive the libvlc_MediaParsedChanged
- * event (you can wait indefinitely for this event).
- * Use libvlc_media_parse_with_options() instead
- *
- * \see libvlc_media_parse
- * \see libvlc_MediaParsedChanged
- * \see libvlc_media_get_meta
- *
- * \param p_md media descriptor object
- */
-LIBVLC_DEPRECATED LIBVLC_API void
-libvlc_media_parse_async( libvlc_media_t *p_md );
-
-/**
- * Return true is the media descriptor object is parsed
- *
- * \deprecated This can return true in case of failure.
- * Use libvlc_media_get_parsed_status() instead
- *
- * \see libvlc_MediaParsedChanged
- *
- * \param p_md media descriptor object
- * \retval true media object has been parsed
- * \retval false otherwise
- */
-LIBVLC_DEPRECATED LIBVLC_API bool
- libvlc_media_is_parsed( libvlc_media_t *p_md );
-
-/**
- * Get media descriptor's elementary streams description
- *
- * Note, you need to call libvlc_media_parse_with_options() or play the media
- * at least once before calling this function.
- * Not doing this will result in an empty array.
- *
- * \version LibVLC 2.1.0 and later.
- * \see libvlc_media_parse_with_options
- *
- * \param p_md media descriptor object
- * \param tracks address to store an allocated array of Elementary Streams
- * descriptions (must be freed with libvlc_media_tracks_release
- by the caller) [OUT]
- *
- * \return the number of Elementary Streams (zero on error)
- */
-LIBVLC_DEPRECATED LIBVLC_API
-unsigned libvlc_media_tracks_get( libvlc_media_t *p_md,
- libvlc_media_track_t ***tracks );
-
-/**
- * Release media descriptor's elementary streams description array
- *
- * \version LibVLC 2.1.0 and later.
- *
- * \param p_tracks tracks info array to release
- * \param i_count number of elements in the array
- */
-LIBVLC_DEPRECATED LIBVLC_API
-void libvlc_media_tracks_release( libvlc_media_track_t **p_tracks,
- unsigned i_count );
-
-/** @}*/
-
/**
* \ingroup libvlc_media_player
* @{
=====================================
include/vlc/libvlc_events.h
=====================================
@@ -65,7 +65,7 @@ enum libvlc_event_e {
libvlc_MediaDurationChanged,
/**
* Parsing state of a \link #libvlc_media_t media item\endlink changed
- * \see libvlc_media_parse_with_options(),
+ * \see libvlc_media_parse_request(),
* libvlc_media_get_parsed_status(),
* libvlc_media_parse_stop()
*/
=====================================
include/vlc/libvlc_media.h
=====================================
@@ -140,9 +140,7 @@ typedef enum libvlc_media_type_t {
} libvlc_media_type_t;
/**
- * Parse flags used by libvlc_media_parse_with_options()
- *
- * \see libvlc_media_parse_with_options
+ * Parse flags used by libvlc_media_parse_request()
*/
typedef enum libvlc_media_parse_flag_t
{
@@ -171,15 +169,14 @@ typedef enum libvlc_media_parse_flag_t
} libvlc_media_parse_flag_t;
/**
- * Parse status used sent by libvlc_media_parse_with_options() or returned by
+ * Parse status used sent by libvlc_media_parse_request() or returned by
* libvlc_media_get_parsed_status()
- *
- * \see libvlc_media_parse_with_options
- * \see libvlc_media_get_parsed_status
*/
typedef enum libvlc_media_parsed_status_t
{
- libvlc_media_parsed_status_skipped = 1,
+ libvlc_media_parsed_status_none,
+ libvlc_media_parsed_status_pending,
+ libvlc_media_parsed_status_skipped,
libvlc_media_parsed_status_failed,
libvlc_media_parsed_status_timeout,
libvlc_media_parsed_status_done,
@@ -461,11 +458,10 @@ LIBVLC_API libvlc_media_t *libvlc_media_duplicate( libvlc_media_t *p_md );
/**
* Read the meta of the media.
*
- * Note, you need to call libvlc_media_parse_with_options() or play the media
+ * Note, you need to call libvlc_media_parse_request() or play the media
* at least once before calling this function.
* If the media has not yet been parsed this will return NULL.
*
- * \see libvlc_media_parse_with_options
* \see libvlc_MediaMetaChanged
*
* \param p_md the media descriptor
@@ -535,12 +531,10 @@ LIBVLC_API libvlc_event_manager_t *
/**
* Get duration (in ms) of media descriptor object item.
*
- * Note, you need to call libvlc_media_parse_with_options() or play the media
+ * Note, you need to call libvlc_media_parse_request() or play the media
* at least once before calling this function.
* Not doing this will result in an undefined result.
*
- * \see libvlc_media_parse_with_options
- *
* \param p_md media descriptor object
* \return duration of media item or -1 on error
*/
@@ -552,7 +546,7 @@ LIBVLC_API libvlc_time_t
*
* \note 'stat' values are currently only parsed by directory accesses. This
* mean that only sub medias of a directory media, parsed with
- * libvlc_media_parse_with_options() can have valid 'stat' properties.
+ * libvlc_media_parse_request() can have valid 'stat' properties.
* \version LibVLC 4.0.0 and later.
*
* \param p_md media descriptor object
@@ -584,18 +578,19 @@ LIBVLC_API int
* \see libvlc_media_get_parsed_status
* \see libvlc_media_parse_flag_t
*
+ * \param inst LibVLC instance that is to parse the media
* \param p_md media descriptor object
* \param parse_flag parse options:
* \param timeout maximum time allowed to preparse the media. If -1, the
* default "preparse-timeout" option will be used as a timeout. If 0, it will
* wait indefinitely. If > 0, the timeout will be used (in milliseconds)..
* \return -1 in case of error, 0 otherwise
- * \version LibVLC 3.0.0 or later
+ * \version LibVLC 4.0.0 or later
*/
LIBVLC_API int
-libvlc_media_parse_with_options( libvlc_media_t *p_md,
- libvlc_media_parse_flag_t parse_flag,
- int timeout );
+libvlc_media_parse_request( libvlc_instance_t *inst, libvlc_media_t *p_md,
+ libvlc_media_parse_flag_t parse_flag,
+ int timeout );
/**
* Stop the parsing of the media
@@ -603,20 +598,21 @@ libvlc_media_parse_with_options( libvlc_media_t *p_md,
* When the media parsing is stopped, the libvlc_MediaParsedChanged event will
* be sent with the libvlc_media_parsed_status_timeout status.
*
- * \see libvlc_media_parse_with_options
+ * \see libvlc_media_parse_request()
*
+ * \param inst LibVLC instance that is to cease or give up parsing the media
* \param p_md media descriptor object
* \version LibVLC 3.0.0 or later
*/
LIBVLC_API void
-libvlc_media_parse_stop( libvlc_media_t *p_md );
+libvlc_media_parse_stop( libvlc_instance_t *inst, libvlc_media_t *p_md );
/**
* Get Parsed status for media descriptor object.
*
* \see libvlc_MediaParsedChanged
* \see libvlc_media_parsed_status_t
- * \see libvlc_media_parse_with_options
+ * \see libvlc_media_parse_request()
*
* \param p_md media descriptor object
* \return a value of the libvlc_media_parsed_status_t enum
@@ -652,11 +648,10 @@ LIBVLC_API void *libvlc_media_get_user_data( libvlc_media_t *p_md );
*
* \version LibVLC 4.0.0 and later.
*
- * \note You need to call libvlc_media_parse_with_options() or play the media
+ * \note You need to call libvlc_media_parse_request() or play the media
* at least once before calling this function. Not doing this will result in
* an empty list.
*
- * \see libvlc_media_parse_with_options
* \see libvlc_media_tracklist_count
* \see libvlc_media_tracklist_at
*
@@ -673,13 +668,12 @@ libvlc_media_get_tracklist( libvlc_media_t *p_md, libvlc_track_type_t type );
/**
* Get codec description from media elementary stream
*
- * Note, you need to call libvlc_media_parse_with_options() or play the media
+ * Note, you need to call libvlc_media_parse_request() or play the media
* at least once before calling this function.
*
* \version LibVLC 3.0.0 and later.
*
* \see libvlc_media_track_t
- * \see libvlc_media_parse_with_options
*
* \param i_type i_type from libvlc_media_track_t
* \param i_codec i_codec or i_original_fourcc from libvlc_media_track_t
@@ -819,7 +813,7 @@ libvlc_media_thumbnail_request_destroy( libvlc_media_thumbnail_request_t *p_req
* track (like a .srt) or an additional audio track (like a .ac3).
*
* \note This function must be called before the media is parsed (via
- * libvlc_media_parse_with_options()) or before the media is played (via
+ * libvlc_media_parse_request()) or before the media is played (via
* libvlc_media_player_play())
*
* \version LibVLC 3.0.0 and later.
=====================================
include/vlc/libvlc_media_player.h
=====================================
@@ -1341,7 +1341,7 @@ LIBVLC_API void libvlc_media_player_set_video_title_display( libvlc_media_player
*
* \version LibVLC 4.0.0 and later.
*
- * \note You need to call libvlc_media_parse_with_options() or play the media
+ * \note You need to call libvlc_media_parse_request() or play the media
* at least once before calling this function. Not doing this will result in
* an empty list.
*
=====================================
lib/libvlc.sym
=====================================
@@ -78,7 +78,6 @@ libvlc_media_get_stats
libvlc_media_get_tracklist
libvlc_media_get_type
libvlc_media_get_user_data
-libvlc_media_is_parsed
libvlc_media_get_parsed_status
libvlc_media_thumbnail_request_by_time
libvlc_media_thumbnail_request_by_pos
@@ -127,9 +126,7 @@ libvlc_media_new_fd
libvlc_media_new_location
libvlc_media_new_path
libvlc_media_new_as_node
-libvlc_media_parse
-libvlc_media_parse_async
-libvlc_media_parse_with_options
+libvlc_media_parse_request
libvlc_media_parse_stop
libvlc_media_player_add_slave
libvlc_media_player_can_pause
@@ -206,8 +203,6 @@ libvlc_media_slaves_release
libvlc_media_set_meta
libvlc_media_set_user_data
libvlc_media_subitems
-libvlc_media_tracks_get
-libvlc_media_tracks_release
libvlc_new
libvlc_playlist_play
libvlc_release
=====================================
lib/media.c
=====================================
@@ -366,25 +366,8 @@ static void send_parsed_changed( libvlc_media_t *p_md,
{
libvlc_event_t event;
- vlc_mutex_lock( &p_md->parsed_lock );
- if( p_md->parsed_status == new_status )
- {
- vlc_mutex_unlock( &p_md->parsed_lock );
+ if (atomic_exchange(&p_md->parsed_status, new_status) == new_status)
return;
- }
-
- /* Legacy: notify libvlc_media_parse */
- if( !p_md->is_parsed )
- {
- p_md->is_parsed = true;
- vlc_cond_broadcast( &p_md->parsed_cond );
- }
-
- p_md->parsed_status = new_status;
- if( p_md->parsed_status != libvlc_media_parsed_status_done )
- p_md->has_asked_preparse = false;
-
- vlc_mutex_unlock( &p_md->parsed_lock );
/* Construct the event */
event.type = libvlc_MediaParsedChanged;
@@ -508,8 +491,6 @@ libvlc_media_t * libvlc_media_new_from_input_item(
p_md->p_input_item = p_input_item;
vlc_atomic_rc_init(&p_md->rc);
- vlc_cond_init(&p_md->parsed_cond);
- vlc_mutex_init(&p_md->parsed_lock);
vlc_mutex_init(&p_md->subitems_lock);
atomic_init(&p_md->worker_count, 0);
@@ -517,6 +498,7 @@ libvlc_media_t * libvlc_media_new_from_input_item(
* It can give a bunch of item to read. */
p_md->p_subitems = NULL;
p_md->p_input_item->libvlc_owner = p_md;
+ atomic_init(&p_md->parsed_status, libvlc_media_parsed_status_none);
libvlc_event_manager_init( &p_md->event_manager, p_md );
@@ -654,9 +636,6 @@ void libvlc_media_release( libvlc_media_t *p_md )
uninstall_input_item_observer( p_md );
- /* Cancel asynchronous parsing (if any) */
- libvlc_MetadataCancel( p_md->p_libvlc_instance->p_libvlc_int, p_md );
-
/* Wait for all async tasks to stop. */
while ((ref = atomic_load_explicit(&p_md->worker_count,
memory_order_acquire)) > 0)
@@ -856,122 +835,67 @@ static const input_preparser_callbacks_t input_preparser_callbacks = {
.on_subtree_added = input_item_subtree_added,
};
-static int media_parse(libvlc_media_t *media, bool b_async,
- libvlc_media_parse_flag_t parse_flag, int timeout)
+int libvlc_media_parse_request(libvlc_instance_t *inst, libvlc_media_t *media,
+ libvlc_media_parse_flag_t parse_flag,
+ int timeout)
{
- bool needed;
+ libvlc_media_parsed_status_t expected = libvlc_media_parsed_status_none;
- vlc_mutex_lock(&media->parsed_lock);
- needed = !media->has_asked_preparse;
- media->has_asked_preparse = true;
- if (needed)
- {
- media->is_parsed = false;
- media->parsed_status = 0;
- }
- vlc_mutex_unlock(&media->parsed_lock);
+ while (!atomic_compare_exchange_weak(&media->parsed_status, &expected,
+ libvlc_media_parsed_status_pending))
+ if (expected == libvlc_media_parsed_status_pending
+ || expected == libvlc_media_parsed_status_done)
+ return -1;
- if (needed)
+ libvlc_int_t *libvlc = inst->p_libvlc_int;
+ input_item_t *item = media->p_input_item;
+ input_item_meta_request_option_t parse_scope = META_REQUEST_OPTION_SCOPE_LOCAL;
+ int ret;
+ unsigned int ref = atomic_load_explicit(&media->worker_count,
+ memory_order_relaxed);
+ do
{
- libvlc_int_t *libvlc = media->p_libvlc_instance->p_libvlc_int;
- input_item_t *item = media->p_input_item;
- input_item_meta_request_option_t parse_scope = META_REQUEST_OPTION_SCOPE_LOCAL;
- int ret;
- unsigned int ref = atomic_load_explicit(&media->worker_count,
- memory_order_relaxed);
- do
- {
- if (unlikely(ref == UINT_MAX))
- return -EOVERFLOW;
- }
- while (!atomic_compare_exchange_weak_explicit(&media->worker_count,
- &ref, ref + 1,
- memory_order_relaxed,
- memory_order_relaxed));
-
- if (parse_flag & libvlc_media_parse_network)
- parse_scope |= META_REQUEST_OPTION_SCOPE_NETWORK;
- if (parse_flag & libvlc_media_fetch_local)
- parse_scope |= META_REQUEST_OPTION_FETCH_LOCAL;
- if (parse_flag & libvlc_media_fetch_network)
- parse_scope |= META_REQUEST_OPTION_FETCH_NETWORK;
- if (parse_flag & libvlc_media_do_interact)
- parse_scope |= META_REQUEST_OPTION_DO_INTERACT;
-
- ret = libvlc_MetadataRequest(libvlc, item, parse_scope,
- &input_preparser_callbacks, media,
- timeout, media);
- if (ret != VLC_SUCCESS)
- {
- atomic_fetch_sub_explicit(&media->worker_count, 1,
- memory_order_relaxed);
- return ret;
- }
+ if (unlikely(ref == UINT_MAX))
+ return -1;
}
- else
- return VLC_EGENERIC;
-
- if (!b_async)
+ while (!atomic_compare_exchange_weak_explicit(&media->worker_count,
+ &ref, ref + 1,
+ memory_order_relaxed,
+ memory_order_relaxed));
+
+ if (parse_flag & libvlc_media_parse_network)
+ parse_scope |= META_REQUEST_OPTION_SCOPE_NETWORK;
+ if (parse_flag & libvlc_media_fetch_local)
+ parse_scope |= META_REQUEST_OPTION_FETCH_LOCAL;
+ if (parse_flag & libvlc_media_fetch_network)
+ parse_scope |= META_REQUEST_OPTION_FETCH_NETWORK;
+ if (parse_flag & libvlc_media_do_interact)
+ parse_scope |= META_REQUEST_OPTION_DO_INTERACT;
+
+ ret = libvlc_MetadataRequest(libvlc, item, parse_scope,
+ &input_preparser_callbacks, media,
+ timeout, media);
+ if (ret != VLC_SUCCESS)
{
- vlc_mutex_lock(&media->parsed_lock);
- while (!media->is_parsed)
- vlc_cond_wait(&media->parsed_cond, &media->parsed_lock);
- vlc_mutex_unlock(&media->parsed_lock);
+ atomic_fetch_sub_explicit(&media->worker_count, 1,
+ memory_order_relaxed);
+ return -1;
}
- return VLC_SUCCESS;
-}
-
-// Parse the media and wait
-void
-libvlc_media_parse(libvlc_media_t *media)
-{
- media_parse( media, false, libvlc_media_fetch_local, -1 );
-}
-
-// Parse the media but do not wait
-void
-libvlc_media_parse_async(libvlc_media_t *media)
-{
- media_parse( media, true, libvlc_media_fetch_local, -1 );
-}
-
-// Parse the media asynchronously with options
-int
-libvlc_media_parse_with_options( libvlc_media_t *media,
- libvlc_media_parse_flag_t parse_flag,
- int timeout )
-{
- return media_parse( media, true, parse_flag, timeout ) == VLC_SUCCESS ? 0 : -1;
+ return 0;
}
// Stop parsing of the media
void
-libvlc_media_parse_stop( libvlc_media_t *media )
+libvlc_media_parse_stop(libvlc_instance_t *inst, libvlc_media_t *media)
{
- libvlc_MetadataCancel( media->p_libvlc_instance->p_libvlc_int, media );
-}
-
-// Get parsed status for media object (deprecated)
-bool libvlc_media_is_parsed(libvlc_media_t *media)
-{
- bool parsed;
-
- vlc_mutex_lock(&media->parsed_lock);
- parsed = media->is_parsed;
- vlc_mutex_unlock(&media->parsed_lock);
- return parsed;
+ libvlc_MetadataCancel(inst->p_libvlc_int, media);
}
// Get Parsed status for media descriptor object
libvlc_media_parsed_status_t
libvlc_media_get_parsed_status(libvlc_media_t *media)
{
- libvlc_media_parsed_status_t status;
-
- vlc_mutex_lock(&media->parsed_lock);
- status = media->parsed_status;
- vlc_mutex_unlock(&media->parsed_lock);
- return status;
+ return atomic_load(&media->parsed_status);
}
// Sets media descriptor's user_data
@@ -990,47 +914,6 @@ libvlc_media_get_user_data( libvlc_media_t * p_md )
return p_md->p_user_data;
}
-// Get media descriptor's elementary streams description
-unsigned
-libvlc_media_tracks_get( libvlc_media_t *p_md, libvlc_media_track_t *** pp_es )
-{
- assert( p_md );
-
- input_item_t *p_input_item = p_md->p_input_item;
- vlc_mutex_lock( &p_input_item->lock );
-
- const int i_es = p_input_item->i_es;
- *pp_es = (i_es > 0) ? calloc( i_es, sizeof(**pp_es) ) : NULL;
-
- if( !*pp_es ) /* no ES, or OOM */
- {
- vlc_mutex_unlock( &p_input_item->lock );
- return 0;
- }
-
- /* Fill array */
- for( int i = 0; i < i_es; i++ )
- {
- libvlc_media_trackpriv_t *p_trackpriv = calloc( 1, sizeof(*p_trackpriv) );
- if ( !p_trackpriv )
- {
- libvlc_media_tracks_release( *pp_es, i_es );
- *pp_es = NULL;
- vlc_mutex_unlock( &p_input_item->lock );
- return 0;
- }
- libvlc_media_track_t *p_mes = &p_trackpriv->t;
- (*pp_es)[i] = p_mes;
-
- const es_format_t *p_es = p_input_item->es[i];
-
- libvlc_media_trackpriv_from_es( p_trackpriv, p_es );
- }
-
- vlc_mutex_unlock( &p_input_item->lock );
- return i_es;
-}
-
libvlc_media_tracklist_t *
libvlc_media_get_tracklist( libvlc_media_t *p_md, libvlc_track_type_t type )
{
@@ -1056,19 +939,6 @@ libvlc_media_get_codec_description( libvlc_track_type_t i_type,
i_codec );
}
-// Release media descriptor's elementary streams description array
-void libvlc_media_tracks_release( libvlc_media_track_t **p_tracks, unsigned i_count )
-{
- for( unsigned i = 0; i < i_count; ++i )
- {
- if ( !p_tracks[i] )
- continue;
- libvlc_media_track_clean( p_tracks[i] );
- free( p_tracks[i] );
- }
- free( p_tracks );
-}
-
// Get the media type of the media descriptor object
libvlc_media_type_t libvlc_media_get_type( libvlc_media_t *p_md )
{
=====================================
lib/media_internal.h
=====================================
@@ -43,8 +43,6 @@ struct libvlc_media_t
VLC_FORWARD_DECLARE_OBJECT(libvlc_media_list_t*) p_subitems; /* A media descriptor can have Sub items. This is the only dependency we really have on media_list */
void *p_user_data;
- vlc_cond_t parsed_cond;
- vlc_mutex_t parsed_lock;
vlc_mutex_t subitems_lock;
/* Idle protection to prevent the media from being released during
@@ -52,9 +50,7 @@ struct libvlc_media_t
* be blocking until no async code is using the media anymore. */
atomic_uint worker_count;
- libvlc_media_parsed_status_t parsed_status;
- bool is_parsed;
- bool has_asked_preparse;
+ _Atomic libvlc_media_parsed_status_t parsed_status;
};
/* Media Descriptor */
@@ -114,7 +110,4 @@ libvlc_media_tracklist_t *
libvlc_media_tracklist_from_player( vlc_player_t *player,
libvlc_track_type_t type );
-void
-libvlc_media_track_clean( libvlc_media_track_t *track );
-
#endif
=====================================
lib/media_track.c
=====================================
@@ -123,8 +123,7 @@ libvlc_media_trackpriv_new( void )
return trackpriv;
}
-void
-libvlc_media_track_clean( libvlc_media_track_t *track )
+static void libvlc_media_track_clean( libvlc_media_track_t *track )
{
free( track->psz_language );
free( track->psz_description );
=====================================
test/libvlc/media.c
=====================================
@@ -126,7 +126,7 @@ static void test_media_preparsed(libvlc_instance_t *vlc, const char *path,
libvlc_event_attach (em, libvlc_MediaParsedChanged, media_parse_ended, &sem);
// Parse the media. This is synchronous.
- int i_ret = libvlc_media_parse_with_options(media, parse_flags, -1);
+ int i_ret = libvlc_media_parse_request(vlc, media, parse_flags, -1);
assert(i_ret == 0);
// Wait for preparsed event
@@ -257,7 +257,8 @@ static void subitem_added(const libvlc_event_t *event, void *user_data)
#undef FILE_SEPARATOR
}
-static void test_media_subitems_media(libvlc_media_t *media, bool play,
+static void test_media_subitems_media(libvlc_instance_t *vlc,
+ libvlc_media_t *media, bool play,
bool b_items_expected)
{
libvlc_media_add_option(media, ":ignore-filetypes= ");
@@ -272,7 +273,7 @@ static void test_media_subitems_media(libvlc_media_t *media, bool play,
if (play)
{
- /* XXX: libvlc_media_parse_with_options won't work with fd, since it
+ /* XXX: libvlc_media_parse won't work with fd, since it
* won't be preparsed because fd:// is an unknown type, so play the
* file to force parsing. */
libvlc_event_attach (em, libvlc_MediaSubItemTreeAdded, subitem_parse_ended, &sem);
@@ -287,7 +288,8 @@ static void test_media_subitems_media(libvlc_media_t *media, bool play,
{
libvlc_event_attach (em, libvlc_MediaParsedChanged, subitem_parse_ended, &sem);
- int i_ret = libvlc_media_parse_with_options(media, libvlc_media_parse_local, -1);
+ int i_ret = libvlc_media_parse_request(vlc, media,
+ libvlc_media_parse_local, -1);
assert(i_ret == 0);
vlc_sem_wait (&sem);
}
@@ -311,7 +313,7 @@ static void test_media_subitems(libvlc_instance_t *vlc)
test_log ("Testing media_subitems: path: '%s'\n", subitems_path);
media = libvlc_media_new_path (vlc, subitems_path);
assert (media != NULL);
- test_media_subitems_media (media, false, true);
+ test_media_subitems_media(vlc, media, false, true);
libvlc_media_release (media);
char *subitems_realpath = realpath (subitems_path, NULL);
@@ -324,7 +326,7 @@ static void test_media_subitems(libvlc_instance_t *vlc)
test_log ("Testing media_subitems: location: '%s'\n", location);
media = libvlc_media_new_location (vlc, location);
assert (media != NULL);
- test_media_subitems_media (media, false, true);
+ test_media_subitems_media(vlc, media, false, true);
free (location);
libvlc_media_release (media);
}
@@ -337,7 +339,7 @@ static void test_media_subitems(libvlc_instance_t *vlc)
assert (fd >= 0);
media = libvlc_media_new_fd (vlc, fd);
assert (media != NULL);
- test_media_subitems_media (media, true, true);
+ test_media_subitems_media(vlc, media, true, true);
libvlc_media_release (media);
vlc_close (fd);
#else
@@ -347,7 +349,7 @@ static void test_media_subitems(libvlc_instance_t *vlc)
test_log ("Testing media_subitems failure\n");
media = libvlc_media_new_location (vlc, "wrongfile://test");
assert (media != NULL);
- test_media_subitems_media (media, false, false);
+ test_media_subitems_media(vlc, media, false, false);
libvlc_media_release (media);
}
=====================================
test/libvlc/media_utils.h
=====================================
@@ -28,8 +28,8 @@ libvlc_media_parse_finished_event(const libvlc_event_t *p_ev, void *p_data)
}
static inline void
-libvlc_media_parse_sync(libvlc_media_t *p_m, libvlc_media_parse_flag_t parse_flag,
- int timeout)
+libvlc_media_parse_sync(libvlc_instance_t *vlc, libvlc_media_t *p_m,
+ libvlc_media_parse_flag_t parse_flag, int timeout)
{
vlc_sem_t sem;
vlc_sem_init(&sem, 0);
@@ -38,7 +38,7 @@ libvlc_media_parse_sync(libvlc_media_t *p_m, libvlc_media_parse_flag_t parse_fla
libvlc_event_attach(p_em, libvlc_MediaParsedChanged,
libvlc_media_parse_finished_event, &sem);
- int i_ret = libvlc_media_parse_with_options(p_m, parse_flag, timeout);
+ int i_ret = libvlc_media_parse_request(vlc, p_m, parse_flag, timeout);
assert(i_ret == 0);
vlc_sem_wait (&sem);
=====================================
test/libvlc/meta.c
=====================================
@@ -40,7 +40,7 @@ static void test_meta (const char ** argv, int argc)
media = libvlc_media_new_path (vlc, SRCDIR "/samples/meta.mp3");
assert( media );
- libvlc_media_parse_sync (media, libvlc_media_parse_local, -1);
+ libvlc_media_parse_sync(vlc, media, libvlc_media_parse_local, -1);
artist = libvlc_media_get_meta (media, libvlc_meta_Artist);
=====================================
test/libvlc/slaves.c
=====================================
@@ -84,7 +84,7 @@ test_media_has_slaves_from_parent(libvlc_instance_t *p_vlc,
assert(p_m != NULL);
printf("Parse media dir to get subitems\n");
- libvlc_media_parse_sync(p_m, libvlc_media_parse_local, -1);
+ libvlc_media_parse_sync(p_vlc, p_m, libvlc_media_parse_local, -1);
char *psz_main_media_mrl = path_to_mrl(p_vlc, psz_main_media);
assert(psz_main_media_mrl != NULL);
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/19364a7beb85e124eba4f6b9b69846bf2b129e6f...699fb5357fa2b559c5019f223c2d8b1f1d75226b
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/19364a7beb85e124eba4f6b9b69846bf2b129e6f...699fb5357fa2b559c5019f223c2d8b1f1d75226b
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list