[vlc-devel] [vlc-commits] taglib: template the extension fix, remove contribs patch

Filip Roséen filip at atch.se
Fri Feb 19 16:37:07 CET 2016


Hi Hannes,

The easiest way to get fix the issue would be to use
`FileRef::addFileTypeResolver (...)` as the initializer for a variable
declared `static`.

    --- a/modules/meta_engine/taglib.cpp
    +++ b/modules/meta_engine/taglib.cpp
    @@ -738,10 +738,13 @@ static int ReadMeta( vlc_object_t* p_this)
             return VLC_EGENERIC;
     
     #if TAGLIB_VERSION >= TAGLIB_SYNCDECODE_FIXED_VERSION
    -    FileRef::addFileTypeResolver( new VLCTagLib::ExtResolver<MPEG::File>(".aac") );
    +    static FileTypeResolver * ftr_acc = FileRef::addFileTypeResolver( new VLCTagLib::ExtResolver<MPEG::File>(".aac") );
     #endif
     
    -    FileRef::addFileTypeResolver( new VLCTagLib::ExtResolver<MP4::File>(".m4v") );
    +    static FileTypeResolver * ftr_m4v = FileRef::addFileTypeResolver( new VLCTagLib::ExtResolver<MP4::File>(".m4v") );
    +
    +    VLC_UNUSED(ftr_acc);
    +    VLC_UNUSED(ftr_m4v);
     
     #if defined(_WIN32)
         wchar_t *wpath = ToWide( psz_path );


This would effectivelly only invoke the functions once each, instead of
every time `ReadMeta` is called. It is however rather unfortunate that a
variable declared static of course must have a name, which is why
`VLC_UNUSED` should be used to silence warnings from the compiler.

Alternatives:

  - move the initialization of `ftr_acc` and `ftr_m4v` to a separate
    function (preferrably a lambda in C++11), and then use the
    invocation of this function as the initializer for a static variable
    (so that we only have one "unused" variable within the scope of
    `ReadMeta`), or together with `std::call_once` (c++11).

  - Declare `ftr_acc` and `ftr_m4v` as (`static`) in the global
    namespace, and introduce code such as:
    
        if (!ftr_acc) ftr_acc = FileRef::addFileTypeResolver (...)


On 16/02/19 13:45, Hannes Domani wrote:

> Hello
> 
> 
> > @@ -719,9 +738,11 @@ static int ReadMeta( vlc_object_t* p_this)
> >          return VLC_EGENERIC;
> > 
> >   #if TAGLIB_VERSION >= TAGLIB_SYNCDECODE_FIXED_VERSION
> > -       FileRef::addFileTypeResolver( new VLCTagLib::FileAAC );
> > +       FileRef::addFileTypeResolver( new VLCTagLib::ExtResolver<MPEG::File>(".aac") );
> >   #endif
> > 
> > +       FileRef::addFileTypeResolver( new VLCTagLib::ExtResolver<MP4::File>(".m4v") );
> > +
> >   #if defined(_WIN32)
> >           wchar_t *wpath = ToWide( psz_path );
> >           if( wpath == NULL )
> 
> 
> Now on every call to ReadMeta() these VLCTagLib::ExtResolver instances are added to a static list, and they are never deleted.
> Is there a way so this is only done once (and maybe delete them at the end)?
> 
> 
> Regards
> Domani Hannes
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


--
:: Filip Roséen
:: +33.768663126
:: +46.701448424
:: filip at atch.se
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20160219/592db9b9/attachment.html>


More information about the vlc-devel mailing list