Commit 56ba662f authored by Laurent Aimar's avatar Laurent Aimar

Clean up input_item_t functions and usages.

It fixes a bunch of missing locks and remove unused functions.
It splits input_internal.h
parent 6b843acc
...@@ -120,15 +120,11 @@ VLC_EXPORT( void, input_item_AddSubItem, ( input_item_t *p_parent, input_item_t ...@@ -120,15 +120,11 @@ VLC_EXPORT( void, input_item_AddSubItem, ( input_item_t *p_parent, input_item_t
/* Flags handled within input_item_AddOpt() */ /* Flags handled within input_item_AddOpt() */
#define VLC_INPUT_OPTION_UNIQUE 0x100 #define VLC_INPUT_OPTION_UNIQUE 0x100
VLC_EXPORT( int, input_item_AddOpt, ( input_item_t *, const char *str, unsigned flags ) ); VLC_EXPORT( int, input_item_AddOpt, ( input_item_t *, const char *str, unsigned flags ) );
VLC_EXPORT( int, input_item_AddOption, (input_item_t *item, const char *str) ); VLC_EXPORT( int, input_item_AddOption, (input_item_t *, const char * ) );
VLC_EXPORT( int ,input_item_AddOption, (input_item_t *item, const char *str) ); VLC_EXPORT( bool, input_item_HasErrorWhenReading, ( input_item_t * ) );
VLC_EXPORT( bool,input_item_HasErrorWhenReading, (input_item_t *item) ); VLC_EXPORT( void, input_item_SetMeta, ( input_item_t *, vlc_meta_type_t meta_type, const char *psz_val ));
VLC_EXPORT( void, input_item_SetMeta, ( input_item_t *p_i, vlc_meta_type_t meta_type, const char *psz_val )); VLC_EXPORT( bool, input_item_MetaMatch, ( input_item_t *p_i, vlc_meta_type_t meta_type, const char *psz ) );
VLC_EXPORT( bool,input_item_HasErrorWhenReading, (input_item_t *item) );
VLC_EXPORT( bool,input_item_MetaMatch, ( input_item_t *p_i, vlc_meta_type_t meta_type, const char *psz ) );
VLC_EXPORT( char *, input_item_GetMeta, ( input_item_t *p_i, vlc_meta_type_t meta_type ) ); VLC_EXPORT( char *, input_item_GetMeta, ( input_item_t *p_i, vlc_meta_type_t meta_type ) );
VLC_EXPORT( char *, input_item_GetName, ( input_item_t * p_i ) ); VLC_EXPORT( char *, input_item_GetName, ( input_item_t * p_i ) );
VLC_EXPORT( char *, input_item_GetURI, ( input_item_t * p_i ) ); VLC_EXPORT( char *, input_item_GetURI, ( input_item_t * p_i ) );
...@@ -137,8 +133,6 @@ VLC_EXPORT(mtime_t, input_item_GetDuration, ( input_item_t * p_i ) ); ...@@ -137,8 +133,6 @@ VLC_EXPORT(mtime_t, input_item_GetDuration, ( input_item_t * p_i ) );
VLC_EXPORT( void, input_item_SetDuration, ( input_item_t * p_i, mtime_t i_duration )); VLC_EXPORT( void, input_item_SetDuration, ( input_item_t * p_i, mtime_t i_duration ));
VLC_EXPORT( bool, input_item_IsPreparsed, ( input_item_t *p_i )); VLC_EXPORT( bool, input_item_IsPreparsed, ( input_item_t *p_i ));
VLC_EXPORT( bool, input_item_IsArtFetched, ( input_item_t *p_i )); VLC_EXPORT( bool, input_item_IsArtFetched, ( input_item_t *p_i ));
VLC_EXPORT( const vlc_meta_t *, input_item_GetMetaObject, ( input_item_t *p_i ));
VLC_EXPORT( void, input_item_MetaMerge, ( input_item_t *p_i, const vlc_meta_t * p_new_meta ));
#define input_item_SetTitle( item, b ) input_item_SetMeta( item, vlc_meta_Title, b ) #define input_item_SetTitle( item, b ) input_item_SetMeta( item, vlc_meta_Title, b )
...@@ -419,7 +413,10 @@ typedef enum input_state_e ...@@ -419,7 +413,10 @@ typedef enum input_state_e
#define INPUT_UPDATE_META 0x0040 #define INPUT_UPDATE_META 0x0040
#define INPUT_UPDATE_SIGNAL 0x0080 #define INPUT_UPDATE_SIGNAL 0x0080
/** Get the input item for an input thread */ /** Get the input item for an input thread
* FIXME see src/input/item.c but is is unsafe unless
* you hold p_input
*/
VLC_EXPORT(input_item_t*, input_GetItem, (input_thread_t*)); VLC_EXPORT(input_item_t*, input_GetItem, (input_thread_t*));
typedef struct input_thread_private_t input_thread_private_t; typedef struct input_thread_private_t input_thread_private_t;
......
...@@ -322,6 +322,7 @@ SOURCES_libvlc_common = \ ...@@ -322,6 +322,7 @@ SOURCES_libvlc_common = \
input/event.h \ input/event.h \
input/stream.h \ input/stream.h \
input/input_internal.h \ input/input_internal.h \
input/input_interface.h \
input/vlm_internal.h \ input/vlm_internal.h \
input/stream.c \ input/stream.c \
input/stream_memory.c \ input/stream_memory.c \
......
...@@ -60,8 +60,8 @@ ...@@ -60,8 +60,8 @@
*****************************************************************************/ *****************************************************************************/
static void Destructor( input_thread_t * p_input ); static void Destructor( input_thread_t * p_input );
static void* Run ( vlc_object_t *p_this ); static void *Run ( vlc_object_t *p_this );
static void* RunAndDestroy ( vlc_object_t *p_this ); static void *RunAndDestroy ( vlc_object_t *p_this );
static input_thread_t * Create ( vlc_object_t *, input_item_t *, static input_thread_t * Create ( vlc_object_t *, input_item_t *,
const char *, bool, sout_instance_t * ); const char *, bool, sout_instance_t * );
...@@ -2791,20 +2791,13 @@ static void InputUpdateMeta( input_thread_t *p_input, vlc_meta_t *p_meta ) ...@@ -2791,20 +2791,13 @@ static void InputUpdateMeta( input_thread_t *p_input, vlc_meta_t *p_meta )
} }
free( psz_arturl ); free( psz_arturl );
/* A bit ugly */ vlc_mutex_unlock( &p_item->lock );
p_meta = NULL;
if( vlc_dictionary_keys_count( &p_item->p_meta->extra_tags ) > 0 )
{
p_meta = vlc_meta_New();
vlc_meta_Merge( p_meta, input_item_GetMetaObject( p_item ) );
}
if( psz_title ) if( psz_title )
{
input_item_SetName( p_item, psz_title ); input_item_SetName( p_item, psz_title );
free( psz_title ); free( psz_title );
}
vlc_mutex_unlock( &p_item->lock );
input_item_SetPreparsed( p_item, true ); input_item_SetPreparsed( p_item, true );
input_SendEventMeta( p_input ); input_SendEventMeta( p_input );
...@@ -2914,10 +2907,11 @@ static void input_ChangeState( input_thread_t *p_input, int i_state ) ...@@ -2914,10 +2907,11 @@ static void input_ChangeState( input_thread_t *p_input, int i_state )
else if( i_state == END_S ) else if( i_state == END_S )
p_input->b_eof = true; p_input->b_eof = true;
input_item_SetHasErrorWhenReading( p_input->p->input.p_item, (i_state == ERROR_S) );
if( b_changed ) if( b_changed )
{
input_item_SetErrorWhenReading( p_input->p->input.p_item, p_input->b_error );
input_SendEventState( p_input, i_state ); input_SendEventState( p_input, i_state );
}
} }
......
/*****************************************************************************
* input_interface.h: Input functions usable ouside input code.
*****************************************************************************
* Copyright (C) 1998-2008 the VideoLAN team
* $Id$
*
* Authors: Laurent Aimar < fenrir _AT_ videolan _DOT_ 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.
*****************************************************************************/
#if defined(__PLUGIN__) || defined(__BUILTIN__) || !defined(__LIBVLC__)
# error This header file can only be included from LibVLC.
#endif
#ifndef _INPUT_INTERFACE_H
#define _INPUT_INTERFACE_H 1
#include <vlc_input.h>
#include <libvlc.h>
/**********************************************************************
* Item metadata
**********************************************************************/
int input_ArtFind( playlist_t *, input_item_t * );
int input_DownloadAndCacheArt( playlist_t *, input_item_t * );
void input_item_SetPreparsed( input_item_t *p_i, bool b_preparsed );
typedef struct playlist_album_t
{
char *psz_artist;
char *psz_album;
char *psz_arturl;
bool b_found;
} playlist_album_t;
void input_item_SetArtNotFound( input_item_t *p_i, bool b_not_found );
void input_item_SetArtFetched( input_item_t *p_i, bool b_art_fetched );
/* misc/stats.c
* FIXME it should NOT be defined here or not coded in misc/stats.c */
input_stats_t *stats_NewInputStats( input_thread_t *p_input );
/* input.c */
#define input_CreateThreadExtended(a,b,c,d) __input_CreateThreadExtended(VLC_OBJECT(a),b,c,d)
input_thread_t *__input_CreateThreadExtended ( vlc_object_t *, input_item_t *, const char *, sout_instance_t * );
sout_instance_t * input_DetachSout( input_thread_t *p_input );
#endif
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <vlc_demux.h> #include <vlc_demux.h>
#include <vlc_input.h> #include <vlc_input.h>
#include <libvlc.h> #include <libvlc.h>
#include "input_interface.h"
/***************************************************************************** /*****************************************************************************
* Private input fields * Private input fields
...@@ -233,93 +234,19 @@ static inline void input_ControlPush( input_thread_t *p_input, ...@@ -233,93 +234,19 @@ static inline void input_ControlPush( input_thread_t *p_input,
vlc_mutex_unlock( &p_input->p->lock_control ); vlc_mutex_unlock( &p_input->p->lock_control );
} }
/** Stuff moved out of vlc_input.h -- FIXME: should probably not be inline
* anyway. */
static inline void input_item_SetPreparsed( input_item_t *p_i, bool preparsed )
{
bool send_event = false;
if( !p_i->p_meta )
p_i->p_meta = vlc_meta_New();
vlc_mutex_lock( &p_i->lock );
int new_status;
if( preparsed )
new_status = p_i->p_meta->i_status | ITEM_PREPARSED;
else
new_status = p_i->p_meta->i_status & ~ITEM_PREPARSED;
if( p_i->p_meta->i_status != new_status )
{
p_i->p_meta->i_status = new_status;
send_event = true;
}
vlc_mutex_unlock( &p_i->lock );
if( send_event )
{
vlc_event_t event;
event.type = vlc_InputItemPreparsedChanged;
event.u.input_item_preparsed_changed.new_status = new_status;
vlc_event_send( &p_i->event_manager, &event );
}
}
static inline void input_item_SetArtNotFound( input_item_t *p_i, bool notfound )
{
if( !p_i->p_meta )
p_i->p_meta = vlc_meta_New();
if( notfound )
p_i->p_meta->i_status |= ITEM_ART_NOTFOUND;
else
p_i->p_meta->i_status &= ~ITEM_ART_NOTFOUND;
}
static inline void input_item_SetArtFetched( input_item_t *p_i, bool artfetched )
{
if( !p_i->p_meta )
p_i->p_meta = vlc_meta_New();
if( artfetched )
p_i->p_meta->i_status |= ITEM_ART_FETCHED;
else
p_i->p_meta->i_status &= ~ITEM_ART_FETCHED;
}
void input_item_SetHasErrorWhenReading( input_item_t *p_i, bool error );
/********************************************************************** /**********************************************************************
* Item metadata * Item metadata
**********************************************************************/ **********************************************************************/
typedef struct playlist_album_t /* input_ExtractAttachmentAndCacheArt:
{ * Becarefull; p_item lock HAS to be taken */
char *psz_artist;
char *psz_album;
char *psz_arturl;
bool b_found;
} playlist_album_t;
int input_ArtFind ( playlist_t *, input_item_t * );
int input_DownloadAndCacheArt ( playlist_t *, input_item_t * );
/* Becarefull; p_item lock HAS to be taken */
void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input ); void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input );
void input_item_SetErrorWhenReading( input_item_t *p_i, bool b_error );
/*************************************************************************** /***************************************************************************
* Internal prototypes * Internal prototypes
***************************************************************************/ ***************************************************************************/
/* misc/stats.c */
input_stats_t *stats_NewInputStats( input_thread_t *p_input );
/* input.c */
#define input_CreateThreadExtended(a,b,c,d) __input_CreateThreadExtended(VLC_OBJECT(a),b,c,d)
input_thread_t *__input_CreateThreadExtended ( vlc_object_t *, input_item_t *, const char *, sout_instance_t * );
sout_instance_t * input_DetachSout( input_thread_t *p_input );
/* var.c */ /* var.c */
void input_ControlVarInit ( input_thread_t * ); void input_ControlVarInit ( input_thread_t * );
void input_ControlVarStop( input_thread_t * ); void input_ControlVarStop( input_thread_t * );
......
This diff is collapsed.
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <vlc_playlist.h> #include <vlc_playlist.h>
#include <vlc_charset.h> #include <vlc_charset.h>
#include <vlc_strings.h> #include <vlc_strings.h>
#include "input_internal.h"
#include "../playlist/playlist_internal.h" #include "../playlist/playlist_internal.h"
#include <errno.h> #include <errno.h>
#include <limits.h> /* PATH_MAX */ #include <limits.h> /* PATH_MAX */
......
...@@ -171,14 +171,12 @@ input_item_DelInfo ...@@ -171,14 +171,12 @@ input_item_DelInfo
input_item_GetDuration input_item_GetDuration
input_item_GetInfo input_item_GetInfo
input_item_GetMeta input_item_GetMeta
input_item_GetMetaObject
input_item_GetName input_item_GetName
input_item_GetURI input_item_GetURI
input_item_HasErrorWhenReading input_item_HasErrorWhenReading
input_item_IsArtFetched input_item_IsArtFetched
input_item_IsPreparsed input_item_IsPreparsed
input_item_MetaMatch input_item_MetaMatch
input_item_MetaMerge
__input_item_NewExt __input_item_NewExt
input_item_NewWithType input_item_NewWithType
input_item_SetDuration input_item_SetDuration
......
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