vlc | branch: master | Thomas Guillem <[email protected]> | Fri Feb 21 16:39:56 2020 +0100| [de62f2a6363693e2e38724cc05657994f3d00330] | committer: Thomas Guillem
input: source: add a refcount The input_source_t will be passed to slave es_out via input_EsOutSourceNew(). It need to be refcounted since the es_out timeshift might use it asynchronously. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=de62f2a6363693e2e38724cc05657994f3d00330 --- src/input/input.c | 16 +++++++++++++++- src/input/input_internal.h | 13 +++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/input/input.c b/src/input/input.c index 0834bbd838..5e3f7fce7e 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -2487,6 +2487,8 @@ static input_source_t *InputSourceNew( input_thread_t *p_input, return NULL; } + vlc_atomic_rc_init( &in->rc ); + /* Split uri */ input_SplitMRL( &psz_access, &psz_demux, &psz_path, &psz_anchor, psz_dup ); @@ -2695,6 +2697,18 @@ static input_source_t *InputSourceNew( input_thread_t *p_input, return in; } +input_source_t *input_source_Hold( input_source_t *in ) +{ + vlc_atomic_rc_inc( &in->rc ); + return in; +} + +void input_source_Release( input_source_t *in ) +{ + if( vlc_atomic_rc_dec( &in->rc ) ) + free( in ); +} + /***************************************************************************** * InputSourceDestroy: *****************************************************************************/ @@ -2712,7 +2726,7 @@ static void InputSourceDestroy( input_source_t *in ) } TAB_CLEAN( in->i_title, in->title ); - free( in ); + input_source_Release( in ); } /***************************************************************************** diff --git a/src/input/input_internal.h b/src/input/input_internal.h index 8914c4678b..f10b6243e3 100644 --- a/src/input/input_internal.h +++ b/src/input/input_internal.h @@ -30,6 +30,7 @@ #include <vlc_demux.h> #include <vlc_input.h> #include <vlc_viewpoint.h> +#include <vlc_atomic.h> #include <libvlc.h> #include "input_interface.h" #include "misc/interrupt.h" @@ -366,6 +367,8 @@ input_item_t* input_GetItem( input_thread_t * ) VLC_USED; /* input_source_t: gathers all information per input source */ typedef struct { + vlc_atomic_rc_t rc; + demux_t *p_demux; /**< Demux object (most downstream) */ /* Title infos for that input */ @@ -635,6 +638,16 @@ int input_GetAttachments(input_thread_t *input, input_attachment_t ***attachment input_attachment_t *input_GetAttachment(input_thread_t *input, const char *name); +/** + * Hold the input_source_t + */ +input_source_t *input_source_Hold( input_source_t *in ); + +/** + * Release the input_source_t + */ +void input_source_Release( input_source_t *in ); + /* Bound pts_delay */ #define INPUT_PTS_DELAY_MAX VLC_TICK_FROM_SEC(60) _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
