[vlc-commits] [Git][videolan/vlc][master] 5 commits: taglib: Remove explicit invocation of default constructor

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Thu Feb 17 20:32:03 UTC 2022



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
93842f65 by Hugo Beauzée-Luyssen at 2022-02-17T19:38:43+00:00
taglib: Remove explicit invocation of default constructor

This is already done implicitly

- - - - -
2f82d6b9 by Hugo Beauzée-Luyssen at 2022-02-17T19:38:43+00:00
contrib: taglib: Fix custom resolvers with IOStream

upstreamed at: https://github.com/taglib/taglib/pull/1040
Fix #26602

- - - - -
268b5b8b by Hugo Beauzée-Luyssen at 2022-02-17T19:38:43+00:00
taglib: Implement new StreamTypeResolver interface when available

refs #26602

- - - - -
98c7c135 by Hugo Beauzée-Luyssen at 2022-02-17T19:38:43+00:00
taglib: Reduce FileRef scope

- - - - -
89e20ea0 by Hugo Beauzée-Luyssen at 2022-02-17T19:38:43+00:00
taglib: Use nullptr instead of 0 for pointers

- - - - -


3 changed files:

- + contrib/src/taglib/0001-FileTypeResolver-Fix-IOStream-usage-with-custom-reso.patch
- contrib/src/taglib/rules.mak
- modules/meta_engine/taglib.cpp


Changes:

=====================================
contrib/src/taglib/0001-FileTypeResolver-Fix-IOStream-usage-with-custom-reso.patch
=====================================
@@ -0,0 +1,101 @@
+From cb9b013217b2e77066141656029cf92cf854054d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= <hugo at beauzee.fr>
+Date: Wed, 9 Feb 2022 13:51:42 +0100
+Subject: [PATCH] FileTypeResolver: Add a StreamTypeResolver interface
+
+---
+ taglib/fileref.cpp      | 19 ++++++++++++++++++-
+ taglib/fileref.h        | 10 ++++++++++
+ taglib/toolkit/taglib.h |  2 ++
+ tests/test_fileref.cpp  |  4 ++++
+ 4 files changed, 34 insertions(+), 1 deletion(-)
+
+diff --git a/taglib/fileref.cpp b/taglib/fileref.cpp
+index f91209a0..88e53ed1 100644
+--- a/taglib/fileref.cpp
++++ b/taglib/fileref.cpp
+@@ -84,6 +84,23 @@ namespace
+     return 0;
+   }
+ 
++  File *detectByResolvers(IOStream* stream, bool readAudioProperties,
++                          AudioProperties::ReadStyle audioPropertiesStyle)
++  {
++    ResolverList::ConstIterator it = fileTypeResolvers.begin();
++    for(; it != fileTypeResolvers.end(); ++it) {
++      const FileRef::StreamTypeResolver* streamResolver =
++        dynamic_cast<const FileRef::StreamTypeResolver*>(*it);
++      if (!streamResolver)
++        continue;
++      File *file = streamResolver->createFileFromStream(stream, readAudioProperties, audioPropertiesStyle);
++      if(file)
++        return file;
++    }
++
++    return 0;
++  }
++
+   // Detect the file type based on the file extension.
+ 
+   File* detectByExtension(IOStream *stream, bool readAudioProperties,
+@@ -482,7 +499,7 @@ void FileRef::parse(IOStream *stream, bool readAudioProperties,
+ {
+   // Try user-defined resolvers.
+ 
+-  d->file = detectByResolvers(stream->name(), readAudioProperties, audioPropertiesStyle);
++  d->file = detectByResolvers(stream, readAudioProperties, audioPropertiesStyle);
+   if(d->file)
+     return;
+ 
+diff --git a/taglib/fileref.h b/taglib/fileref.h
+index 76e694e4..37f44a0e 100644
+--- a/taglib/fileref.h
++++ b/taglib/fileref.h
+@@ -108,6 +108,16 @@ namespace TagLib {
+                                audioPropertiesStyle = AudioProperties::Average) const = 0;
+     };
+ 
++    class TAGLIB_EXPORT StreamTypeResolver : public FileTypeResolver
++    {
++        TAGLIB_IGNORE_MISSING_DESTRUCTOR
++      public:
++        virtual File *createFileFromStream(IOStream* stream,
++                                 bool readAudioProperties = true,
++                                 AudioProperties::ReadStyle
++                                 audioPropertiesStyle = AudioProperties::Average) const = 0;
++    };
++
+     /*!
+      * Creates a null FileRef.
+      */
+diff --git a/taglib/toolkit/taglib.h b/taglib/toolkit/taglib.h
+index ffce61f7..2bb56994 100644
+--- a/taglib/toolkit/taglib.h
++++ b/taglib/toolkit/taglib.h
+@@ -54,6 +54,8 @@
+ #define TAGLIB_DEPRECATED
+ #endif
+ 
++#define VLC_PATCHED_TAGLIB_IOSTREAM_RESOLVERS
++
+ #include <string>
+ 
+ //! A namespace for all TagLib related classes and functions
+diff --git a/tests/test_fileref.cpp b/tests/test_fileref.cpp
+index 1fc5def9..c8136129 100644
+--- a/tests/test_fileref.cpp
++++ b/tests/test_fileref.cpp
+@@ -59,6 +59,10 @@ namespace
+     {
+       return new Ogg::Vorbis::File(fileName);
+     }
++    virtual File *createFile(IOStream* s, bool, AudioProperties::ReadStyle) const
++    {
++      return new Ogg::Vorbis::File(s);
++    }
+   };
+ }
+ 
+-- 
+2.34.1
+


=====================================
contrib/src/taglib/rules.mak
=====================================
@@ -16,6 +16,7 @@ $(TARBALLS)/taglib-$(TAGLIB_VERSION).tar.gz:
 taglib: taglib-$(TAGLIB_VERSION).tar.gz .sum-taglib
 	$(UNPACK)
 	$(APPLY) $(SRC)/taglib/0001-Implement-ID3v2-readStyle-avoid-worst-case.patch
+	$(APPLY) $(SRC)/taglib/0001-FileTypeResolver-Fix-IOStream-usage-with-custom-reso.patch
 	$(MOVE)
 
 .taglib: taglib toolchain.cmake


=====================================
modules/meta_engine/taglib.cpp
=====================================
@@ -94,15 +94,27 @@ using namespace TagLib;
 #include <algorithm>
 #include <limits>
 
+#if defined(VLC_PATCHED_TAGLIB_IOSTREAM_RESOLVERS) || \
+    TAGLIB_VERSION >= VERSION_INT(1, 12, 0)
+#define USE_IOSTREAM_RESOLVER 1
+#endif
+
 namespace VLCTagLib
 {
     template <class T>
+#ifdef USE_IOSTREAM_RESOLVER
+    class ExtResolver : public FileRef::StreamTypeResolver
+#else
     class ExtResolver : public FileRef::FileTypeResolver
+#endif
     {
         public:
             ExtResolver(const std::string &);
             ~ExtResolver() {}
             virtual File *createFile(FileName, bool, AudioProperties::ReadStyle) const;
+#ifdef USE_IOSTREAM_RESOLVER
+            virtual File *createFileFromStream(IOStream*, bool, AudioProperties::ReadStyle) const;
+#endif
 
         protected:
             std::string ext;
@@ -110,7 +122,7 @@ namespace VLCTagLib
 }
 
 template <class T>
-VLCTagLib::ExtResolver<T>::ExtResolver(const std::string & ext) : FileTypeResolver()
+VLCTagLib::ExtResolver<T>::ExtResolver(const std::string & ext)
 {
     this->ext = ext;
     std::transform(this->ext.begin(), this->ext.end(), this->ext.begin(), ::toupper);
@@ -130,9 +142,28 @@ File *VLCTagLib::ExtResolver<T>::createFile(FileName fileName, bool, AudioProper
             return new T(fileName, false, AudioProperties::Fast);
     }
 
-    return 0;
+    return nullptr;
 }
 
+#ifdef USE_IOSTREAM_RESOLVER
+template<class T>
+File* VLCTagLib::ExtResolver<T>::createFileFromStream(IOStream* s, bool, AudioProperties::ReadStyle) const
+{
+    std::string filename = std::string(s->name());
+    std::size_t namesize = filename.size();
+
+    if (namesize > ext.length())
+    {
+        std::string fext = filename.substr(namesize - ext.length(), ext.length());
+        std::transform(fext.begin(), fext.end(), fext.begin(), ::toupper);
+        if(fext == ext)
+            return new T(s, ID3v2::FrameFactory::instance(), false, AudioProperties::Fast);
+    }
+
+    return nullptr;
+}
+#endif
+
 static VLCTagLib::ExtResolver<MPEG::File> aacresolver(".aac");
 static bool b_extensions_registered = false;
 
@@ -879,7 +910,6 @@ static int ReadMeta( vlc_object_t* p_this)
     vlc::threads::mutex_locker locker(taglib_lock);
     demux_meta_t*   p_demux_meta = (demux_meta_t *)p_this;
     vlc_meta_t*     p_meta;
-    FileRef f;
 
     p_demux_meta->p_meta = NULL;
 
@@ -915,7 +945,7 @@ static int ReadMeta( vlc_object_t* p_this)
     else
         s.setMaxSequentialRead( 1024 * 2048 );
 #endif
-    f = FileRef( &s, false, AudioProperties::ReadStyle::Fast );
+    FileRef f( &s, false, AudioProperties::ReadStyle::Fast );
 
     if( f.isNull() )
         return VLC_EGENERIC;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c7c215554637434632c5d37d59915ebe1169de84...89e20ea0d87f414f763ce38ff5579aec61f71b42

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c7c215554637434632c5d37d59915ebe1169de84...89e20ea0d87f414f763ce38ff5579aec61f71b42
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