[vlc-devel] [PATCH 6/7] preparser: post-pone event until after art fetching is complete

Filip Roséen filip at atch.se
Wed Mar 22 18:53:08 CET 2017


Hi Rémi,

I will let Hugo answer your remarks in detail as the patch might have
been written by me, but the rationale for it is his (including the
first part of the commit message).

However, I will reply with a few of my personal opinions on the
matter.

On 2017-03-22 19:33, Rémi Denis-Courmont wrote:

> Nit: postpone takes no dash.
> 
> Le keskiviikkona 22. maaliskuuta 2017, 17.58.46 EET Filip Roséen a écrit :
> > Since one can query an art fetching
> 
> Nit: Not sure what that sentence means. Maybe you mean "request fetching art".
> 
> > through libvlc_media_parse_with_options,
> > one would expect the event originating from this request to be sent upon
> > all requested operations completion.
> 
> Nit: completion of all requested ops.
> 
> > The alternative would be to monitor
> > the libvlc_MediaMetaChanged, hoping for an artork url change, but this
> > can't account for error nor timeout.
> 
> Nit: artwork.
> 
> > 
> > --
> > 
> > The changes introduced were written after a discussion with Hugo
> > Beauzée-Luyssen where he expressed that he would, if possible, be able to
> > post-pone the preparsing events until the art fetching is complete.
> 
> AFAIK, there is a reason why they are separate. Preparsing only accesses the 
> media itself, while meta fetch goes to the network.

The meta-fetchers does not necessarily have to go to the network, as
an example `modules/meta_engine/folder.c` is an art-finder that only
requires local access (but I do agree with the overall opinion in your
note).

> In many cases, the later is orders of magnitude slower. So it makes sense to 
> have the preparsed meta-data available separately.

Definitely agreed, but as one can use `libvlc_MetadataRequest` to not
request network-metadata, it could be viewed as intended by design. It
is however debatable if that is actually what most/all libvlc users
expect (as this fix is mostly for them).

> > Post-poning the event fixes issues that are currently reproducible where
> > medialibrary is used, and art is missing (because it listens to the preparse
> > event in order to generate the database contents).
> > 
> > It can be viewed as a follow-up to the below rejected patch (with the
> > same goal in mind):
> > 
> >  - https://patches.videolan.org/patch/15810/
> > ---
> >  src/playlist/fetcher.c   | 42 ++++++++++++++++++++++++++++++++++--------
> >  src/playlist/fetcher.h   |  4 ++--
> >  src/playlist/preparser.c |  7 +++++--
> >  3 files changed, 41 insertions(+), 12 deletions(-)
> > 
> > diff --git a/src/playlist/fetcher.c b/src/playlist/fetcher.c
> > index ab4b3989c4..0172906146 100644
> > --- a/src/playlist/fetcher.c
> > +++ b/src/playlist/fetcher.c
> > @@ -50,6 +50,7 @@ struct playlist_fetcher_t {
> >  struct fetcher_request {
> >      input_item_t* item;
> >      atomic_uint refs;
> > +    int preparse_status;
> >      int options;
> >  };
> > 
> > @@ -194,13 +195,23 @@ static int SearchByScope( playlist_fetcher_t* fetcher,
> > ! SearchArt( fetcher, item, scope ) )
> >      {
> >          AddAlbumCache( fetcher, req->item, false );
> > -        background_worker_Push( &fetcher->downloader, req, NULL, 0 );
> > -        return VLC_SUCCESS;
> > +
> > +        if( !background_worker_Push( &fetcher->downloader, req, NULL, 0 ) )
> > +            return VLC_SUCCESS;
> >      }
> > 
> >      return VLC_EGENERIC;
> >  }
> > 
> > +static void SetPreparsed( struct fetcher_request* req )
> > +{
> > +    if( req->preparse_status != -1 )
> > +    {
> > +        input_item_SignalPreparseEnded( req->item, req->preparse_status );
> > +        input_item_SetPreparsed( req->item, true );
> 
> This order looks race-prone. Normally, one changes the state, then signals the 
> change.

Nice catch, my only excuse is that the patch was written in a hurry
while I was actually focusing on the previous patches in this serious.

> With that said, I think I don´t really understand what this patch does, or 
> that I agree with it.

The gist of the patch is to postpone the events denoting preparsing to
after all work requested by `libvlc_MetadataRequest` has finished.
 
> > +    }
> > +}
> > +
> >  static void Downloader( playlist_fetcher_t* fetcher,
> >      struct fetcher_request* req )
> >  {
> > @@ -259,6 +270,7 @@ out:
> >      }
> > 
> >      free( psz_arturl );
> > +    SetPreparsed( req );
> >      return;
> > 
> >  error:
> > @@ -274,15 +286,25 @@ static void SearchLocal( playlist_fetcher_t* fetcher,
> > struct fetcher_request* re if( var_InheritBool( fetcher->owner,
> > "metadata-network-access" ) || req->options &
> > META_REQUEST_OPTION_SCOPE_NETWORK )
> >      {
> > -        background_worker_Push( &fetcher->network, req, NULL, 0 );
> > +        if( background_worker_Push( &fetcher->network, req, NULL, 0 ) )
> > +            SetPreparsed( req );
> > +
> > +        return;
> > +    }
> > +    else
> > +    {
> > +        input_item_SetArtNotFound( req->item, true );
> > +        SetPreparsed( req );
> >      }
> > -    else input_item_SetArtNotFound( req->item, true );
> >  }
> > 
> >  static void SearchNetwork( playlist_fetcher_t* fetcher, struct
> > fetcher_request* req ) {
> >      if( SearchByScope( fetcher, req, FETCHER_SCOPE_NETWORK ) )
> > +    {
> >          input_item_SetArtNotFound( req->item, true );
> > +        SetPreparsed( req );
> > +    }
> >  }
> > 
> >  static void RequestRelease( void* req_ )
> > @@ -399,22 +421,26 @@ playlist_fetcher_t* playlist_fetcher_New(
> > vlc_object_t* owner ) return fetcher;
> >  }
> > 
> > -void playlist_fetcher_Push( playlist_fetcher_t* fetcher, input_item_t*
> > item, -    input_item_meta_request_option_t options )
> > +int playlist_fetcher_Push( playlist_fetcher_t* fetcher, input_item_t* item,
> > +    input_item_meta_request_option_t options, int preparse_status ) {
> >      struct fetcher_request* req = malloc( sizeof *req );
> > 
> >      if( unlikely( !req ) )
> > -        return;
> > +        return VLC_ENOMEM;
> > 
> >      req->item = item;
> >      req->options = options;
> > +    req->preparse_status = preparse_status;
> > 
> >      atomic_init( &req->refs, 1 );
> >      input_item_Hold( item );
> > 
> > -    background_worker_Push( &fetcher->local, req, NULL, 0 );
> > +    if( background_worker_Push( &fetcher->local, req, NULL, 0 ) )
> > +        SetPreparsed( req );
> > +
> >      RequestRelease( req );
> > +    return VLC_SUCCESS;
> >  }
> > 
> >  void playlist_fetcher_Delete( playlist_fetcher_t* fetcher )
> > diff --git a/src/playlist/fetcher.h b/src/playlist/fetcher.h
> > index c5d9a3ddbb..06718acf77 100644
> > --- a/src/playlist/fetcher.h
> > +++ b/src/playlist/fetcher.h
> > @@ -46,8 +46,8 @@ playlist_fetcher_t *playlist_fetcher_New( vlc_object_t *
> > ); * The input item is retained until the art fetching is done or until the
> > * fetcher object is destroyed.
> >   */
> > -void playlist_fetcher_Push( playlist_fetcher_t *, input_item_t *,
> > -                            input_item_meta_request_option_t );
> > +int playlist_fetcher_Push( playlist_fetcher_t *, input_item_t *,
> > +                           input_item_meta_request_option_t, int );
> > 
> >  /**
> >   * This function destroys the fetcher object and thread.
> > diff --git a/src/playlist/preparser.c b/src/playlist/preparser.c
> > index 98a05b858c..f513abd8d3 100644
> > --- a/src/playlist/preparser.c
> > +++ b/src/playlist/preparser.c
> > @@ -95,7 +95,10 @@ static void PreparserCloseInput( void* preparser_, void*
> > input_ ) input_Close( input );
> > 
> >      if( preparser->fetcher )
> > -        playlist_fetcher_Push( preparser->fetcher, item, 0 );
> > +    {
> > +        if( !playlist_fetcher_Push( preparser->fetcher, item, 0, status ) )
> > +            return;
> > +    }
> > 
> >      input_item_SetPreparsed( item, true );
> >      input_item_SignalPreparseEnded( item, status );
> > @@ -163,7 +166,7 @@ void playlist_preparser_fetcher_Push(
> > playlist_preparser_t *preparser, input_item_t *item,
> > input_item_meta_request_option_t options ) {
> >      if( preparser->fetcher )
> > -        playlist_fetcher_Push( preparser->fetcher, item, options );
> > +        playlist_fetcher_Push( preparser->fetcher, item, options, -1 );
> >  }
> > 
> >  void playlist_preparser_Cancel( playlist_preparser_t *preparser, void *id )
> 

Thank you,\
Filip Roséen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20170322/611e8340/attachment.html>


More information about the vlc-devel mailing list