[vlc-devel] [PATCH 2/2] demux: mkv: have mouse events registration non fatal

Steve Lhomme robux4 at ycbcr.xyz
Fri Sep 11 08:08:44 CEST 2020


On 2020-09-10 22:14, Francois Cartegnie wrote:
> ---
>   modules/demux/mkv/events.cpp           | 7 ++++++-
>   modules/demux/mkv/matroska_segment.cpp | 9 +++------
>   2 files changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/modules/demux/mkv/events.cpp b/modules/demux/mkv/events.cpp
> index 8526545f2c..cd7b57f1e9 100644
> --- a/modules/demux/mkv/events.cpp
> +++ b/modules/demux/mkv/events.cpp
> @@ -48,6 +48,9 @@ void event_thread_t::SetPci(const pci_t *data)
>   {
>       vlc_mutex_locker l(&lock);
>   
> +    if(es_list.empty())
> +        return;
> +

OK

>       memcpy(&pci_packet, data, sizeof(pci_packet));
>   
>   #ifndef WORDS_BIGENDIAN
> @@ -356,7 +359,9 @@ bool event_thread_t::AddES( es_out_id_t* es, int category )
>   void event_thread_t::DelES( es_out_id_t* es )
>   {
>       vlc_mutex_locker lock_guard( &lock );
> -    es_list.erase( std::find( es_list.begin(), es_list.end(), es ) );
> +    es_list_t::iterator info = std::find( es_list.begin(), es_list.end(), es );
> +    if( info != es_list.end() )
> +        es_list.erase( info );

I'm no C++ specialist, but shouldn't this be automatic ?

>   }
>   
>   } // namespace
> diff --git a/modules/demux/mkv/matroska_segment.cpp b/modules/demux/mkv/matroska_segment.cpp
> index 8fba12df9c..57cc84c816 100644
> --- a/modules/demux/mkv/matroska_segment.cpp
> +++ b/modules/demux/mkv/matroska_segment.cpp
> @@ -1123,13 +1123,10 @@ bool matroska_segment_c::ESCreate()
>           {
>               track.p_es = es_out_Add( sys.demuxer.out, &track.fmt );
>   
> -            if( track.p_es )
> +            if( track.p_es &&
> +                !sys.ev.AddES( track.p_es, track.fmt.i_cat ) )
>               {
> -                if (!sys.ev.AddES( track.p_es, track.fmt.i_cat ))
> -                {
> -                    es_out_Del( sys.demuxer.out, track.p_es );
> -                    track.p_es = NULL;
> -                }
> +                msg_Warn( &sys.demuxer, "Could not register events, interactive menus will not work");

Might be OK theoretically. But it doesn't seem to be a real life case. 
In es_out.c, ES_OUT_VOUT_SET_MOUSE_EVENT fails only if the track is not 
a video one. And it's already checked in AddES(). The same check is done 
in dvdnav or bluray.

And that's the only case were AddES will fail. In other words, AddES() 
already checks that the ES is legit to use or not, regardless of the 
mouse events.

>               }
>           }
>   
> -- 
> 2.25.4
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
> 


More information about the vlc-devel mailing list