Commit bd6930e4 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

art_finder_t: custom type for art finder modules

parent 2858f56a
/*****************************************************************************
* 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
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_playlist.h> #include <vlc_playlist.h>
#include <vlc_art_finder.h>
#include <vlc_charset.h> #include <vlc_charset.h>
#include <vlc_url.h> #include <vlc_url.h>
...@@ -74,7 +75,8 @@ vlc_module_end () ...@@ -74,7 +75,8 @@ vlc_module_end ()
*****************************************************************************/ *****************************************************************************/
static int FindMeta( vlc_object_t *p_this ) 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; bool b_have_art = false;
int i; int i;
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <vlc_input.h> #include <vlc_input.h>
#include <vlc_playlist.h> #include <vlc_playlist.h>
#include <vlc_meta.h> #include <vlc_meta.h>
#include <vlc_art_finder.h>
#include <vlc_url.h> #include <vlc_url.h>
#include <vlc_strings.h> #include <vlc_strings.h>
#include <vlc_stream.h> #include <vlc_stream.h>
...@@ -191,11 +192,12 @@ static int fetch_art( vlc_object_t *p_this, const char * psz_filename, ...@@ -191,11 +192,12 @@ static int fetch_art( vlc_object_t *p_this, const char * psz_filename,
*****************************************************************************/ *****************************************************************************/
int FindArt( vlc_object_t *p_this ) 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 ); playlist_t *p_playlist = pl_Hold( p_this );
if( !p_playlist ) if( !p_playlist )
return VLC_EGENERIC; 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 ); 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 ); int i_ret = vlclua_scripts_batch_execute( p_this, "meta", &fetch_art, L, p_item );
lua_close( L ); lua_close( L );
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <vlc_playlist.h> #include <vlc_playlist.h>
#include <vlc_stream.h> #include <vlc_stream.h>
#include <limits.h> #include <limits.h>
#include <vlc_art_finder.h>
#include "art.h" #include "art.h"
#include "fetcher.h" #include "fetcher.h"
...@@ -138,12 +139,10 @@ void playlist_fetcher_Delete( playlist_fetcher_t *p_fetcher ) ...@@ -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 ) static int FindArt( playlist_fetcher_t *p_fetcher, input_item_t *p_item )
{ {
int i_ret; int i_ret;
module_t *p_module;
char *psz_title, *psz_artist, *psz_album;
psz_artist = input_item_GetArtist( p_item ); char *psz_artist = input_item_GetArtist( p_item );
psz_album = input_item_GetAlbum( p_item ); char *psz_album = input_item_GetAlbum( p_item );
psz_title = input_item_GetTitle( p_item ); char *psz_title = input_item_GetTitle( p_item );
if( !psz_title ) if( !psz_title )
psz_title = input_item_GetName( p_item ); psz_title = input_item_GetName( p_item );
...@@ -219,19 +218,26 @@ static int FindArt( playlist_fetcher_t *p_fetcher, input_item_t *p_item ) ...@@ -219,19 +218,26 @@ static int FindArt( playlist_fetcher_t *p_fetcher, input_item_t *p_item )
} }
/* Fetch the art url */ /* Fetch the art url */
p_fetcher->p_private = p_item; i_ret = VLC_EGENERIC;
p_module = module_need( p_fetcher, "art finder", NULL, false );
if( p_module ) vlc_object_t *p_parent = VLC_OBJECT(p_fetcher->p_playlist);
{ art_finder_t *p_finder =
module_unneed( p_fetcher, p_module ); vlc_custom_create( p_parent, sizeof( *p_finder ), VLC_OBJECT_GENERIC,
i_ret = 1; "art finder" );
} if( p_finder != NULL)
else
{ {
msg_Dbg( p_fetcher, "unable to find art" ); module_t *p_module;
i_ret = VLC_EGENERIC;
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 */ /* Record this album */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment