Moved input_item_t from input_source_t to input_thread_private_t.
authorLaurent Aimar <fenrir@videolan.org>
Tue, 2 Dec 2008 18:16:17 +0000 (19:16 +0100)
committerLaurent Aimar <fenrir@videolan.org>
Thu, 4 Dec 2008 19:34:06 +0000 (20:34 +0100)
src/Makefile.am
src/input/control.c
src/input/es_out.c
src/input/event.c
src/input/input.c
src/input/input_internal.h
src/input/item.c
src/input/item.h [new file with mode: 0644]
src/input/meta.c

index 48fda22..3d9f7be 100644 (file)
@@ -320,6 +320,7 @@ SOURCES_libvlc_common = \
        input/es_out.h \
        input/es_out_timeshift.h \
        input/event.h \
+       input/item.h \
        input/stream.h \
        input/input_internal.h \
        input/input_interface.h \
index 4239a40..d796037 100644 (file)
@@ -143,7 +143,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
             if( vasprintf( &psz_value, psz_format, args ) == -1 )
                 return VLC_EGENERIC;
 
-            int i_ret = input_item_AddInfo( p_input->p->input.p_item,
+            int i_ret = input_item_AddInfo( p_input->p->p_item,
                                             psz_cat, psz_name, "%s", psz_value );
             free( psz_value );
 
@@ -157,7 +157,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
             char *psz_cat = (char *)va_arg( args, char * );
             char *psz_name = (char *)va_arg( args, char * );
 
-            int i_ret = input_item_DelInfo( p_input->p->input.p_item,
+            int i_ret = input_item_DelInfo( p_input->p->p_item,
                                             psz_cat, psz_name );
 
             if( !p_input->b_preparsing && !i_ret )
@@ -174,7 +174,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
             int i_ret = VLC_EGENERIC;
             *ppsz_value = NULL;
 
-            *ppsz_value = input_item_GetInfo( p_input->p->input.p_item,
+            *ppsz_value = input_item_GetInfo( p_input->p->p_item,
                                                   psz_cat, psz_name );
             return i_ret;
         }
@@ -185,11 +185,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
 
             if( !psz_name ) return VLC_EGENERIC;
 
-            vlc_mutex_lock( &p_input->p->input.p_item->lock );
-            if( p_input->p->input.p_item->psz_name )
-                free( p_input->p->input.p_item->psz_name );
-            p_input->p->input.p_item->psz_name = strdup( psz_name );
-            vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+            input_item_SetName( p_input->p->p_item, psz_name );
 
             if( !p_input->b_preparsing )
                 input_SendEventMetaName( p_input, psz_name );
@@ -200,7 +196,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
             p_bkmk = (seekpoint_t *)va_arg( args, seekpoint_t * );
             p_bkmk = vlc_seekpoint_Duplicate( p_bkmk );
 
-            vlc_mutex_lock( &p_input->p->input.p_item->lock );
+            vlc_mutex_lock( &p_input->p->p_item->lock );
             if( !p_bkmk->psz_name )
             {
                  if( asprintf( &p_bkmk->psz_name, _("Bookmark %i"),
@@ -224,7 +220,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
                                 &val, &text );
                 }
             }
-            vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+            vlc_mutex_unlock( &p_input->p->p_item->lock );
 
             UpdateBookmarksOption( p_input );
 
@@ -234,7 +230,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
             p_bkmk = (seekpoint_t *)va_arg( args, seekpoint_t * );
             i_bkmk = (int)va_arg( args, int );
 
-            vlc_mutex_lock( &p_input->p->input.p_item->lock );
+            vlc_mutex_lock( &p_input->p->p_item->lock );
             if( i_bkmk < p_input->p->i_bookmark )
             {
                 vlc_value_t val, text;
@@ -252,7 +248,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
                                 &val, &text );
                 }
             }
-            vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+            vlc_mutex_unlock( &p_input->p->p_item->lock );
 
             UpdateBookmarksOption( p_input );
 
@@ -261,7 +257,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
         case INPUT_DEL_BOOKMARK:
             i_bkmk = (int)va_arg( args, int );
 
-            vlc_mutex_lock( &p_input->p->input.p_item->lock );
+            vlc_mutex_lock( &p_input->p->p_item->lock );
             if( i_bkmk < p_input->p->i_bookmark )
             {
                 vlc_value_t val, text;
@@ -281,13 +277,13 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
                     var_Change( p_input, "bookmark", VLC_VAR_ADDCHOICE,
                                 &val, &text );
                 }
-                vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+                vlc_mutex_unlock( &p_input->p->p_item->lock );
 
                 UpdateBookmarksOption( p_input );
 
                 return VLC_SUCCESS;
             }
-            vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+            vlc_mutex_unlock( &p_input->p->p_item->lock );
 
             return VLC_EGENERIC;
 
@@ -295,7 +291,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
             ppp_bkmk = (seekpoint_t ***)va_arg( args, seekpoint_t *** );
             pi_bkmk = (int *)va_arg( args, int * );
 
-            vlc_mutex_lock( &p_input->p->input.p_item->lock );
+            vlc_mutex_lock( &p_input->p->p_item->lock );
             if( p_input->p->i_bookmark )
             {
                 int i;
@@ -309,7 +305,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
                         vlc_seekpoint_Duplicate(p_input->p->bookmark[i]);
                 }
 
-                vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+                vlc_mutex_unlock( &p_input->p->p_item->lock );
                 return VLC_SUCCESS;
             }
             else
@@ -317,14 +313,14 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
                 *ppp_bkmk = NULL;
                 *pi_bkmk = 0;
 
-                vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+                vlc_mutex_unlock( &p_input->p->p_item->lock );
                 return VLC_EGENERIC;
             }
             break;
 
         case INPUT_CLEAR_BOOKMARKS:
 
-            vlc_mutex_lock( &p_input->p->input.p_item->lock );
+            vlc_mutex_lock( &p_input->p->p_item->lock );
             if( p_input->p->i_bookmark )
             {
                 int i;
@@ -338,7 +334,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
                 }
                 var_Change( p_input, "bookmark", VLC_VAR_CLEARCHOICES, 0, 0 );
             }
-            vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+            vlc_mutex_unlock( &p_input->p->p_item->lock );
 
             UpdateBookmarksOption( p_input );
 
@@ -347,7 +343,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
         case INPUT_SET_BOOKMARK:
             i_bkmk = (int)va_arg( args, int );
 
-            vlc_mutex_lock( &p_input->p->input.p_item->lock );
+            vlc_mutex_lock( &p_input->p->p_item->lock );
             if( i_bkmk >= 0 && i_bkmk < p_input->p->i_bookmark )
             {
                 vlc_value_t pos;
@@ -363,7 +359,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
                     // don't crash on bookmarks in live streams
                     if( stream_Size( p_input->p->input.p_stream ) == 0 )
                     {
-                        vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+                        vlc_mutex_unlock( &p_input->p->p_item->lock );
                         return VLC_EGENERIC;
                     }
                     pos.f_float = !p_input->p->input.p_stream ? 0 :
@@ -377,12 +373,12 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
                     i_ret = var_Set( p_input, "position", pos );
                 }
 
-                vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+                vlc_mutex_unlock( &p_input->p->p_item->lock );
                 return i_ret;
             }
             else
             {
-                vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+                vlc_mutex_unlock( &p_input->p->p_item->lock );
                 return VLC_EGENERIC;
             }
 
@@ -398,7 +394,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
             if( asprintf( &str, "%s=%s", psz_option, psz_value ) == -1 )
                 return VLC_ENOMEM;
 
-            i = input_item_AddOpt( p_input->p->input.p_item, str,
+            i = input_item_AddOpt( p_input->p->p_item, str,
                                   VLC_INPUT_OPTION_UNIQUE );
             free( str );
             return i;
@@ -420,11 +416,11 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
         {
             int i;
             pf = (double*)va_arg( args, double * );
-            vlc_mutex_lock( &p_input->p->input.p_item->lock );
+            vlc_mutex_lock( &p_input->p->p_item->lock );
             *pf = p_input->p->input.f_fps;
             for( i = 0; i < p_input->p->i_slave && *pf <= 0.001; i++ )
                 *pf = p_input->p->slave[i]->f_fps;
-            vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+            vlc_mutex_unlock( &p_input->p->p_item->lock );
             return VLC_SUCCESS;
         }
 
@@ -443,10 +439,10 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
             int *pi_attachment = (int*)va_arg( args, int * );
             int i;
 
-            vlc_mutex_lock( &p_input->p->input.p_item->lock );
+            vlc_mutex_lock( &p_input->p->p_item->lock );
             if( p_input->p->i_attachment <= 0 )
             {
-                vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+                vlc_mutex_unlock( &p_input->p->p_item->lock );
                 *ppp_attachment = NULL;
                 *pi_attachment = 0;
                 return VLC_EGENERIC;
@@ -456,7 +452,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
             for( i = 0; i < p_input->p->i_attachment; i++ )
                 (*ppp_attachment)[i] = vlc_input_attachment_Duplicate( p_input->p->attachment[i] );
 
-            vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+            vlc_mutex_unlock( &p_input->p->p_item->lock );
             return VLC_SUCCESS;
         }
 
@@ -466,18 +462,18 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
             const char *psz_name = (const char*)va_arg( args, const char * );
             int i;
 
-            vlc_mutex_lock( &p_input->p->input.p_item->lock );
+            vlc_mutex_lock( &p_input->p->p_item->lock );
             for( i = 0; i < p_input->p->i_attachment; i++ )
             {
                 if( !strcmp( p_input->p->attachment[i]->psz_name, psz_name ) )
                 {
                     *pp_attachment = vlc_input_attachment_Duplicate( p_input->p->attachment[i] );
-                    vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+                    vlc_mutex_unlock( &p_input->p->p_item->lock );
                     return VLC_SUCCESS;
                 }
             }
             *pp_attachment = NULL;
-            vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+            vlc_mutex_unlock( &p_input->p->p_item->lock );
             return VLC_EGENERIC;
         }
 
@@ -507,7 +503,7 @@ static void UpdateBookmarksOption( input_thread_t *p_input )
     int i, i_len = 0;
     char *psz_value = NULL, *psz_next = NULL;
 
-    vlc_mutex_lock( &p_input->p->input.p_item->lock );
+    vlc_mutex_lock( &p_input->p->p_item->lock );
     if( p_input->p->i_bookmark > 0 )
     {
         for( i = 0; i < p_input->p->i_bookmark; i++ )
@@ -531,7 +527,7 @@ static void UpdateBookmarksOption( input_thread_t *p_input )
                 *psz_next = ','; psz_next++;
         }
     }
-    vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+    vlc_mutex_unlock( &p_input->p->p_item->lock );
 
     input_Control( p_input, INPUT_ADD_OPTION, "bookmarks",
                    psz_value ? psz_value : "" );
index c252da6..feed176 100644 (file)
@@ -978,10 +978,8 @@ static void EsOutProgramSelect( es_out_t *out, es_out_pgrm_t *p_pgrm )
     }
 
     /* Update now playing */
-    input_item_SetNowPlaying( p_input->p->input.p_item,
-                              p_pgrm->psz_now_playing );
-    input_item_SetPublisher( p_input->p->input.p_item,
-                             p_pgrm->psz_publisher );
+    input_item_SetNowPlaying( p_input->p->p_item, p_pgrm->psz_now_playing );
+    input_item_SetPublisher( p_input->p->p_item, p_pgrm->psz_publisher );
 
     input_SendEventMeta( p_input );
 }
@@ -1170,7 +1168,7 @@ static void EsOutProgramMeta( es_out_t *out, int i_group, vlc_meta_t *p_meta )
     {
         if( p_sys->p_pgrm == p_pgrm )
         {
-            input_item_SetPublisher( p_input->p->input.p_item, psz_provider );
+            input_item_SetPublisher( p_input->p->p_item, psz_provider );
             input_SendEventMeta( p_input );
         }
         input_Control( p_input, INPUT_ADD_INFO, psz_cat, input_MetaTypeToLocalizedString(vlc_meta_Publisher), psz_provider );
@@ -1296,7 +1294,7 @@ static void EsOutProgramEpg( es_out_t *out, int i_group, vlc_epg_t *p_epg )
 
     if( p_pgrm == p_sys->p_pgrm )
     {
-        input_item_SetNowPlaying( p_input->p->input.p_item, p_pgrm->psz_now_playing );
+        input_item_SetNowPlaying( p_input->p->p_item, p_pgrm->psz_now_playing );
         input_SendEventMeta( p_input );
     }
 
@@ -1373,9 +1371,9 @@ static es_out_id_t *EsOutAdd( es_out_t *out, const es_format_t *fmt )
         es->i_channel = p_sys->i_audio;
 
         memset( &rg, 0, sizeof(rg) );
-        vlc_mutex_lock( &p_input->p->input.p_item->lock );
-        vlc_audio_replay_gain_MergeFromMeta( &rg, p_input->p->input.p_item->p_meta );
-        vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+        vlc_mutex_lock( &p_input->p->p_item->lock );
+        vlc_audio_replay_gain_MergeFromMeta( &rg, p_input->p->p_item->p_meta );
+        vlc_mutex_unlock( &p_input->p->p_item->lock );
 
         for( i = 0; i < AUDIO_REPLAY_GAIN_MAX; i++ )
         {
index 2fe986d..47ecd2c 100644 (file)
@@ -53,7 +53,7 @@ void input_SendEventTimes( input_thread_t *p_input,
 
        /* FIXME ugly + what about meta change event ? */
     if( var_GetTime( p_input, "length" ) != i_length )
-        input_item_SetDuration( p_input->p->input.p_item, i_length );
+        input_item_SetDuration( p_input->p->p_item, i_length );
     val.i_time = i_length;
     var_Change( p_input, "length", VLC_VAR_SETVALUE, &val, NULL );
 
@@ -168,7 +168,7 @@ void input_SendEventMeta( input_thread_t *p_input )
 
        event.type = vlc_InputItemMetaChanged;
        event.u.input_item_meta_changed.meta_type = vlc_meta_ArtworkURL;
-       vlc_event_send( &p_input->p->input.p_item->event_manager, &event );
+       vlc_event_send( &p_input->p->p_item->event_manager, &event );
 }
 
 void input_SendEventMetaInfo( input_thread_t *p_input )
@@ -179,7 +179,7 @@ void input_SendEventMetaInfo( input_thread_t *p_input )
     vlc_event_t event;
 
     event.type = vlc_InputItemInfoChanged;
-    vlc_event_send( &p_input->p->input.p_item->event_manager, &event );
+    vlc_event_send( &p_input->p->p_item->event_manager, &event );
 }
 
 void input_SendEventMetaName( input_thread_t *p_input, const char *psz_name )
@@ -191,7 +191,7 @@ void input_SendEventMetaName( input_thread_t *p_input, const char *psz_name )
 
     event.type = vlc_InputItemNameChanged;
     event.u.input_item_name_changed.new_name = psz_name;
-    vlc_event_send( &p_input->p->input.p_item->event_manager, &event );
+    vlc_event_send( &p_input->p->p_item->event_manager, &event );
 }
 
 /*****************************************************************************
index a4a1dd1..5f26d97 100644 (file)
@@ -42,6 +42,7 @@
 #include "access.h"
 #include "demux.h"
 #include "stream.h"
+#include "item.h"
 
 #include <vlc_sout.h>
 #include "../stream_output/stream_output.h"
@@ -188,9 +189,10 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
     p_input->p->b_out_pace_control = false;
     p_input->i_pts_delay = 0;
 
-    /* Init Input fields */
     vlc_gc_incref( p_item ); /* Released in Destructor() */
-    p_input->p->input.p_item = p_item;
+    p_input->p->p_item = p_item;
+
+    /* Init Input fields */
     p_input->p->input.p_access = NULL;
     p_input->p->input.p_stream = NULL;
     p_input->p->input.p_demux  = NULL;
@@ -316,7 +318,7 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
 static void Destructor( input_thread_t * p_input )
 {
 #ifndef NDEBUG
-    char * psz_name = input_item_GetName( p_input->p->input.p_item );
+    char * psz_name = input_item_GetName( p_input->p->p_item );
     msg_Dbg( p_input, "Destroying the input for '%s'", psz_name);
     free( psz_name );
 #endif
@@ -329,7 +331,7 @@ static void Destructor( input_thread_t * p_input )
     if( p_input->p->p_sout )
         sout_DeleteInstance( p_input->p->p_sout );
 #endif
-    vlc_gc_decref( p_input->p->input.p_item );
+    vlc_gc_decref( p_input->p->p_item );
 
     vlc_mutex_destroy( &p_input->p->counters.counters_lock );
 
@@ -464,6 +466,18 @@ sout_instance_t *input_DetachSout( input_thread_t *p_input )
     return p_sout;
 }
 
+/**
+ * Get the item from an input thread
+ * FIXME it does not increase ref count of the item.
+ * if it is used after p_input is destroyed nothing prevent it from
+ * being freed.
+ */
+input_item_t *input_GetItem( input_thread_t *p_input )
+{
+    assert( p_input && p_input->p );
+    return p_input->p->p_item;
+}
+
 /*****************************************************************************
  * ObjectKillChildrens
  *****************************************************************************/
@@ -684,7 +698,7 @@ static void MainLoopInterface( input_thread_t *p_input )
  */
 static void MainLoopStatistic( input_thread_t *p_input )
 {
-    stats_ComputeInputStats( p_input, p_input->p->input.p_item->p_stats );
+    stats_ComputeInputStats( p_input, p_input->p->p_item->p_stats );
     /* Are we the thread responsible for computing global stats ? */
     if( libvlc_priv( p_input->p_libvlc )->p_stats_computer == p_input )
     {
@@ -831,7 +845,7 @@ static int InitSout( input_thread_t * p_input )
 
     /* Find a usable sout and attach it to p_input */
     psz = var_GetNonEmptyString( p_input, "sout" );
-    if( psz && strncasecmp( p_input->p->input.p_item->psz_uri, "vlc:", 4 ) )
+    if( psz && strncasecmp( p_input->p->p_item->psz_uri, "vlc:", 4 ) )
     {
         /* Check the validity of the provided sout */
         if( p_input->p->p_sout )
@@ -1018,7 +1032,7 @@ static void LoadSubtitles( input_thread_t *p_input )
     {
         char *psz_autopath = var_GetNonEmptyString( p_input, "sub-autodetect-path" );
         char **ppsz_subs = subtitles_Detect( p_input, psz_autopath,
-                                             p_input->p->input.p_item->psz_uri );
+                                             p_input->p->p_item->psz_uri );
         free( psz_autopath );
 
         for( int i = 0; ppsz_subs && ppsz_subs[i]; i++ )
@@ -1125,9 +1139,9 @@ static int Init( input_thread_t * p_input )
     vlc_meta_t *p_meta;
     int i, ret;
 
-    for( i = 0; i < p_input->p->input.p_item->i_options; i++ )
+    for( i = 0; i < p_input->p->p_item->i_options; i++ )
     {
-        if( !strncmp( p_input->p->input.p_item->ppsz_options[i], "meta-file", 9 ) )
+        if( !strncmp( p_input->p->p_item->ppsz_options[i], "meta-file", 9 ) )
         {
             msg_Dbg( p_input, "Input is a meta file: disabling unneeded options" );
             var_SetString( p_input, "sout", "" );
@@ -1156,7 +1170,7 @@ static int Init( input_thread_t * p_input )
     var_Create( p_input, "sample-rate", VLC_VAR_INTEGER );
 
     if( InputSourceInit( p_input, &p_input->p->input,
-                         p_input->p->input.p_item->psz_uri, NULL ) )
+                         p_input->p->p_item->psz_uri, NULL ) )
     {
         goto error;
     }
@@ -1170,7 +1184,7 @@ static int Init( input_thread_t * p_input )
                          &i_length ) )
         i_length = 0;
     if( i_length <= 0 )
-        i_length = input_item_GetDuration( p_input->p->input.p_item );
+        i_length = input_item_GetDuration( p_input->p->p_item );
     input_SendEventTimes( p_input, 0.0, 0, i_length );
 
     if( !p_input->b_preparsing )
@@ -1216,7 +1230,7 @@ static int Init( input_thread_t * p_input )
     if( !p_input->b_preparsing )
     {
         msg_Dbg( p_input, "`%s' successfully opened",
-                 p_input->p->input.p_item->psz_uri );
+                 p_input->p->p_item->psz_uri );
 
     }
 
@@ -1336,7 +1350,7 @@ static void End( input_thread_t * p_input )
             libvlc_priv_t *p_private = libvlc_priv( p_input->p_libvlc );
 
             /* make sure we are up to date */
-            stats_ComputeInputStats( p_input, p_input->p->input.p_item->p_stats );
+            stats_ComputeInputStats( p_input, p_input->p->p_item->p_stats );
             if( p_private->p_stats_computer == p_input )
             {
                 stats_ComputeGlobalStats( p_input->p_libvlc,
@@ -2559,17 +2573,17 @@ static int InputSourceInit( input_thread_t *p_input,
         if( !demux_Control( in->p_demux, DEMUX_GET_ATTACHMENTS,
                              &attachment, &i_attachment ) )
         {
-            vlc_mutex_lock( &p_input->p->input.p_item->lock );
+            vlc_mutex_lock( &p_input->p->p_item->lock );
             AppendAttachment( &p_input->p->i_attachment, &p_input->p->attachment,
                               i_attachment, attachment );
-            vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+            vlc_mutex_unlock( &p_input->p->p_item->lock );
         }
     }
     if( !demux_Control( in->p_demux, DEMUX_GET_FPS, &f_fps ) )
     {
-        vlc_mutex_lock( &p_input->p->input.p_item->lock );
+        vlc_mutex_lock( &p_input->p->p_item->lock );
         in->f_fps = f_fps;
-        vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+        vlc_mutex_unlock( &p_input->p->p_item->lock );
     }
 
     if( var_GetInteger( p_input, "clock-synchro" ) != -1 )
@@ -2658,10 +2672,10 @@ static void InputSourceMeta( input_thread_t *p_input,
 
         if( p_demux_meta->i_attachments > 0 )
         {
-            vlc_mutex_lock( &p_input->p->input.p_item->lock );
+            vlc_mutex_lock( &p_input->p->p_item->lock );
             AppendAttachment( &p_input->p->i_attachment, &p_input->p->attachment,
                               p_demux_meta->i_attachments, p_demux_meta->attachments );
-            vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+            vlc_mutex_unlock( &p_input->p->p_item->lock );
         }
         module_unneed( p_demux, p_id3 );
     }
@@ -2780,7 +2794,7 @@ static void InputMetaUser( input_thread_t *p_input, vlc_meta_t *p_meta )
  *****************************************************************************/
 static void InputUpdateMeta( input_thread_t *p_input, vlc_meta_t *p_meta )
 {
-    input_item_t *p_item = p_input->p->input.p_item;
+    input_item_t *p_item = p_input->p->p_item;
 
     char *psz_title = NULL;
     char *psz_arturl = input_item_GetArtURL( p_item );
@@ -2910,7 +2924,7 @@ static void input_ChangeState( input_thread_t *p_input, int i_state )
 
     if( b_changed )
     {
-        input_item_SetErrorWhenReading( p_input->p->input.p_item, p_input->b_error );
+        input_item_SetErrorWhenReading( p_input->p->p_item, p_input->b_error );
         input_SendEventState( p_input, i_state );
     }
 }
index 7165bd9..66a38e0 100644 (file)
@@ -43,9 +43,6 @@
 /* input_source_t: gathers all information per input source */
 typedef struct
 {
-    /* Input item description */
-    input_item_t *p_item;
-
     /* Access/Stream/Demux plugins */
     access_t *p_access;
     stream_t *p_stream;
@@ -118,6 +115,8 @@ struct input_thread_private_t
     bool            b_out_pace_control; /*     idem ? */
 
     /* Main input properties */
+    input_item_t *p_item;
+
     input_source_t input;
     /* Slave demuxers (subs, and others) */
     int            i_slave;
@@ -212,8 +211,6 @@ void input_ControlPush( input_thread_t *, int i_type, vlc_value_t * );
  *  Becarefull; p_item lock HAS to be taken */
 void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input );
 
-void input_item_SetErrorWhenReading( input_item_t *p_i, bool b_error );
-
 /***************************************************************************
  * Internal prototypes
  ***************************************************************************/
index 655ad59..7d8d3bc 100644 (file)
@@ -30,7 +30,7 @@
 #include "vlc_playlist.h"
 #include "vlc_interface.h"
 
-#include "input_internal.h"
+#include "item.h"
 
 static void GuessType( input_item_t *p_item );
 
@@ -211,18 +211,6 @@ void input_item_SetMeta( input_item_t *p_i, vlc_meta_type_t meta_type, const cha
     vlc_event_send( &p_i->event_manager, &event );
 }
 
-/**
- * Get the item from an input thread
- * FIXME it does not increase ref count of the item.
- * if it is used after p_input is destroyed nothing prevent it from
- * being freed.
- */
-input_item_t *input_GetItem( input_thread_t *p_input )
-{
-    assert( p_input && p_input->p );
-    return p_input->p->input.p_item;
-}
-
 /* FIXME GRRRRRRRRRR args should be in the reverse order to be 
  * consistant with (nearly?) all or copy funcs */
 void input_item_CopyOptions( input_item_t *p_parent,
diff --git a/src/input/item.h b/src/input/item.h
new file mode 100644 (file)
index 0000000..971620a
--- /dev/null
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * item.h
+ *****************************************************************************
+ * Copyright (C) 2008 Laurent Aimar
+ * $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_ITEM_H
+#define _INPUT_ITEM_H 1
+
+#include "input_interface.h"
+
+void input_item_SetErrorWhenReading( input_item_t *p_i, bool b_error );
+
+#endif
index c8d0137..2123f99 100644 (file)
@@ -447,7 +447,7 @@ int input_DownloadAndCacheArt( playlist_t *p_playlist, input_item_t *p_item )
 
 void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input )
 {
-    input_item_t *p_item = p_input->p->input.p_item;
+    input_item_t *p_item = p_input->p->p_item;
     const char *psz_arturl;
     const char *psz_artist = NULL;
     const char *psz_album = NULL;