[vlc-commits] [Git][videolan/vlc][master] 25 commits: input_item: remove vlc_InputItemInfoChanged event

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Mon Dec 25 15:36:02 UTC 2023



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
9ec7b8b0 by Thomas Guillem at 2023-12-25T13:40:11+00:00
input_item: remove vlc_InputItemInfoChanged event

Never listened. Use vlc_player_cbs.on_media_meta_changed or
vlc_metadata_cbs.on_preparse_ended to get notified when new infos are
updated.

- - - - -
075551a8 by Thomas Guillem at 2023-12-25T13:40:11+00:00
input_item: remove vlc_InputItemNameChanged event

Not even plugged.

- - - - -
2db3dfe9 by Thomas Guillem at 2023-12-25T13:40:11+00:00
input_item: remove input_item_HasErrorWhenReading

- - - - -
d4ffb251 by Thomas Guillem at 2023-12-25T13:40:11+00:00
input_item: remove vlc_InputItemErrorWhenReadingChanged event

Not used anymore.

- - - - -
b9c45d96 by Thomas Guillem at 2023-12-25T13:40:11+00:00
input_item: remove vlc_InputItemAttachmentsFound event

Never listened. Use vlc_metadata_cbs.on_attachments_added to get
notified when new infos are updated.

- - - - -
dadd462b by Thomas Guillem at 2023-12-25T13:40:11+00:00
lib: media_player: don't use item event_manager

- - - - -
042af1fa by Thomas Guillem at 2023-12-25T13:40:11+00:00
input_item: remove vlc_InputItemPreparsedChanged event

Not listened anymore. Use vlc_player_cbs.on_media_meta_changed or
vlc_metadata_cbs.on_preparse_ended to get notified when the media is
parsed.

- - - - -
8350e96d by Thomas Guillem at 2023-12-25T13:40:11+00:00
lib: media: don't specify the meta type when a meta changed

This is only possible when using the item event manager, but not
possible with the parser and player.

- - - - -
90f3be72 by Thomas Guillem at 2023-12-25T13:40:11+00:00
lib: rework how libvlc_MediaMetaChanged is sent

>From the player, listen to vlc_player_cbs.on_media_meta_changed.
>From the parser, listen to vlc_metadata_cbs.on_preparse_ended.

This event will be send only one time from the parser for all meta types.
This event can be send several time (when the demux is updating meta)
from the player, for all meta types.

- - - - -
a414c3dd by Thomas Guillem at 2023-12-25T13:40:11+00:00
input_item: remove vlc_InputItemMetaChanged event

Not listened anymore. Use vlc_player_cbs.on_media_meta_changed or
vlc_metadata_cbs.on_preparse_ended to get notified when meta changes.

- - - - -
afa83064 by Thomas Guillem at 2023-12-25T13:40:11+00:00
lib: rework how libvlc_MediaDurationChanged is sent

>From the player, listen to vlc_player_cbs.on_length_changed.
>From the parser, listen to vlc_metadata_cbs.on_preparse_ended.

This event will be send only one time from the parser.
This event can be send several time (when the demux is updating the
length) from the player.

- - - - -
a21ea840 by Thomas Guillem at 2023-12-25T13:40:11+00:00
lib: media: remove item observer

- - - - -
8040b7df by Thomas Guillem at 2023-12-25T13:40:11+00:00
lib: events: deprecate libvlc_MediaDurationChanged

- - - - -
0bb0712d by Thomas Guillem at 2023-12-25T13:40:11+00:00
input_item: remove unused vlc_event_t members

- - - - -
03aaa898 by Thomas Guillem at 2023-12-25T13:40:11+00:00
input_item: remove vlc_InputItemDurationChanged event

Not used anymore, use vlc_player_cbs.on_length_changed or
vlc_metadata_cbs.on_preparse_ended to get notified when duration
changes.

- - - - -
2484e2cb by Thomas Guillem at 2023-12-25T13:40:11+00:00
vlc_arrays: add missing include

vlc_events.h will be removed.
vlc_events.h, that is included by vlc_input_item.h, includes vlc_common.h indirectly.

- - - - -
ce34957a by Thomas Guillem at 2023-12-25T13:40:11+00:00
upnp: add (future) missing include

vlc_events.h will be removed.
vlc_events.h, that is included by vlc_input_item.h, includes vlc_arrays.h

- - - - -
6665d06c by Thomas Guillem at 2023-12-25T13:40:11+00:00
mkv: add (future) missing include

vlc_events.h will be removed.
vlc_events.h, that is included by vlc_input_item.h, includes vlc_arrays.h

- - - - -
3a68cbb3 by Thomas Guillem at 2023-12-25T13:40:11+00:00
dshow: add (future) missing include

vlc_events.h will be removed.
vlc_events.h, that is included by vlc_input_item.h, includes vlc_arrays.h

- - - - -
71f54c25 by Thomas Guillem at 2023-12-25T13:40:11+00:00
dcp: add (future) missing include

vlc_events.h will be removed.
vlc_events.h, that is included by vlc_input_item.h, includes vlc_arrays.h

- - - - -
57ae37b1 by Thomas Guillem at 2023-12-25T13:40:11+00:00
lua: remove unused vlc_events.h include

- - - - -
2e047a3d by Thomas Guillem at 2023-12-25T13:40:11+00:00
epg: remove unused vlc_events.h include

- - - - -
7e05eb82 by Thomas Guillem at 2023-12-25T13:40:11+00:00
test: media: remove unused vlc_events.h include

- - - - -
d1f766e7 by Thomas Guillem at 2023-12-25T13:40:11+00:00
input_item: remove the event manager

- - - - -
37758b8c by Thomas Guillem at 2023-12-25T13:40:11+00:00
core: remove vlc_events

It was only used by input_item.

- - - - -


22 changed files:

- include/meson.build
- include/vlc/libvlc_events.h
- include/vlc_arrays.h
- − include/vlc_events.h
- include/vlc_input_item.h
- lib/media.c
- lib/media_player.c
- modules/access/dcp/dcpparser.h
- modules/access/dshow/dshow.cpp
- modules/demux/mkv/chapter_command.hpp
- modules/lua/extension.c
- modules/services_discovery/upnp.cpp
- po/POTFILES.in
- src/Makefile.am
- src/input/input.c
- src/input/item.c
- src/input/item.h
- src/libvlccore.sym
- src/meson.build
- − src/misc/events.c
- src/video_output/video_epg.c
- test/libvlc/media.c


Changes:

=====================================
include/meson.build
=====================================
@@ -46,7 +46,6 @@ install_headers(
     'vlc_epg.h',
     'vlc_es.h',
     'vlc_es_out.h',
-    'vlc_events.h',
     'vlc_extensions.h',
     'vlc_filter.h',
     'vlc_fingerprinter.h',


=====================================
include/vlc/libvlc_events.h
=====================================
@@ -61,7 +61,7 @@ enum libvlc_event_e {
      */
 
     /**
-     * Metadata of a \link #libvlc_media_t media item\endlink changed
+     * 1 or several Metadata of a \link #libvlc_media_t media item\endlink changed
      */
     libvlc_MediaMetaChanged=0,
     /**
@@ -70,8 +70,7 @@ enum libvlc_event_e {
      */
     libvlc_MediaSubItemAdded,
     /**
-     * Duration of a \link #libvlc_media_t media item\endlink changed
-     * \see libvlc_media_get_duration()
+     * Deprecated, use libvlc_MediaParsedChanged or libvlc_MediaPlayerLengthChanged.
      */
     libvlc_MediaDurationChanged,
     /**
@@ -267,7 +266,7 @@ typedef struct libvlc_event_t
         /* media descriptor */
         struct
         {
-            libvlc_meta_t meta_type;
+            libvlc_meta_t meta_type; /**< Deprecated, any meta_type can change */
         } media_meta_changed;
         struct
         {


=====================================
include/vlc_arrays.h
=====================================
@@ -24,6 +24,8 @@
 #ifndef VLC_ARRAYS_H_
 #define VLC_ARRAYS_H_
 
+#include <vlc_common.h>
+
 /**
  * \file
  * This file defines functions, structures and macros for handling arrays in vlc


=====================================
include/vlc_events.h deleted
=====================================
@@ -1,215 +0,0 @@
-/*****************************************************************************
- * vlc_events.h: events definitions
- * Interface used to send events.
- *****************************************************************************
- * Copyright (C) 2007 VLC authors and VideoLAN
- *
- * Authors: Pierre d'Herbemont
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-#ifndef VLC_EVENTS_H
-# define VLC_EVENTS_H
-
-#include <vlc_arrays.h>
-#include <vlc_meta.h>
-#include <vlc_threads.h>
-
-/**
- * \file
- * This file is the interface definition for events
- * (implementation in src/misc/events.c)
- */
-
-/*****************************************************************************
- * Documentation
- *****************************************************************************/
-/*
- **** Background
- *
- * This implements a way to send and receive event for an object (which can be
- * a simple C struct or less).
- *
- * This is in direct concurrency with the Variable based Callback
- * (see src/misc/variables.c).
- *
- * It has the following advantages over Variable based Callback:
- * - No need to implement the whole vlc_object_t in the object,
- * thus it reduce it size. This is especially true for input_item_t which
- * doesn't have vlc_object_t. This is the first reason of existence of
- * this implementation.
- * - Libvlc can easily be based upon that.
- * - Existing event are clearly declared (in include/vlc_events.h)
- *
- *
- **** Example usage
- *
- * (vlc_cool_object_t doesn't need to have the vlc_object_t.)
- *
- * struct vlc_cool_object_t
- * {
- *        ...
- *        vlc_event_manager_t p_event_manager;
- *        ...
- * }
- *
- * vlc_my_cool_object_new()
- * {
- *        ...
- *        vlc_event_manager_init( &p_self->p_event_manager, p_self, p_a_libvlc_object );
- *        ...
- * }
- *
- * vlc_my_cool_object_release()
- * {
- *         ...
- *         vlc_event_manager_fini( &p_self->p_event_manager );
- *         ...
- * }
- *
- * vlc_my_cool_object_do_something()
- * {
- *        ...
- *        vlc_event_t event;
- *        event.type = vlc_MyCoolObjectDidSomething;
- *        event.u.my_cool_object_did_something.what_it_did = kSomething;
- *        vlc_event_send( &p_self->p_event_manager, &event );
- * }
- * */
-
-  /*****************************************************************************
- * Event Type
- *****************************************************************************/
-
-/* List of event */
-typedef enum vlc_event_type_t {
-    /* Input item events */
-    vlc_InputItemMetaChanged,
-    vlc_InputItemDurationChanged,
-    vlc_InputItemPreparsedChanged,
-    vlc_InputItemNameChanged,
-    vlc_InputItemInfoChanged,
-    vlc_InputItemErrorWhenReadingChanged,
-    vlc_InputItemAttachmentsFound,
-} vlc_event_type_t;
-
-#define VLC_EVENT_TYPE_COUNT (vlc_InputItemAttachmentsFound + 1)
-
-typedef struct vlc_event_listeners_group_t
-{
-    DECL_ARRAY(struct vlc_event_listener_t *) listeners;
-} vlc_event_listeners_group_t;
-
-/* Event manager type */
-typedef struct vlc_event_manager_t
-{
-    void * p_obj;
-    vlc_mutex_t lock;
-    vlc_event_listeners_group_t events[VLC_EVENT_TYPE_COUNT];
-} vlc_event_manager_t;
-
-/* Event definition */
-typedef struct vlc_event_t
-{
-    vlc_event_type_t type;
-    void * p_obj; /* Sender object, automatically filled by vlc_event_send() */
-    union vlc_event_type_specific
-    {
-        /* Input item events */
-        struct vlc_input_item_meta_changed
-        {
-            vlc_meta_type_t meta_type;
-        } input_item_meta_changed;
-        struct vlc_input_item_subitem_added
-        {
-            input_item_t * p_new_child;
-        } input_item_subitem_added;
-        struct vlc_input_item_subitem_tree_added
-        {
-            input_item_node_t * p_root;
-        } input_item_subitem_tree_added;
-        struct vlc_input_item_duration_changed
-        {
-            vlc_tick_t new_duration;
-        } input_item_duration_changed;
-        struct vlc_input_item_preparsed_changed
-        {
-            int new_status;
-        } input_item_preparsed_changed;
-        struct vlc_input_item_name_changed
-        {
-            const char * new_name;
-        } input_item_name_changed;
-        struct vlc_input_item_info_changed
-        {
-            void * unused;
-        } input_item_info_changed;
-        struct input_item_error_when_reading_changed
-        {
-            bool new_value;
-        } input_item_error_when_reading_changed;
-        struct input_item_preparse_ended
-        {
-            int new_status;
-        } input_item_preparse_ended;
-        struct input_item_attachments_found
-        {
-            input_attachment_t** attachments;
-            size_t count;
-        } input_item_attachments_found;
-    } u;
-} vlc_event_t;
-
-/* Event callback type */
-typedef void ( *vlc_event_callback_t )( const vlc_event_t *, void * );
-
- /*****************************************************************************
- * Event manager
- *****************************************************************************/
-
-/*
- * p_obj points to the object that owns the event manager, and from
- * which events are sent
- */
-void vlc_event_manager_init( vlc_event_manager_t * p_em, void * p_obj );
-
-/*
- * Destroy
- */
-void vlc_event_manager_fini( vlc_event_manager_t * p_em );
-
-/*
- * Send an event to the listener attached to this p_em.
- */
-void vlc_event_send( vlc_event_manager_t * p_em, vlc_event_t * );
-
-/*
- * Add a callback for an event.
- */
-VLC_API int vlc_event_attach( vlc_event_manager_t * p_event_manager,
-                              vlc_event_type_t event_type,
-                              vlc_event_callback_t pf_callback,
-                              void *p_user_data );
-
-/*
- * Remove a callback for an event.
- */
-VLC_API void vlc_event_detach( vlc_event_manager_t *p_event_manager,
-                               vlc_event_type_t event_type,
-                               vlc_event_callback_t pf_callback,
-                               void *p_user_data );
-
-#endif /* VLC_EVENTS_H */


=====================================
include/vlc_input_item.h
=====================================
@@ -31,7 +31,6 @@
 
 #include <vlc_meta.h>
 #include <vlc_epg.h>
-#include <vlc_events.h>
 #include <vlc_list.h>
 #include <vlc_vector.h>
 #include <vlc_threads.h>
@@ -125,14 +124,11 @@ struct input_item_t
     input_item_slave_t **pp_slaves;  /**< Slave entries that will be loaded by
                                           the input_thread */
 
-    vlc_event_manager_t event_manager;
-
     vlc_mutex_t lock;                 /**< Lock for the item */
 
     enum input_item_type_e i_type;   /**< Type (file, disc, ... see input_item_type_e) */
     bool        b_net;               /**< Net: always true for TYPE_STREAM, it
                                           depends for others types */
-    bool        b_error_when_reading;/**< Error When Reading */
 
     int         i_preparse_depth;    /**< How many level of sub items can be preparsed:
                                           -1: recursive, 0: none, >0: n levels */
@@ -294,7 +290,6 @@ VLC_API input_item_slave_t *input_item_slave_New(const char *, enum slave_type,
 VLC_API int input_item_AddSlave(input_item_t *, input_item_slave_t *);
 
 /* */
-VLC_API bool input_item_HasErrorWhenReading( input_item_t * );
 VLC_API void input_item_SetMeta( input_item_t *, vlc_meta_type_t meta_type, const char *psz_val );
 VLC_API bool input_item_MetaMatch( input_item_t *p_i, vlc_meta_type_t meta_type, const char *psz );
 VLC_API char * input_item_GetMeta( input_item_t *p_i, vlc_meta_type_t meta_type ) VLC_USED;


=====================================
lib/media.c
=====================================
@@ -77,37 +77,6 @@ static const vlc_meta_type_t libvlc_to_vlc_meta[] =
     [libvlc_meta_DiscTotal]    = vlc_meta_DiscTotal
 };
 
-static const libvlc_meta_t vlc_to_libvlc_meta[] =
-{
-    [vlc_meta_Title]        = libvlc_meta_Title,
-    [vlc_meta_Artist]       = libvlc_meta_Artist,
-    [vlc_meta_Genre]        = libvlc_meta_Genre,
-    [vlc_meta_Copyright]    = libvlc_meta_Copyright,
-    [vlc_meta_Album]        = libvlc_meta_Album,
-    [vlc_meta_TrackNumber]  = libvlc_meta_TrackNumber,
-    [vlc_meta_Description]  = libvlc_meta_Description,
-    [vlc_meta_Rating]       = libvlc_meta_Rating,
-    [vlc_meta_Date]         = libvlc_meta_Date,
-    [vlc_meta_Setting]      = libvlc_meta_Setting,
-    [vlc_meta_URL]          = libvlc_meta_URL,
-    [vlc_meta_Language]     = libvlc_meta_Language,
-    [vlc_meta_NowPlaying]   = libvlc_meta_NowPlaying,
-    [vlc_meta_ESNowPlaying] = libvlc_meta_NowPlaying,
-    [vlc_meta_Publisher]    = libvlc_meta_Publisher,
-    [vlc_meta_EncodedBy]    = libvlc_meta_EncodedBy,
-    [vlc_meta_ArtworkURL]   = libvlc_meta_ArtworkURL,
-    [vlc_meta_TrackID]      = libvlc_meta_TrackID,
-    [vlc_meta_TrackTotal]   = libvlc_meta_TrackTotal,
-    [vlc_meta_Director]     = libvlc_meta_Director,
-    [vlc_meta_Season]       = libvlc_meta_Season,
-    [vlc_meta_Episode]      = libvlc_meta_Episode,
-    [vlc_meta_ShowName]     = libvlc_meta_ShowName,
-    [vlc_meta_Actors]       = libvlc_meta_Actors,
-    [vlc_meta_AlbumArtist]  = libvlc_meta_AlbumArtist,
-    [vlc_meta_DiscNumber]   = libvlc_meta_DiscNumber,
-    [vlc_meta_DiscTotal]    = libvlc_meta_DiscTotal
-};
-
 static_assert(
     ORIENT_TOP_LEFT     == (int) libvlc_video_orient_top_left &&
     ORIENT_TOP_RIGHT    == (int) libvlc_video_orient_top_right &&
@@ -272,44 +241,6 @@ void libvlc_media_add_subtree(libvlc_media_t *p_md, input_item_node_t *node)
     libvlc_event_send( &p_md->event_manager, &event );
 }
 
-/**
- * \internal
- * input_item_meta_changed (Private) (vlc event Callback)
- */
-static void input_item_meta_changed( const vlc_event_t *p_event,
-                                     void * user_data )
-{
-    libvlc_media_t * p_md = user_data;
-    libvlc_event_t event;
-
-    /* Construct the event */
-    event.type = libvlc_MediaMetaChanged;
-    event.u.media_meta_changed.meta_type =
-        vlc_to_libvlc_meta[p_event->u.input_item_meta_changed.meta_type];
-
-    /* Send the event */
-    libvlc_event_send( &p_md->event_manager, &event );
-}
-
-/**
- * \internal
- * input_item_duration_changed (Private) (vlc event Callback)
- */
-static void input_item_duration_changed( const vlc_event_t *p_event,
-                                         void * user_data )
-{
-    libvlc_media_t * p_md = user_data;
-    libvlc_event_t event;
-
-    /* Construct the event */
-    event.type = libvlc_MediaDurationChanged;
-    event.u.media_duration_changed.new_duration =
-        libvlc_time_from_vlc_tick(p_event->u.input_item_duration_changed.new_duration);
-
-    /* Send the event */
-    libvlc_event_send( &p_md->event_manager, &event );
-}
-
 static void input_item_attachments_added( input_item_t *item,
                                           input_attachment_t *const *array,
                                           size_t count, void *user_data )
@@ -346,11 +277,20 @@ static void send_parsed_changed( libvlc_media_t *p_md,
     if (atomic_exchange(&p_md->parsed_status, new_status) == new_status)
         return;
 
-    /* Construct the event */
+    /* Duration event */
+    event.type = libvlc_MediaDurationChanged;
+    event.u.media_duration_changed.new_duration =
+        input_item_GetDuration( p_md->p_input_item );
+    libvlc_event_send( &p_md->event_manager, &event );
+
+    /* Meta event */
+    event.type = libvlc_MediaMetaChanged;
+    event.u.media_meta_changed.meta_type = 0;
+    libvlc_event_send( &p_md->event_manager, &event );
+
+    /* Parsed event */
     event.type = libvlc_MediaParsedChanged;
     event.u.media_parsed_changed.new_status = new_status;
-
-    /* Send the event */
     libvlc_event_send( &p_md->event_manager, &event );
 
     libvlc_media_list_t *p_subitems = p_md->p_subitems;
@@ -396,38 +336,6 @@ static void input_item_preparse_ended(input_item_t *item,
         vlc_atomic_notify_one(&p_md->worker_count);
 }
 
-/**
- * \internal
- * Install event handler (Private)
- */
-static void install_input_item_observer( libvlc_media_t *p_md )
-{
-    vlc_event_attach( &p_md->p_input_item->event_manager,
-                      vlc_InputItemMetaChanged,
-                      input_item_meta_changed,
-                      p_md );
-    vlc_event_attach( &p_md->p_input_item->event_manager,
-                      vlc_InputItemDurationChanged,
-                      input_item_duration_changed,
-                      p_md );
-}
-
-/**
- * \internal
- * Uninstall event handler (Private)
- */
-static void uninstall_input_item_observer( libvlc_media_t *p_md )
-{
-    vlc_event_detach( &p_md->p_input_item->event_manager,
-                      vlc_InputItemMetaChanged,
-                      input_item_meta_changed,
-                      p_md );
-    vlc_event_detach( &p_md->p_input_item->event_manager,
-                      vlc_InputItemDurationChanged,
-                      input_item_duration_changed,
-                      p_md );
-}
-
 /**
  * \internal
  * Create a new media descriptor object from an input_item (Private)
@@ -472,7 +380,6 @@ libvlc_media_t * libvlc_media_new_from_input_item(input_item_t *p_input_item )
 
     input_item_Hold( p_md->p_input_item );
 
-    install_input_item_observer( p_md );
     return p_md;
 }
 
@@ -589,8 +496,6 @@ void libvlc_media_release( libvlc_media_t *p_md )
     if( !vlc_atomic_rc_dec(&p_md->rc) )
         return;
 
-    uninstall_input_item_observer( p_md );
-
     /* Wait for all async tasks to stop. */
     while ((ref = atomic_load_explicit(&p_md->worker_count,
                                        memory_order_acquire)) > 0)


=====================================
lib/media_player.c
=====================================
@@ -49,9 +49,6 @@ static int
 snapshot_was_taken( vlc_object_t *p_this, char const *psz_cmd,
                     vlc_value_t oldval, vlc_value_t newval, void *p_data );
 
-static void media_attach_preparsed_event(libvlc_media_t *);
-static void media_detach_preparsed_event(libvlc_media_t *);
-
 static void libvlc_media_player_destroy( libvlc_media_player_t *p_mi );
 
 // player callbacks
@@ -241,6 +238,16 @@ on_length_changed(vlc_player_t *player, vlc_tick_t new_length, void *data)
 
     libvlc_event_t event;
 
+    libvlc_media_t *md = mp->p_md;
+    if (md != NULL)
+    {
+        /* Duration event */
+        event.type = libvlc_MediaDurationChanged;
+        event.u.media_duration_changed.new_duration =
+            input_item_GetDuration( md->p_input_item );
+        libvlc_event_send( &md->event_manager, &event );
+    }
+
     event.type = libvlc_MediaPlayerLengthChanged;
     event.u.media_player_length_changed.new_length =
         MS_FROM_VLC_TICK(new_length);
@@ -425,6 +432,33 @@ on_chapter_selection_changed(vlc_player_t *player,
     libvlc_event_send(&mp->event_manager, &event);
 }
 
+static void
+on_media_meta_changed(vlc_player_t *player, input_item_t *media, void *data)
+{
+    (void) player;
+
+    libvlc_media_player_t *mp = data;
+    input_item_t *current = mp->p_md ? mp->p_md->p_input_item : NULL;
+    if (media != current)
+        return;
+
+    /* Meta event */
+    libvlc_event_t event;
+    event.type = libvlc_MediaMetaChanged;
+    event.u.media_meta_changed.meta_type = 0;
+    libvlc_event_send( &mp->p_md->event_manager, &event );
+
+    libvlc_media_parsed_status_t status = libvlc_media_parsed_status_done;
+    if (atomic_exchange(&mp->p_md->parsed_status, status) == status)
+        return;
+
+    /* Parsed event */
+    event.type = libvlc_MediaParsedChanged;
+    event.u.media_parsed_changed.new_status = status;
+    libvlc_event_send( &mp->p_md->event_manager, &event );
+}
+
+
 static void
 on_media_subitems_changed(vlc_player_t *player, input_item_t *media,
                           input_item_node_t *new_subitems, void *data)
@@ -541,6 +575,7 @@ static const struct vlc_player_cbs vlc_player_cbs = {
     .on_titles_changed = on_titles_changed,
     .on_title_selection_changed = on_title_selection_changed,
     .on_chapter_selection_changed = on_chapter_selection_changed,
+    .on_media_meta_changed = on_media_meta_changed,
     .on_media_subitems_changed = on_media_subitems_changed,
     .on_cork_changed = on_cork_changed,
     .on_vout_changed = on_vout_changed,
@@ -572,35 +607,6 @@ static int snapshot_was_taken(vlc_object_t *p_this, char const *psz_cmd,
     return VLC_SUCCESS;
 }
 
-static void input_item_preparsed_changed( const vlc_event_t *p_event,
-                                          void * user_data )
-{
-    libvlc_media_t *p_md = user_data;
-    if( p_event->u.input_item_preparsed_changed.new_status & ITEM_PREPARSED )
-    {
-        /* Send the event */
-        libvlc_event_t event;
-        event.type = libvlc_MediaParsedChanged;
-        event.u.media_parsed_changed.new_status = libvlc_media_parsed_status_done;
-        libvlc_event_send( &p_md->event_manager, &event );
-    }
-}
-
-static void media_attach_preparsed_event( libvlc_media_t *p_md )
-{
-    vlc_event_attach( &p_md->p_input_item->event_manager,
-                      vlc_InputItemPreparsedChanged,
-                      input_item_preparsed_changed, p_md );
-}
-
-static void media_detach_preparsed_event( libvlc_media_t *p_md )
-{
-    vlc_event_detach( &p_md->p_input_item->event_manager,
-                      vlc_InputItemPreparsedChanged,
-                      input_item_preparsed_changed,
-                      p_md );
-}
-
 /**************************************************************************
  * Create a Media Instance object.
  *
@@ -826,7 +832,6 @@ libvlc_media_player_new_from_media( libvlc_instance_t *inst,
 
     libvlc_media_retain( p_md );
     p_mi->p_md = p_md;
-    media_attach_preparsed_event(p_md);
 
     vlc_player_Lock(p_mi->player);
     int ret = vlc_player_SetCurrentMedia(p_mi->player, p_md->p_input_item);
@@ -834,7 +839,6 @@ libvlc_media_player_new_from_media( libvlc_instance_t *inst,
 
     if (ret != VLC_SUCCESS)
     {
-        media_detach_preparsed_event(p_md);
         libvlc_media_release(p_md);
         p_mi->p_md = NULL;
         return NULL;
@@ -863,8 +867,6 @@ static void libvlc_media_player_destroy( libvlc_media_player_t *p_mi )
 
     vlc_player_Delete(p_mi->player);
 
-    if (p_mi->p_md)
-        media_detach_preparsed_event(p_mi->p_md);
     libvlc_event_manager_destroy(&p_mi->event_manager);
     libvlc_media_release( p_mi->p_md );
 
@@ -910,16 +912,10 @@ void libvlc_media_player_set_media(
 {
     vlc_player_Lock(p_mi->player);
 
-    if (p_mi->p_md)
-        media_detach_preparsed_event(p_mi->p_md);
-
     libvlc_media_release( p_mi->p_md );
 
     if( p_md )
-    {
         libvlc_media_retain( p_md );
-        media_attach_preparsed_event(p_md);
-    }
     p_mi->p_md = p_md;
 
     vlc_player_SetCurrentMedia(p_mi->player, p_md ? p_md->p_input_item : NULL);


=====================================
modules/access/dcp/dcpparser.h
=====================================
@@ -40,6 +40,7 @@
 
 /* VLC core API headers */
 #include <vlc_common.h>
+#include <vlc_arrays.h>
 #include <vlc_demux.h>
 #include <vlc_plugin.h>
 


=====================================
modules/access/dshow/dshow.cpp
=====================================
@@ -37,6 +37,7 @@
 #include <vector>
 
 #include <vlc_common.h>
+#include <vlc_arrays.h>
 #include <vlc_plugin.h>
 #include <vlc_access.h>
 #include <vlc_demux.h>


=====================================
modules/demux/mkv/chapter_command.hpp
=====================================
@@ -24,6 +24,7 @@
 #ifndef VLC_MKV_CHAPTER_COMMAND_HPP_
 #define VLC_MKV_CHAPTER_COMMAND_HPP_
 
+#include <vlc_arrays.h>
 #include "mkv.hpp"
 
 namespace mkv {


=====================================
modules/lua/extension.c
=====================================
@@ -35,7 +35,6 @@
 
 #include <vlc_common.h>
 #include <vlc_interface.h>
-#include <vlc_events.h>
 #include <vlc_dialog.h>
 #include <vlc_player.h>
 


=====================================
modules/services_discovery/upnp.cpp
=====================================
@@ -35,6 +35,7 @@
 #include "upnp.hpp"
 
 #include <vlc_access.h>
+#include <vlc_arrays.h>
 #include <vlc_plugin.h>
 #include <vlc_interrupt.h>
 #include <vlc_services_discovery.h>


=====================================
po/POTFILES.in
=====================================
@@ -18,7 +18,6 @@ include/vlc/deprecated.h
 include/vlc_epg.h
 include/vlc_es.h
 include/vlc_es_out.h
-include/vlc_events.h
 include/vlc_filter.h
 include/vlc_fixups.h
 include/vlc_frame.h
@@ -90,7 +89,6 @@ src/libvlc-module.c
 src/misc/actions.c
 src/misc/cpu.c
 src/misc/es_format.c
-src/misc/events.c
 src/misc/filter_chain.c
 src/misc/frame.c
 src/misc/image.c


=====================================
src/Makefile.am
=====================================
@@ -50,7 +50,6 @@ pluginsinclude_HEADERS = \
 	../include/vlc_epg.h \
 	../include/vlc_es.h \
 	../include/vlc_es_out.h \
-	../include/vlc_events.h \
 	../include/vlc_executor.h \
 	../include/vlc_filter.h \
 	../include/vlc_fingerprinter.h \
@@ -396,7 +395,6 @@ libvlccore_la_SOURCES = \
 	misc/diffutil.c \
 	misc/epg.c \
 	misc/exit.c \
-	misc/events.c \
 	misc/image.c \
 	misc/messages.c \
 	misc/tracer.c \


=====================================
src/input/input.c
=====================================
@@ -3112,10 +3112,6 @@ static void AppendAttachment( input_thread_t *p_input, int i_new,
         }
         /* */
         priv->i_attachment = i_attachment;
-        vlc_event_send( &priv->p_item->event_manager, &(vlc_event_t) {
-            .type = vlc_InputItemAttachmentsFound,
-            .u.input_item_attachments_found.attachments = pp_new,
-            .u.input_item_attachments_found.count = i_new } );
 
         input_SendEvent(p_input, &(struct vlc_input_event) {
             .type = INPUT_EVENT_ATTACHMENTS,
@@ -3286,8 +3282,6 @@ static void input_ChangeState( input_thread_t *p_input, int i_state,
         return;
 
     input_priv(p_input)->i_state = i_state;
-    if( i_state == ERROR_S )
-        input_item_SetErrorWhenReading( input_priv(p_input)->p_item, true );
     if (i_state == END_S || i_state == ERROR_S)
         input_SendEventCapabilities( p_input, 0 );
     input_SendEventState( p_input, i_state, state_date );


=====================================
src/input/item.c
=====================================
@@ -48,46 +48,16 @@ struct input_item_opaque
 
 static enum input_item_type_e GuessType( const input_item_t *p_item, bool *p_net );
 
-void input_item_SetErrorWhenReading( input_item_t *p_i, bool b_error )
-{
-    bool b_changed;
-
-    vlc_mutex_lock( &p_i->lock );
-
-    b_changed = p_i->b_error_when_reading != b_error;
-    p_i->b_error_when_reading = b_error;
-
-    vlc_mutex_unlock( &p_i->lock );
-
-    if( b_changed )
-    {
-        vlc_event_send( &p_i->event_manager, &(vlc_event_t) {
-            .type = vlc_InputItemErrorWhenReadingChanged,
-            .u.input_item_error_when_reading_changed.new_value = b_error } );
-    }
-}
 void input_item_SetPreparsed( input_item_t *p_i )
 {
-    bool b_send_event = false;
-
     vlc_mutex_lock( &p_i->lock );
 
     int status = vlc_meta_GetStatus(p_i->p_meta);
     int new_status = status | ITEM_PREPARSED;
     if( status != new_status )
-    {
         vlc_meta_SetStatus(p_i->p_meta, new_status);
-        b_send_event = true;
-    }
 
     vlc_mutex_unlock( &p_i->lock );
-
-    if( b_send_event )
-    {
-        vlc_event_send( &p_i->event_manager, &(vlc_event_t) {
-            .type = vlc_InputItemPreparsedChanged,
-            .u.input_item_preparsed_changed.new_status = new_status } );
-    }
 }
 
 void input_item_SetArtNotFound( input_item_t *p_i, bool b_not_found )
@@ -127,11 +97,6 @@ void input_item_SetMeta( input_item_t *p_i, vlc_meta_type_t meta_type, const cha
     vlc_mutex_lock( &p_i->lock );
     vlc_meta_Set( p_i->p_meta, meta_type, psz_val );
     vlc_mutex_unlock( &p_i->lock );
-
-    /* Notify interested third parties */
-    vlc_event_send( &p_i->event_manager, &(vlc_event_t) {
-        .type = vlc_InputItemMetaChanged,
-        .u.input_item_meta_changed.meta_type = meta_type } );
 }
 
 void input_item_SetMetaExtra( input_item_t *p_i, const char *psz_name, const char *psz_value )
@@ -214,17 +179,6 @@ void input_item_CopyOptions( input_item_t *p_child,
     free( optv );
 }
 
-bool input_item_HasErrorWhenReading( input_item_t *p_item )
-{
-    vlc_mutex_lock( &p_item->lock );
-
-    bool b_error = p_item->b_error_when_reading;
-
-    vlc_mutex_unlock( &p_item->lock );
-
-    return b_error;
-}
-
 bool input_item_MetaMatch( input_item_t *p_i,
                            vlc_meta_type_t meta_type, const char *psz )
 {
@@ -408,22 +362,10 @@ vlc_tick_t input_item_GetDuration( input_item_t *p_i )
 
 void input_item_SetDuration( input_item_t *p_i, vlc_tick_t i_duration )
 {
-    bool b_send_event = false;
-
     vlc_mutex_lock( &p_i->lock );
     if( p_i->i_duration != i_duration )
-    {
         p_i->i_duration = i_duration;
-        b_send_event = true;
-    }
     vlc_mutex_unlock( &p_i->lock );
-
-    if( b_send_event )
-    {
-        vlc_event_send( &p_i->event_manager, &(vlc_event_t) {
-            .type = vlc_InputItemDurationChanged,
-            .u.input_item_duration_changed.new_duration = i_duration } );
-    }
 }
 
 char *input_item_GetNowPlayingFb( input_item_t *p_item )
@@ -482,8 +424,6 @@ void input_item_Release( input_item_t *p_item )
     if( !vlc_atomic_rc_dec( &owner->rc ) )
         return;
 
-    vlc_event_manager_fini( &p_item->event_manager );
-
     free( p_item->psz_name );
     free( p_item->psz_uri );
     free( p_item->p_stats );
@@ -797,11 +737,6 @@ int input_item_AddInfo( input_item_t *p_i,
 
     vlc_mutex_unlock( &p_i->lock );
 
-
-    if( !i_ret )
-        vlc_event_send( &p_i->event_manager, &(vlc_event_t) {
-            .type = vlc_InputItemInfoChanged } );
-
     return i_ret;
 }
 
@@ -835,9 +770,6 @@ int input_item_DelInfo( input_item_t *p_i,
     }
     vlc_mutex_unlock( &p_i->lock );
 
-    vlc_event_send( &p_i->event_manager,
-                    &(vlc_event_t) { .type = vlc_InputItemInfoChanged } );
-
     return VLC_SUCCESS;
 }
 void input_item_ReplaceInfos( input_item_t *p_item, info_category_t *p_cat )
@@ -853,9 +785,6 @@ void input_item_ReplaceInfos( input_item_t *p_item, info_category_t *p_cat )
     else
         vlc_list_append( &p_cat->node, &p_item->categories );
     vlc_mutex_unlock( &p_item->lock );
-
-    vlc_event_send( &p_item->event_manager,
-                    &(vlc_event_t) { .type = vlc_InputItemInfoChanged } );
 }
 
 void input_item_MergeInfos( input_item_t *p_item, info_category_t *p_cat )
@@ -874,14 +803,10 @@ void input_item_MergeInfos( input_item_t *p_item, info_category_t *p_cat )
     else
         vlc_list_append( &p_cat->node, &p_item->categories );
     vlc_mutex_unlock( &p_item->lock );
-
-    vlc_event_send( &p_item->event_manager,
-                    &(vlc_event_t) { .type = vlc_InputItemInfoChanged } );
 }
 
 void input_item_SetEpgEvent( input_item_t *p_item, const vlc_epg_event_t *p_epg_evt )
 {
-    bool b_changed = false;
     vlc_mutex_lock( &p_item->lock );
 
     for( int i = 0; i < p_item->i_epg; i++ )
@@ -899,19 +824,12 @@ void input_item_SetEpgEvent( input_item_t *p_item, const vlc_epg_event_t *p_epg_
                         p_epg->p_current = p_dup;
                     vlc_epg_event_Delete( p_epg->pp_event[j] );
                     p_epg->pp_event[j] = p_dup;
-                    b_changed = true;
                 }
                 break;
             }
         }
     }
     vlc_mutex_unlock( &p_item->lock );
-
-    if ( b_changed )
-    {
-        vlc_event_send( &p_item->event_manager,
-                        &(vlc_event_t) { .type = vlc_InputItemInfoChanged } );
-    }
 }
 
 //#define EPG_DEBUG
@@ -972,7 +890,7 @@ void input_item_SetEpg( input_item_t *p_item, const vlc_epg_t *p_update, bool b_
 #ifdef EPG_DEBUG
     char *psz_epg;
     if( asprintf( &psz_epg, "EPG %s", p_epg->psz_name ? p_epg->psz_name : "unknown" ) < 0 )
-        goto signal;
+        return;
 
     input_item_DelInfo( p_item, psz_epg, NULL );
 
@@ -1002,10 +920,7 @@ void input_item_SetEpg( input_item_t *p_item, const vlc_epg_t *p_update, bool b_
     }
     vlc_mutex_unlock( &p_item->lock );
     free( psz_epg );
-signal:
 #endif
-    vlc_event_send( &p_item->event_manager,
-                    &(vlc_event_t){ .type = vlc_InputItemInfoChanged, } );
 }
 
 void input_item_ChangeEPGSource( input_item_t *p_item, int i_source_id )
@@ -1064,9 +979,6 @@ void input_item_SetEpgOffline( input_item_t *p_item )
     else
         vlc_mutex_unlock( &p_item->lock );
 #endif
-
-    vlc_event_send( &p_item->event_manager,
-                    &(vlc_event_t) { .type = vlc_InputItemInfoChanged } );
 }
 
 input_item_t *
@@ -1080,7 +992,6 @@ input_item_NewExt( const char *psz_uri, const char *psz_name,
     vlc_atomic_rc_init( &owner->rc );
 
     input_item_t *p_input = &owner->item;
-    vlc_event_manager_t * p_em = &p_input->event_manager;
 
     p_input->p_meta = vlc_meta_New();
     if( unlikely(p_input->p_meta == NULL) )
@@ -1116,11 +1027,8 @@ input_item_NewExt( const char *psz_uri, const char *psz_name,
     TAB_INIT( p_input->i_epg, p_input->pp_epg );
     TAB_INIT( p_input->i_slaves, p_input->pp_slaves );
 
-    vlc_event_manager_init( p_em, p_input );
-
     if( type != ITEM_TYPE_UNKNOWN )
         p_input->i_type = type;
-    p_input->b_error_when_reading = false;
 
     if( i_net != ITEM_NET_UNKNOWN )
         p_input->b_net = i_net == ITEM_NET;


=====================================
src/input/item.h
=====================================
@@ -26,7 +26,6 @@
 #include "input_interface.h"
 #include <vlc_atomic.h>
 
-void input_item_SetErrorWhenReading( input_item_t *p_i, bool b_error );
 void input_item_UpdateTracksInfo( input_item_t *item, const es_format_t *fmt,
                                   const char *es_id, bool stable );
 bool input_item_ShouldPreparseSubItems( input_item_t *p_i );


=====================================
src/libvlccore.sym
=====================================
@@ -199,7 +199,6 @@ input_item_GetName
 input_item_GetNowPlayingFb
 input_item_GetTitleFbName
 input_item_GetURI
-input_item_HasErrorWhenReading
 input_item_IsArtFetched
 input_item_IsPreparsed
 input_item_MetaMatch
@@ -587,8 +586,6 @@ vlc_control_cancel
 vlc_GetCPUCount
 vlc_CPU
 vlc_CPU_functions_init
-vlc_event_attach
-vlc_event_detach
 vlc_filenamecmp
 vlc_fourcc_GetCodec
 vlc_fourcc_GetCodecAudio


=====================================
src/meson.build
=====================================
@@ -252,7 +252,6 @@ libvlccore_sources_base = files(
     'misc/diffutil.c',
     'misc/epg.c',
     'misc/exit.c',
-    'misc/events.c',
     'misc/image.c',
     'misc/messages.c',
     'misc/mime.c',


=====================================
src/misc/events.c deleted
=====================================
@@ -1,167 +0,0 @@
-/*****************************************************************************
- * events.c: events interface
- * This library provides an interface to the send and receive events.
- * It is more lightweight than variable based callback.
- *****************************************************************************
- * Copyright (C) 1998-2005 VLC authors and VideoLAN
- *
- * Authors: Pierre d'Herbemont <pdherbemont # videolan.org >
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-/*****************************************************************************
- * Preamble
- *****************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <vlc_common.h>
-
-#include <assert.h>
-
-#include <vlc_events.h>
-#include <vlc_arrays.h>
-
-/*****************************************************************************
- * Documentation : Read vlc_events.h
- *****************************************************************************/
-
-/*****************************************************************************
- *  Private types.
- *****************************************************************************/
-
-typedef struct vlc_event_listener_t
-{
-    void *               p_user_data;
-    vlc_event_callback_t pf_callback;
-} vlc_event_listener_t;
-
-/*****************************************************************************
- *
- *****************************************************************************/
-
-#undef vlc_event_manager_init
-/**
- * Initialize event manager object
- * p_obj is the object that contains the event manager. But not
- * necessarily a vlc_object_t (an input_item_t is not a vlc_object_t
- * for instance).
- */
-void vlc_event_manager_init( vlc_event_manager_t * p_em, void * p_obj )
-{
-    p_em->p_obj = p_obj;
-    /* This is an unsafe work-around for a long-standing playlist bug.
-     * Do not rely on this. */
-    vlc_mutex_init_recursive( &p_em->lock );
-
-    for( size_t i = 0; i < ARRAY_SIZE(p_em->events); i++ )
-       ARRAY_INIT( p_em->events[i].listeners );
-}
-
-/**
- * Destroy the event manager
- */
-void vlc_event_manager_fini( vlc_event_manager_t * p_em )
-{
-    struct vlc_event_listener_t * listener;
-
-    for( size_t i = 0; i < ARRAY_SIZE(p_em->events); i++ )
-    {
-        struct vlc_event_listeners_group_t *slot = p_em->events + i;
-
-        ARRAY_FOREACH( listener, slot->listeners )
-            free( listener );
-
-        ARRAY_RESET( slot->listeners );
-    }
-}
-
-/**
- * Send an event to the listener attached to this p_em.
- */
-void vlc_event_send( vlc_event_manager_t * p_em,
-                     vlc_event_t * p_event )
-{
-    vlc_event_listeners_group_t *slot = &p_em->events[p_event->type];
-    vlc_event_listener_t * listener;
-
-    /* Fill event with the sending object now */
-    p_event->p_obj = p_em->p_obj;
-
-    vlc_mutex_lock( &p_em->lock ) ;
-
-    ARRAY_FOREACH( listener, slot->listeners )
-        listener->pf_callback( p_event, listener->p_user_data );
-
-    vlc_mutex_unlock( &p_em->lock );
-}
-
-#undef vlc_event_attach
-/**
- * Add a callback for an event.
- */
-int vlc_event_attach( vlc_event_manager_t * p_em,
-                      vlc_event_type_t event_type,
-                      vlc_event_callback_t pf_callback,
-                      void *p_user_data )
-{
-    vlc_event_listener_t * listener;
-    vlc_event_listeners_group_t *slot = &p_em->events[event_type];
-
-    listener = malloc(sizeof(vlc_event_listener_t));
-    if( !listener )
-        return VLC_ENOMEM;
-
-    listener->p_user_data = p_user_data;
-    listener->pf_callback = pf_callback;
-
-    vlc_mutex_lock( &p_em->lock );
-    ARRAY_APPEND( slot->listeners, listener );
-    vlc_mutex_unlock( &p_em->lock );
-    return VLC_SUCCESS;
-}
-
-/**
- * Remove a callback for an event.
- */
-
-void vlc_event_detach( vlc_event_manager_t *p_em,
-                       vlc_event_type_t event_type,
-                       vlc_event_callback_t pf_callback,
-                       void *p_user_data )
-{
-    vlc_event_listeners_group_t *slot = &p_em->events[event_type];
-
-    vlc_mutex_lock( &p_em->lock );
-
-    for (int i = 0; i < slot->listeners.i_size; ++i)
-    {
-        struct vlc_event_listener_t *listener = slot->listeners.p_elems[i];
-        if( listener->pf_callback == pf_callback &&
-            listener->p_user_data == p_user_data )
-        {
-            /* that's our listener */
-            ARRAY_REMOVE( slot->listeners, i );
-            vlc_mutex_unlock( &p_em->lock );
-            free( listener );
-            return;
-        }
-    }
-
-    vlc_assert_unreachable();
-}


=====================================
src/video_output/video_epg.c
=====================================
@@ -31,7 +31,6 @@
 #include <vlc_configuration.h>
 #include <vlc_vout.h>
 #include <vlc_vout_osd.h>
-#include <vlc_events.h>
 #include <vlc_input_item.h>
 #include <vlc_epg.h>
 #include <vlc_url.h>


=====================================
test/libvlc/media.c
=====================================
@@ -30,7 +30,6 @@
 #include <vlc_threads.h>
 #include <vlc_fs.h>
 #include <vlc_input_item.h>
-#include <vlc_events.h>
 
 static void media_parse_ended(const libvlc_event_t *event, void *user_data)
 {



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2e1f78972e1682bb4404e6825de49c0dbda7c7f4...37758b8c439d10b2a2d350b163af121e1060d5d9

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2e1f78972e1682bb4404e6825de49c0dbda7c7f4...37758b8c439d10b2a2d350b163af121e1060d5d9
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