[vlc-devel] commit: art_finder_t: custom type for art finder modules ( Rémi Denis-Courmont )

git version control git at videolan.org
Sun Aug 23 12:08:53 CEST 2009


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Aug 23 13:07:03 2009 +0300| [bd6930e42cd1aecdf8e4d292ea089a9e12ae0960] | committer: Rémi Denis-Courmont 

art_finder_t: custom type for art finder modules

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bd6930e42cd1aecdf8e4d292ea089a9e12ae0960
---

 include/vlc_art_finder.h     |   30 ++++++++++++++++++++++++++++++
 modules/meta_engine/folder.c |    4 +++-
 modules/misc/lua/meta.c      |    4 +++-
 src/playlist/fetcher.c       |   38 ++++++++++++++++++++++----------------
 4 files changed, 58 insertions(+), 18 deletions(-)

diff --git a/include/vlc_art_finder.h b/include/vlc_art_finder.h
new file mode 100644
index 0000000..d4b7e90
--- /dev/null
+++ b/include/vlc_art_finder.h
@@ -0,0 +1,30 @@
+/*****************************************************************************
+ * vlc_art_finder.h
+ *****************************************************************************
+ * Copyright (C) 2009 Rémi Denis-Courmont
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef VLC_ART_FINDER_H
+#define VLC_ART_FINDER_H 1
+
+typedef struct art_finder_t
+{
+    VLC_COMMON_MEMBERS
+    input_item_t *p_item;
+} art_finder_t;
+
+#endif
diff --git a/modules/meta_engine/folder.c b/modules/meta_engine/folder.c
index 9ef715f..fbb9619 100644
--- a/modules/meta_engine/folder.c
+++ b/modules/meta_engine/folder.c
@@ -32,6 +32,7 @@
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_playlist.h>
+#include <vlc_art_finder.h>
 #include <vlc_charset.h>
 #include <vlc_url.h>
 
@@ -74,7 +75,8 @@ vlc_module_end ()
  *****************************************************************************/
 static int FindMeta( vlc_object_t *p_this )
 {
-    input_item_t *p_item = (input_item_t *)p_this->p_private;
+    art_finder_t *p_finder = (art_finder_t *)p_this;
+    input_item_t *p_item = p_finder->p_item;
     bool b_have_art = false;
 
     int i;
diff --git a/modules/misc/lua/meta.c b/modules/misc/lua/meta.c
index 733f2b7..5eb2ef0 100644
--- a/modules/misc/lua/meta.c
+++ b/modules/misc/lua/meta.c
@@ -37,6 +37,7 @@
 #include <vlc_input.h>
 #include <vlc_playlist.h>
 #include <vlc_meta.h>
+#include <vlc_art_finder.h>
 #include <vlc_url.h>
 #include <vlc_strings.h>
 #include <vlc_stream.h>
@@ -191,11 +192,12 @@ static int fetch_art( vlc_object_t *p_this, const char * psz_filename,
  *****************************************************************************/
 int FindArt( vlc_object_t *p_this )
 {
+    art_finder_t *p_finder = (art_finder_t *)p_this;
+    input_item_t *p_item = p_finder->p_item;
     playlist_t *p_playlist = pl_Hold( p_this );
     if( !p_playlist )
         return VLC_EGENERIC;
 
-    input_item_t *p_item = (input_item_t *)p_this->p_private;
     lua_State *L = vlclua_meta_init( p_this, p_item );
     int i_ret = vlclua_scripts_batch_execute( p_this, "meta", &fetch_art, L, p_item );
     lua_close( L );
diff --git a/src/playlist/fetcher.c b/src/playlist/fetcher.c
index d2b6356..47715c8 100644
--- a/src/playlist/fetcher.c
+++ b/src/playlist/fetcher.c
@@ -29,6 +29,7 @@
 #include <vlc_playlist.h>
 #include <vlc_stream.h>
 #include <limits.h>
+#include <vlc_art_finder.h>
 
 #include "art.h"
 #include "fetcher.h"
@@ -138,12 +139,10 @@ void playlist_fetcher_Delete( playlist_fetcher_t *p_fetcher )
 static int FindArt( playlist_fetcher_t *p_fetcher, input_item_t *p_item )
 {
     int i_ret;
-    module_t *p_module;
-    char *psz_title, *psz_artist, *psz_album;
 
-    psz_artist = input_item_GetArtist( p_item );
-    psz_album = input_item_GetAlbum( p_item );
-    psz_title = input_item_GetTitle( p_item );
+    char *psz_artist = input_item_GetArtist( p_item );
+    char *psz_album = input_item_GetAlbum( p_item );
+    char *psz_title = input_item_GetTitle( p_item );
     if( !psz_title )
         psz_title = input_item_GetName( p_item );
 
@@ -219,19 +218,26 @@ static int FindArt( playlist_fetcher_t *p_fetcher, input_item_t *p_item )
     }
 
     /* Fetch the art url */
-    p_fetcher->p_private = p_item;
-
-    p_module = module_need( p_fetcher, "art finder", NULL, false );
+    i_ret = VLC_EGENERIC;
 
-    if( p_module )
-    {
-        module_unneed( p_fetcher, p_module );
-        i_ret = 1;
-    }
-    else
+    vlc_object_t *p_parent = VLC_OBJECT(p_fetcher->p_playlist);
+    art_finder_t *p_finder =
+        vlc_custom_create( p_parent, sizeof( *p_finder ), VLC_OBJECT_GENERIC,
+                           "art finder" );
+    if( p_finder != NULL)
     {
-        msg_Dbg( p_fetcher, "unable to find art" );
-        i_ret = VLC_EGENERIC;
+        module_t *p_module;
+
+        vlc_object_attach( p_finder, p_parent );
+        p_finder->p_item = p_item;
+
+        p_module = module_need( p_parent, "art finder", NULL, false );
+        if( p_module )
+        {
+            module_unneed( p_finder, p_module );
+            i_ret = 1;
+        }
+        vlc_object_release( p_finder );
     }
 
     /* Record this album */




More information about the vlc-devel mailing list