Commit 56010546 authored by Antoine Cellerier's avatar Antoine Cellerier

Start of meta engine stuff. src/input/input.c needs to be fixed a bit. I'll...

Start of meta engine stuff. src/input/input.c needs to be fixed a bit. I'll finish it today. @zorglub: now you have to use the psz_arturl meta to display stuff in the interface.
parent 18efcf5c
......@@ -443,6 +443,9 @@ typedef struct global_stats_t global_stats_t;
typedef struct update_t update_t;
typedef struct update_iterator_t update_iterator_t;
/* Meta engine */
typedef struct meta_engine_t meta_engine_t;
/*****************************************************************************
* Variable callbacks
*****************************************************************************/
......
/*****************************************************************************
* vlc_input.h: Core input structures
*****************************************************************************
* Copyright (C) 1999-2004 the VideoLAN team
* Copyright (C) 1999-2006 the VideoLAN team
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
......@@ -307,7 +307,7 @@ static inline input_title_t *vlc_input_title_Duplicate( input_title_t *t )
/* "state" value */
enum input_state_e
{
INIT_S,
INIT_S,
OPENING_S,
BUFFERING_S,
PLAYING_S,
......@@ -465,6 +465,8 @@ VLC_EXPORT( input_thread_t *, __input_CreateThread, ( vlc_object_t *, input_item
VLC_EXPORT( input_thread_t *, __input_CreateThread2, ( vlc_object_t *, input_item_t *, char * ) );
#define input_Preparse(a,b) __input_Preparse(VLC_OBJECT(a),b)
VLC_EXPORT( int, __input_Preparse, ( vlc_object_t *, input_item_t * ) );
#define input_SecondaryPreparse(a,b) __input_SecondaryPreparse(VLC_OBJECT(a),b)
VLC_EXPORT( int, __input_SecondaryPreparse, ( vlc_object_t *, input_item_t * ) );
#define input_Read(a,b,c) __input_Read(VLC_OBJECT(a),b, c)
VLC_EXPORT( int, __input_Read, ( vlc_object_t *, input_item_t *, vlc_bool_t ) );
......
......@@ -43,6 +43,8 @@
#define VLC_META_PUBLISHER N_("Publisher")
#define VLC_META_ENCODED_BY N_("Encoded by")
#define VLC_META_ART_URL N_("Art URL")
#define VLC_META_CODEC_NAME N_("Codec Name")
#define VLC_META_CODEC_DESCRIPTION N_("Codec Description")
......@@ -64,6 +66,7 @@ struct vlc_meta_t
char *psz_nowplaying;
char *psz_publisher;
char *psz_encodedby;
char *psz_arturl;
#if 0
/* track meta information */
int i_track;
......@@ -91,6 +94,7 @@ struct vlc_meta_t
#define vlc_meta_SetNowPlaying( meta, b ) vlc_meta_Set( meta, nowplaying, b );
#define vlc_meta_SetPublisher( meta, b ) vlc_meta_Set( meta, publisher, b );
#define vlc_meta_SetEncodedBy( meta, b ) vlc_meta_Set( meta, encodedby, b );
#define vlc_meta_SetArtURL( meta, b ) vlc_meta_Set( meta, arturl, b );
static inline vlc_meta_t *vlc_meta_New( void )
{
......@@ -112,6 +116,7 @@ static inline vlc_meta_t *vlc_meta_New( void )
m->psz_nowplaying = NULL;
m->psz_publisher = NULL;
m->psz_encodedby = NULL;
m->psz_arturl = NULL;
return m;
}
......@@ -133,6 +138,7 @@ static inline void vlc_meta_Delete( vlc_meta_t *m )
free( m->psz_nowplaying );
free( m->psz_publisher );
free( m->psz_encodedby );
free( m->psz_arturl );
free( m );
}
......@@ -161,6 +167,7 @@ static inline void vlc_meta_Merge( vlc_meta_t *dst, vlc_meta_t *src )
COPY_FIELD( nowplaying );
COPY_FIELD( publisher );
COPY_FIELD( encodedby );
COPY_FIELD( arturl );
}
/** \todo Track meta */
......
/*****************************************************************************
* vlc_meta_engine.h: meta engine module.
*****************************************************************************
* Copyright (C) 2006 the VideoLAN team
* $Id$
*
* Authors: Antoine Cellerier <dionoea A videolan D org>
*
* 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_META_ENGINE_H
#define _VLC_META_ENGINE_H
#include "vlc_meta.h"
#define VLC_META_ENGINE_TITLE 0x00000001
#define VLC_META_ENGINE_AUTHOR 0x00000002
#define VLC_META_ENGINE_ARTIST 0x00000004
#define VLC_META_ENGINE_GENRE 0x00000008
#define VLC_META_ENGINE_COPYRIGHT 0x00000010
#define VLC_META_ENGINE_COLLECTION 0x00000020
#define VLC_META_ENGINE_SEQ_NUM 0x00000040
#define VLC_META_ENGINE_DESCRIPTION 0x00000080
#define VLC_META_ENGINE_RATING 0x00000100
#define VLC_META_ENGINE_DATE 0x00000200
#define VLC_META_ENGINE_URL 0x00000400
#define VLC_META_ENGINE_LANGUAGE 0x00000800
#define VLC_META_ENGINE_ART_URL 0x00001000
#define VLC_META_ENGINE_MB_ARTIST_ID 0x00002000
#define VLC_META_ENGINE_MB_RELEASE_ID 0x00004000
#define VLC_META_ENGINE_MB_TRACK_ID 0x00008000
#define VLC_META_ENGINE_MB_TRM_ID 0x00010000
typedef struct meta_engine_sys_t meta_engine_sys_t;
struct meta_engine_t
{
VLC_COMMON_MEMBERS
module_t *p_module;
uint32_t i_mandatory; /**< Stuff which we really need to get */
uint32_t i_optional; /**< Stuff which we'd like to have */
input_item_t *p_item;
};
#endif
/*****************************************************************************
* vlc_objects.h: vlc_object_t definition and manipulation methods
*****************************************************************************
* Copyright (C) 2002 the VideoLAN team
* Copyright (C) 2002-2006 the VideoLAN team
* $Id$
*
* Authors: Samuel Hocevar <sam@zoy.org>
......@@ -32,38 +32,39 @@
*/
/* Object types */
#define VLC_OBJECT_ROOT (-1)
#define VLC_OBJECT_LIBVLC (-2)
#define VLC_OBJECT_MODULE (-3)
#define VLC_OBJECT_INTF (-4)
#define VLC_OBJECT_PLAYLIST (-5)
#define VLC_OBJECT_ITEM (-6)
#define VLC_OBJECT_INPUT (-7)
#define VLC_OBJECT_DECODER (-8)
#define VLC_OBJECT_VOUT (-9)
#define VLC_OBJECT_AOUT (-10)
#define VLC_OBJECT_SOUT (-11)
#define VLC_OBJECT_HTTPD (-12)
#define VLC_OBJECT_PACKETIZER (-13)
#define VLC_OBJECT_ENCODER (-14)
#define VLC_OBJECT_DIALOGS (-15)
#define VLC_OBJECT_VLM (-16)
#define VLC_OBJECT_ANNOUNCE (-17)
#define VLC_OBJECT_DEMUX (-18)
#define VLC_OBJECT_ACCESS (-19)
#define VLC_OBJECT_STREAM (-20)
#define VLC_OBJECT_OPENGL (-21)
#define VLC_OBJECT_FILTER (-22)
#define VLC_OBJECT_VOD (-23)
#define VLC_OBJECT_SPU (-24)
#define VLC_OBJECT_TLS (-25)
#define VLC_OBJECT_SD (-26)
#define VLC_OBJECT_XML (-27)
#define VLC_OBJECT_OSDMENU (-28)
#define VLC_OBJECT_STATS (-29)
#define VLC_OBJECT_HTTPD_HOST (-30)
#define VLC_OBJECT_GENERIC (-666)
#define VLC_OBJECT_ROOT (-1)
#define VLC_OBJECT_LIBVLC (-2)
#define VLC_OBJECT_MODULE (-3)
#define VLC_OBJECT_INTF (-4)
#define VLC_OBJECT_PLAYLIST (-5)
#define VLC_OBJECT_ITEM (-6)
#define VLC_OBJECT_INPUT (-7)
#define VLC_OBJECT_DECODER (-8)
#define VLC_OBJECT_VOUT (-9)
#define VLC_OBJECT_AOUT (-10)
#define VLC_OBJECT_SOUT (-11)
#define VLC_OBJECT_HTTPD (-12)
#define VLC_OBJECT_PACKETIZER (-13)
#define VLC_OBJECT_ENCODER (-14)
#define VLC_OBJECT_DIALOGS (-15)
#define VLC_OBJECT_VLM (-16)
#define VLC_OBJECT_ANNOUNCE (-17)
#define VLC_OBJECT_DEMUX (-18)
#define VLC_OBJECT_ACCESS (-19)
#define VLC_OBJECT_STREAM (-20)
#define VLC_OBJECT_OPENGL (-21)
#define VLC_OBJECT_FILTER (-22)
#define VLC_OBJECT_VOD (-23)
#define VLC_OBJECT_SPU (-24)
#define VLC_OBJECT_TLS (-25)
#define VLC_OBJECT_SD (-26)
#define VLC_OBJECT_XML (-27)
#define VLC_OBJECT_OSDMENU (-28)
#define VLC_OBJECT_STATS (-29)
#define VLC_OBJECT_HTTPD_HOST (-30)
#define VLC_OBJECT_META_ENGINE (-31)
#define VLC_OBJECT_GENERIC (-666)
/* Object search mode */
#define FIND_PARENT 0x0001
......
......@@ -145,6 +145,7 @@ struct playlist_t
mtime_t i_vout_destroyed_date;
mtime_t i_sout_destroyed_date;
playlist_preparse_t *p_preparse; /**< Preparser object */
playlist_preparse_t *p_secondary_preparse; /**< Preparser object */
vlc_mutex_t gc_lock; /**< Lock to protect the garbage collection */
......
......@@ -538,6 +538,7 @@ struct module_symbols_t
void (*aout_EnableFilter_inner) (vlc_object_t *, const char *, vlc_bool_t);
void (*playlist_NodesPairCreate_inner) (playlist_t *, char *, playlist_item_t **, playlist_item_t **, vlc_bool_t);
char * (*aout_VisualChange_inner) (vlc_object_t *, int);
int (*__input_SecondaryPreparse_inner) (vlc_object_t *, input_item_t *);
};
# if defined (__PLUGIN__)
# define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
......@@ -1010,6 +1011,7 @@ struct module_symbols_t
# define aout_EnableFilter (p_symbols)->aout_EnableFilter_inner
# define playlist_NodesPairCreate (p_symbols)->playlist_NodesPairCreate_inner
# define aout_VisualChange (p_symbols)->aout_VisualChange_inner
# define __input_SecondaryPreparse (p_symbols)->__input_SecondaryPreparse_inner
# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
/******************************************************************
* STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.
......@@ -1485,6 +1487,7 @@ struct module_symbols_t
((p_symbols)->aout_EnableFilter_inner) = aout_EnableFilter; \
((p_symbols)->playlist_NodesPairCreate_inner) = playlist_NodesPairCreate; \
((p_symbols)->aout_VisualChange_inner) = aout_VisualChange; \
((p_symbols)->__input_SecondaryPreparse_inner) = __input_SecondaryPreparse; \
(p_symbols)->net_ConvertIPv4_deprecated = NULL; \
(p_symbols)->__playlist_ItemNew_deprecated = NULL; \
(p_symbols)->__playlist_ItemCopy_deprecated = NULL; \
......
SOURCES_musicbrainz = musicbrainz.c
......@@ -29,173 +29,108 @@
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <vlc_meta.h>
#include <vlc_meta_engine.h>
#include "musicbrainz/mb_c.h"
/*****************************************************************************
* intf_sys_t: description and status of log interface
*****************************************************************************/
struct intf_sys_t
{
};
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
static int ItemChange( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
static int FindMeta( vlc_object_t * );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin();
set_category( CAT_INTERFACE );
set_subcategory( SUBCAT_INTERFACE_CONTROL );
/* set_category( CAT_INTERFACE );
set_subcategory( SUBCAT_INTERFACE_CONTROL );*/
set_shortname( N_( "MusicBrainz" ) );
set_description( _("MusicBrainz meta data") );
set_capability( "interface", 0 );
set_callbacks( Open, Close );
set_capability( "meta engine", 80 );
set_callbacks( FindMeta, NULL );
vlc_module_end();
/*****************************************************************************
* Open: initialize and create stuff
*****************************************************************************/
static int Open( vlc_object_t *p_this )
static int FindMeta( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
playlist_t *p_playlist;
MALLOC_ERR( p_intf->p_sys, intf_sys_t );
p_playlist = pl_Yield( p_intf );
var_AddCallback( p_playlist, "item-change", ItemChange, p_intf );
var_AddCallback( p_playlist, "playlist-current", ItemChange, p_intf );
pl_Release( p_intf );
return VLC_SUCCESS;
}
meta_engine_t *p_me = (meta_engine_t *)p_this;
input_item_t *p_item = p_me->p_item;
/*****************************************************************************
* Close: destroy interface stuff
*****************************************************************************/
static void Close( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
playlist_t *p_playlist = pl_Yield( p_this );
var_DelCallback( p_playlist, "item-change", ItemChange, p_intf );
var_DelCallback( p_playlist, "playlist-current", ItemChange, p_intf );
pl_Release( p_this );
/* Destroy structure */
free( p_intf->p_sys );
}
/*****************************************************************************
* ItemChange: Playlist item change callback
*****************************************************************************/
static int ItemChange( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *param )
{
intf_thread_t *p_intf = (intf_thread_t *)param;
char *psz_title = NULL;
char *psz_artist = NULL;
char *psz_album = NULL;
input_thread_t *p_input;
playlist_t *p_playlist = pl_Yield( p_this );
p_input = p_playlist->p_input;
pl_Release( p_this );
char psz_buf[256];
char psz_data[256];
char i_album_count, i;
char *ppsz_args[4];
if( !p_input ) return VLC_SUCCESS;
vlc_object_yield( p_input );
if( !p_item->p_meta ) return VLC_EGENERIC;
psz_artist = p_item->p_meta->psz_artist;
psz_album = p_item->p_meta->psz_album;
psz_title = p_item->psz_name;
if( p_input->b_dead || !p_input->input.p_item->psz_name )
if( !psz_artist || !psz_album )
return VLC_EGENERIC;
musicbrainz_t p_mb;
p_mb = mb_New();
#ifdef WIN32
mb_WSAInit( p_mb );
#endif
mb_SetDepth( p_mb, 2 );
ppsz_args[0] = psz_album;
ppsz_args[1] = psz_artist;
ppsz_args[2] = NULL;
if( !mb_QueryWithArgs( p_mb,
"<mq:FindAlbum>\n" \
" <mq:depth>@DEPTH@</mq:depth>\n" \
" <mq:maxItems>@MAX_ITEMS@</mq:maxItems>\n" \
" <mq:albumName>@1@</mq:albumName>\n" \
" <mq:artistName>@2@</mq:artistName>\n" \
"</mq:FindAlbum>\n", ppsz_args ) )
{
/* Not playing anything ... */
vlc_object_release( p_input );
return VLC_SUCCESS;
mb_GetQueryError( p_mb, psz_buf, 256 );
msg_Err( p_me, "Query failed: %s\n", psz_buf );
mb_Delete( p_mb );
return VLC_EGENERIC;
}
/* Playing something ... */
psz_artist = p_input->input.p_item->p_meta->psz_artist;
psz_album = p_input->input.p_item->p_meta->psz_album;
psz_title = p_input->input.p_item->psz_name;
if( psz_artist && psz_album /* && psz_title */ )
i_album_count = mb_GetResultInt( p_mb, MBE_GetNumAlbums );
if( i_album_count < 1 )
{
musicbrainz_t p_mb;
char psz_buf[256];
char psz_data[256];
char i_album_count, i;
char *ppsz_args[4];
fprintf( stdout,"--> %s %s %s\n", psz_artist, psz_album, psz_title );
p_mb = mb_New();
#ifdef WIN32
mb_WSAInit( p_mb );
#endif
mb_SetDepth( p_mb, 2 );
ppsz_args[0] = psz_album;
ppsz_args[1] = psz_artist;
ppsz_args[2] = NULL;
if( !mb_QueryWithArgs( p_mb,
"<mq:FindAlbum>\n" \
" <mq:depth>@DEPTH@</mq:depth>\n" \
" <mq:maxItems>@MAX_ITEMS@</mq:maxItems>\n" \
" <mq:albumName>@1@</mq:albumName>\n" \
" <mq:artistName>@2@</mq:artistName>\n" \
"</mq:FindAlbum>\n", ppsz_args ) )
{
mb_GetQueryError( p_mb, psz_buf, 256 );
msg_Err( p_intf, "Query failed: %s\n", psz_buf );
mb_Delete( p_mb );
vlc_object_release( p_input );
return VLC_EGENERIC;
}
msg_Err( p_me, "No albums found.\n" );
mb_Delete( p_mb );
return VLC_EGENERIC;
}
i_album_count = mb_GetResultInt( p_mb, MBE_GetNumAlbums );
if( i_album_count < 1 )
{
msg_Err( p_intf, "No albums found.\n" );
mb_Delete( p_mb );
vlc_object_release( p_input );
return VLC_EGENERIC;
}
msg_Dbg( p_me, "Found %d albums.\n", i_album_count );
for( i = 1; i <= i_album_count; i++ )
{
mb_Select( p_mb, MBS_Rewind );
mb_Select1( p_mb, MBS_SelectAlbum, i );
msg_Dbg( p_intf, "Found %d albums.\n", i_album_count );
mb_GetResultData( p_mb, MBE_AlbumGetAlbumId, psz_data, 256 );
mb_GetIDFromURL( p_mb, psz_data, psz_buf, 256 );
msg_Dbg( p_me, "Album Id: %s", psz_buf );
for( i = 1; i <= i_album_count; i++ )
if( mb_GetResultData( p_mb, MBE_AlbumGetAmazonAsin, psz_buf, 256 ) )
{
mb_Select( p_mb, MBS_Rewind );
mb_Select1( p_mb, MBS_SelectAlbum, i );
mb_GetResultData( p_mb, MBE_AlbumGetAlbumId, psz_data, 256 );
mb_GetIDFromURL( p_mb, psz_data, psz_buf, 256 );
msg_Dbg( p_intf, "Album Id: %s", psz_buf );
if( mb_GetResultData( p_mb, MBE_AlbumGetAmazonAsin, psz_buf, 256 ) )
{
msg_Dbg( p_intf, "Amazon ASIN: %s", psz_buf );
msg_Dbg( p_intf, "Album art url: " "http://images.amazon.com/images/P/%s.01._AA240_SCLZZZZZZZ_.jpg", psz_buf );
break;
}
msg_Dbg( p_me, "Amazon ASIN: %s", psz_buf );
sprintf( psz_data, "http://images.amazon.com/images/P/%s.01._SCLZZZZZZZ_.jpg", psz_buf );
vlc_meta_SetArtURL( p_item->p_meta, psz_data );
break;
}
}
#ifdef WIN32
mb_WSAInit( p_mb );
mb_WSAInit( p_mb );
#endif
mb_Delete( p_mb );
}
vlc_object_release( p_input );
mb_Delete( p_mb );
return VLC_SUCCESS;
}
......@@ -12,4 +12,3 @@ SOURCES_gnutls = gnutls.c
SOURCES_svg = svg.c
SOURCES_profile_parser = profile_parser.c
SOURCES_audioscrobbler = audioscrobbler.c
SOURCES_musicbrainz = musicbrainz.c
......@@ -39,6 +39,7 @@
#include "vlc_playlist.h"
#include "vlc_interface.h"
#include "vlc_interaction.h"
#include "vlc_meta_engine.h"
#include "charset.h"
......@@ -344,6 +345,110 @@ int __input_Preparse( vlc_object_t *p_parent, input_item_t *p_item )
return VLC_SUCCESS;
}
int __input_SecondaryPreparse( vlc_object_t *p_parent, input_item_t *p_item )
{
struct meta_engine_t *p_me;
/* FIXME: don't launch any module if we already have all the needed
* info. Easiest way to do this would be to add a dummy module.
* I'll do that later */
p_me = vlc_object_create( p_parent, VLC_OBJECT_META_ENGINE );
p_me->i_flags |= OBJECT_FLAGS_NOINTERACT;
p_me->i_mandatory = VLC_META_ENGINE_TITLE
| VLC_META_ENGINE_AUTHOR
| VLC_META_ENGINE_ARTIST
| VLC_META_ENGINE_ART_URL;
p_me->i_optional = 0;
p_me->p_item = p_item;
p_me->p_module = module_Need( p_me, "meta engine", 0, VLC_FALSE );
if( !p_me->p_module )
{
msg_Err( p_parent, "no suitable meta engine module" );
return VLC_EGENERIC;
}
module_Unneed( p_me, p_me->p_module );
if( p_item->p_meta
&& p_item->p_meta->psz_arturl
&& *p_item->p_meta->psz_arturl
&& strncmp( p_item->p_meta->psz_arturl, "file", 4 ) )
{
/* process album art */
#define MAX_PATH 10000
char *psz_artist = p_item->p_meta->psz_artist;
char *psz_album = p_item->p_meta->psz_album;
char *psz_type = strrchr( p_item->p_meta->psz_arturl, '.' );
char *psz_filename = (char *)malloc( MAX_PATH );
FILE *p_file;
/* GRUIKKKKKKKKKK */
snprintf( psz_filename, MAX_PATH,
"file://%s/" CONFIG_DIR,
p_parent->p_libvlc->psz_homedir );
utf8_mkdir( psz_filename+7 );
snprintf( psz_filename, MAX_PATH,
"file://%s/" CONFIG_DIR "/art",
p_parent->p_libvlc->psz_homedir );
utf8_mkdir( psz_filename+7 );
snprintf( psz_filename, MAX_PATH,
"file://%s/" CONFIG_DIR "/art/%s",
p_parent->p_libvlc->psz_homedir,
psz_artist );
utf8_mkdir( psz_filename+7 );
snprintf( psz_filename, MAX_PATH,
"file://%s/" CONFIG_DIR "/art/%s/%s",
p_parent->p_libvlc->psz_homedir,
psz_artist, psz_album );
utf8_mkdir( psz_filename+7 );
snprintf( psz_filename, MAX_PATH,
"file://%s/" CONFIG_DIR "/art/%s/%s/art%s",
p_parent->p_libvlc->psz_homedir,
psz_artist, psz_album, psz_type );
msg_Dbg( p_parent, "Saving album art to %s", psz_filename );
/* Check if file exists */
p_file = utf8_fopen( psz_filename+7, "r" );
if( p_file )
{
msg_Dbg( p_parent, "Album art %s already exists", psz_filename );
fclose( p_file );
}
else
{
stream_t *p_stream = stream_UrlNew( p_parent,
p_item->p_meta->psz_arturl );
if( p_stream )
{
void *p_buffer = malloc( 1<<16 );
long int l_read;
p_file = utf8_fopen( psz_filename+7, "w" );
printf("a %p\n");
while( ( l_read = stream_Read( p_stream, p_buffer, 1<<16 ) ) )
{
printf("%d\n", l_read);
fwrite( p_buffer, l_read, 1, p_file );
printf("////\n");
}
printf("a\n");
free( p_buffer );
fclose( p_file );
stream_Delete( p_stream );
msg_Dbg( p_parent, "Album art saved to %s\n", psz_filename );
free( p_item->p_meta->psz_arturl );
p_item->p_meta->psz_arturl = strdup( psz_filename );
}
}
free( psz_filename );
}
return VLC_SUCCESS;
}
/**
* Request a running input thread to stop and die
*
......
......@@ -522,6 +522,7 @@ static void PrintMsg ( vlc_object_t * p_this, msg_item_t * p_item )
case VLC_OBJECT_ANNOUNCE: psz_object = "announce handler"; break;
case VLC_OBJECT_DEMUX: psz_object = "demuxer"; break;
case VLC_OBJECT_ACCESS: psz_object = "access"; break;
case VLC_OBJECT_META_ENGINE: psz_object = "meta engine"; break;
}
#ifdef UNDER_CE
......
......@@ -56,6 +56,7 @@
#include "vlc_tls.h"
#include "vlc_xml.h"
#include "vlc_osd.h"
#include "vlc_meta_engine.h"
/*****************************************************************************
* Local prototypes
......@@ -212,6 +213,10 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type )
i_size = sizeof( announce_handler_t );
psz_type = "announce";
break;
case VLC_OBJECT_META_ENGINE:
i_size = sizeof( meta_engine_t );
psz_type = "meta engine";
break;
case VLC_OBJECT_OSDMENU:
i_size = sizeof( osd_menu_t );
psz_type = "osd menu";
......
......@@ -230,8 +230,7 @@ void PreparseEnqueueItemSub( playlist_t *p_playlist,
{
for( i = 0; i < p_item->i_children; i++)
{
PreparseEnqueueItemSub( p_playlist,
p_item->pp_children[i] );
PreparseEnqueueItemSub( p_playlist, p_item->pp_children[i] );
}
}
}
......
......@@ -143,9 +143,11 @@ void playlist_Destroy( playlist_t *p_playlist )
playlist_MLDump( p_playlist );
vlc_thread_join( p_playlist->p_preparse );
vlc_thread_join( p_playlist->p_secondary_preparse );
vlc_thread_join( p_playlist );
vlc_object_detach( p_playlist->p_preparse );
vlc_object_detach( p_playlist->p_secondary_preparse );
var_Destroy( p_playlist, "intf-change" );
var_Destroy( p_playlist, "item-change" );
......@@ -171,6 +173,7 @@ void playlist_Destroy( playlist_t *p_playlist )
vlc_mutex_destroy( &p_playlist->gc_lock );
vlc_object_destroy( p_playlist->p_preparse );
vlc_object_destroy( p_playlist->p_secondary_preparse );
vlc_object_detach( p_playlist );
vlc_object_destroy( p_playlist );
......@@ -449,7 +452,7 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
if( p_obj->i_waiting > 0 )
{
input_item_t *p_current = p_playlist->p_preparse->pp_waiting[0];
input_item_t *p_current = p_obj->pp_waiting[0];
REMOVE_ELEM( p_obj->pp_waiting, p_obj->i_waiting, 0 );
vlc_mutex_unlock( &p_obj->object_lock );
PL_LOCK;
......@@ -478,8 +481,19 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
{
var_SetInteger( p_playlist, "item-change",
p_current->i_id );
}
vlc_gc_decref( p_current );
/* Add to secondary preparse queue */
PL_LOCK
vlc_mutex_lock( &p_playlist->p_secondary_preparse->object_lock );
INSERT_ELEM( p_playlist->p_secondary_preparse->pp_waiting,
p_playlist->p_secondary_preparse->i_waiting,
p_playlist->p_secondary_preparse->i_waiting,
p_current );
vlc_gc_incref( p_current );
vlc_mutex_unlock( &p_playlist->p_secondary_preparse->object_lock );
PL_UNLOCK
}
else
{
......@@ -495,6 +509,34 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
vlc_mutex_unlock( &p_obj->object_lock );
}
/** Main loop for secondary preparser queue */
void playlist_SecondaryPreparseLoop( playlist_preparse_t *p_obj )
{
playlist_t *p_playlist = (playlist_t *)p_obj->p_parent;
vlc_mutex_lock( &p_obj->object_lock );
if( p_obj->i_waiting > 0 )
{
input_item_t *p_current = p_obj->pp_waiting[0];
REMOVE_ELEM( p_obj->pp_waiting, p_obj->i_waiting, 0 );
vlc_mutex_unlock( &p_obj->object_lock );
if( p_current )
{
input_SecondaryPreparse( p_playlist, p_current );
var_SetInteger( p_playlist, "item-change",
p_current->i_id );
vlc_gc_decref( p_current );
}
else
{
vlc_mutex_unlock( &p_playlist->object_lock );
}
return;
}
vlc_mutex_unlock( &p_obj->object_lock );
}
static void VariablesInit( playlist_t *p_playlist )
{
vlc_value_t val;
......
......@@ -52,6 +52,7 @@ void playlist_Destroy ( playlist_t * );
void playlist_MainLoop( playlist_t * );
void playlist_LastLoop( playlist_t * );
void playlist_PreparseLoop( playlist_preparse_t * );
void playlist_SecondaryPreparseLoop( playlist_preparse_t * );
/* Control */
playlist_item_t * playlist_NextItem ( playlist_t * );
......
......@@ -33,6 +33,7 @@
*****************************************************************************/
static void RunControlThread ( playlist_t * );
static void RunPreparse( playlist_preparse_t * );
static void RunSecondaryPreparse( playlist_preparse_t * );
static playlist_t * CreatePlaylist( vlc_object_t *p_parent );
static void HandlePlaylist( playlist_t * );
......@@ -93,6 +94,30 @@ void __playlist_ThreadCreate( vlc_object_t *p_parent )
return;
}
// Secondary Preparse
p_playlist->p_secondary_preparse = vlc_object_create( p_playlist,
sizeof( playlist_preparse_t ) );
if( !p_playlist->p_secondary_preparse )
{
msg_Err( p_playlist, "unable to create secondary preparser" );
vlc_object_destroy( p_playlist );
return;
}
p_playlist->p_secondary_preparse->i_waiting = 0;
p_playlist->p_secondary_preparse->pp_waiting = NULL;
vlc_object_attach( p_playlist->p_secondary_preparse, p_playlist );
if( vlc_thread_create( p_playlist->p_secondary_preparse,
"secondary preparser",
RunSecondaryPreparse,
VLC_THREAD_PRIORITY_LOW, VLC_TRUE ) )
{
msg_Err( p_playlist, "cannot spawn secondary preparse thread" );
vlc_object_detach( p_playlist->p_secondary_preparse );
vlc_object_destroy( p_playlist->p_secondary_preparse );
return;
}
// Start the thread
if( vlc_thread_create( p_playlist, "playlist", RunControlThread,
VLC_THREAD_PRIORITY_LOW, VLC_TRUE ) )
......@@ -185,7 +210,23 @@ static void RunPreparse ( playlist_preparse_t *p_obj )
while( !p_playlist->b_die )
{
playlist_PreparseLoop( p_obj );
playlist_PreparseLoop( p_obj );
if( p_obj->i_waiting == 0 )
{
msleep( INTF_IDLE_SLEEP );
}
}
}
static void RunSecondaryPreparse( playlist_preparse_t *p_obj )
{
playlist_t *p_playlist = (playlist_t *)p_obj->p_parent;
/* Tell above that we're ready */
vlc_thread_ready( p_obj );
while( !p_playlist->b_die )
{
playlist_SecondaryPreparseLoop( p_obj );
if( p_obj->i_waiting == 0 )
{
msleep( INTF_IDLE_SLEEP );
......
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