]> git.sesse.net Git - vlc/blobdiff - src/input/control.c
* mkv.cpp: should fix the compilation error with gcc
[vlc] / src / input / control.c
index faade0bd2a5a59e8894efcad713741e985461313..3170f3cc64df53dfdc1d8041467dd8cc81c207ff 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * control.c
  *****************************************************************************
- * Copyright (C) 1999-2004 VideoLAN
+ * Copyright (C) 1999-2004 the VideoLAN team
  * $Id$
  *
  * Authors: Gildas Bazin <gbazin@videolan.org>
@@ -129,6 +129,8 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
 
         case INPUT_ADD_INFO:
         {
+            /* FIXME : Impossible to use vlc_input_item_AddInfo because of
+             * the ... problem ? */
             char *psz_cat = (char *)va_arg( args, char * );
             char *psz_name = (char *)va_arg( args, char * );
             char *psz_format = (char *)va_arg( args, char * );
@@ -195,41 +197,62 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
         }
         return VLC_SUCCESS;
 
-        case INPUT_GET_INFO:
+        case INPUT_DEL_INFO:
         {
             char *psz_cat = (char *)va_arg( args, char * );
             char *psz_name = (char *)va_arg( args, char * );
-            char **ppsz_value = (char **)va_arg( args, char ** );
-            int i_ret = VLC_EGENERIC;
+
+            info_category_t *p_cat = NULL;
             int i;
-            *ppsz_value = NULL;
 
             vlc_mutex_lock( &p_input->input.p_item->lock );
             for( i = 0; i < p_input->input.p_item->i_categories; i++ )
             {
                 if( !strcmp( p_input->input.p_item->pp_categories[i]->psz_name,
-                             psz_cat ) ) break;
+                             psz_cat ) )
+                {
+                    p_cat = p_input->input.p_item->pp_categories[i];
+                    break;
+                }
             }
-
-            if( i != p_input->input.p_item->i_categories )
+            if( p_cat == NULL )
             {
-                info_category_t *p_cat;
-                p_cat = p_input->input.p_item->pp_categories[i];
+                vlc_mutex_unlock( &p_input->input.p_item->lock );
+                return VLC_EGENERIC;
+            }
 
-                for( i = 0; i < p_cat->i_infos; i++ )
+            for( i = 0; i < p_cat->i_infos; i++ )
+            {
+                if( !strcmp( p_cat->pp_infos[i]->psz_name, psz_name ) )
                 {
-                    if( !strcmp( p_cat->pp_infos[i]->psz_name, psz_name ) )
-                    {
-                        if( p_cat->pp_infos[i]->psz_value )
-                        {
-                            *ppsz_value =strdup(p_cat->pp_infos[i]->psz_value);
-                            i_ret = VLC_SUCCESS;
-                        }
-                        break;
-                    }
+                    free( p_cat->pp_infos[i]->psz_name );
+                    if( p_cat->pp_infos[i]->psz_value )
+                        free( p_cat->pp_infos[i]->psz_value );
+                    free( p_cat->pp_infos[i] );
+                    REMOVE_ELEM( p_cat->pp_infos, p_cat->i_infos, i );
+                    break;
                 }
             }
             vlc_mutex_unlock( &p_input->input.p_item->lock );
+
+            if( i >= p_cat->i_infos )
+                return VLC_EGENERIC;
+
+            NotifyPlaylist( p_input );
+        }
+        return VLC_SUCCESS;
+
+
+        case INPUT_GET_INFO:
+        {
+            char *psz_cat = (char *)va_arg( args, char * );
+            char *psz_name = (char *)va_arg( args, char * );
+            char **ppsz_value = (char **)va_arg( args, char ** );
+            int i_ret = VLC_EGENERIC;
+            *ppsz_value = NULL;
+
+            *ppsz_value = vlc_input_item_GetInfo( p_input->input.p_item,
+                                                  psz_cat, psz_name );
             return i_ret;
         }
 
@@ -406,13 +429,19 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
                 vlc_value_t pos;
                 int i_ret;
 
-                if( p_input->bookmark[i_bkmk]->i_time_offset )
+                if( p_input->bookmark[i_bkmk]->i_time_offset != -1 )
                 {
                     pos.i_time = p_input->bookmark[i_bkmk]->i_time_offset;
                     i_ret = var_Set( p_input, "time", pos );
                 }
-                else if( p_input->bookmark[i_bkmk]->i_byte_offset )
+                else if( p_input->bookmark[i_bkmk]->i_byte_offset != -1 )
                 {
+                    // don't crash on bookmarks in live streams
+                    if( stream_Size( p_input->input.p_stream ) == 0 )
+                    {
+                        vlc_mutex_unlock( &p_input->input.p_item->lock );
+                        return VLC_EGENERIC;
+                    }
                     pos.f_float = !p_input->input.p_stream ? 0 :
                         p_input->bookmark[i_bkmk]->i_byte_offset /
                         stream_Size( p_input->input.p_stream );
@@ -442,7 +471,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
             int i;
 
             vlc_mutex_lock( &p_input->input.p_item->lock );
-            /* Check if option already exists */            
+            /* Check if option already exists */
             for( i = 0; i < p_input->input.p_item->i_options; i++ )
             {
                 if( !strncmp( p_input->input.p_item->ppsz_options[i],