[vlc-devel] commit: Hopefully fix #1910 'When I use the command " mrl playlist_add vlc_play", "playlist_add" used to return the index of the item added to the playlist wheras in the last nightly build , "playlist_add" just add 0 to the stack. Thus, "vlc_play" just play the first element of the playlist in spite of playing the desired file .' ... and fix an unrelated compilation warning which ended up being a bit more complex to fix than I though . (Antoine Cellerier )

git version control git at videolan.org
Sun Aug 24 22:30:56 CEST 2008


vlc | branch: master | Antoine Cellerier <dionoea at videolan.org> | Sun Aug 24 22:34:10 2008 +0200| [08f5b0d05dc0f522c548652ef04bd12a4438cbc9] | committer: Antoine Cellerier 

Hopefully fix #1910 'When I use the command "mrl playlist_add vlc_play", "playlist_add" used to return the index of the item added to the playlist wheras in the last nightly build, "playlist_add" just add 0 to the stack. Thus, "vlc_play" just play the first element of the playlist in spite of playing the desired file.' ... and fix an unrelated compilation warning which ended up being a bit more complex to fix than I though.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=08f5b0d05dc0f522c548652ef04bd12a4438cbc9
---

 modules/control/http/http.h  |    6 +++---
 modules/control/http/macro.c |    9 ++++++---
 modules/control/http/mvar.c  |    2 +-
 modules/control/http/rpn.c   |   17 ++++++++++++-----
 modules/control/http/util.c  |   14 +++++++-------
 5 files changed, 29 insertions(+), 19 deletions(-)

diff --git a/modules/control/http/http.h b/modules/control/http/http.h
index 68c8187..7bd9c02 100644
--- a/modules/control/http/http.h
+++ b/modules/control/http/http.h
@@ -118,10 +118,10 @@ void HandleSeek( intf_thread_t *p_intf, char *p_value );
 
 /** This function extracts the value for a given argument name
  * from an HTTP request */
-char *ExtractURIValue( char *restrict psz_uri,
+const char *ExtractURIValue( const char *restrict psz_uri,
                            const char *restrict psz_name,
                            char *restrict psz_value, size_t i_value_max );
-char *ExtractURIString( char *restrict psz_uri,
+char *ExtractURIString( const char *restrict psz_uri,
                             const char *restrict psz_name );
 /** \todo Describe this function */
 int TestURIParam( char *psz_uri, const char *psz_name );
@@ -177,7 +177,7 @@ void     mvar_RemoveVar( mvar_t *v, mvar_t *f );
 /** This function retrieves the child variable named "name" */
 mvar_t  *mvar_GetVar( mvar_t *s, const char *name );
 /** This function retrieves the value of the child variable named "field" */
-char    *mvar_GetValue( mvar_t *v, char *field );
+const char *mvar_GetValue( mvar_t *v, const char *field );
 /** This function creates a variable with the given name and value and
  * adds it as first child of vars */
 void     mvar_PushNewVar( mvar_t *vars, const char *name,
diff --git a/modules/control/http/macro.c b/modules/control/http/macro.c
index 7dde365..2b6aff0 100644
--- a/modules/control/http/macro.c
+++ b/modules/control/http/macro.c
@@ -362,7 +362,8 @@ static void MacroDo( httpd_file_sys_t *p_args,
                 case MVLC_DEL:
                 {
                     int i_item, *p_items = NULL, i_nb_items = 0;
-                    char item[512], *p_parser = p_request;
+                    char item[512];
+                    const char *p_parser = p_request;
 
                     /* Get the list of items to delete */
                     while( (p_parser =
@@ -396,7 +397,8 @@ static void MacroDo( httpd_file_sys_t *p_args,
                 case MVLC_KEEP:
                 {
                     int i_item, *p_items = NULL, i_nb_items = 0;
-                    char item[512], *p_parser = p_request;
+                    char item[512];
+                    const char *p_parser = p_request;
                     int i,j;
 
                     /* Get the list of items to keep */
@@ -769,7 +771,8 @@ static void MacroDo( httpd_file_sys_t *p_args,
         }
         case MVLC_VALUE:
         {
-            char *s, *v;
+            char *s;
+            const char *v;
 
             if( m->param1 )
             {
diff --git a/modules/control/http/mvar.c b/modules/control/http/mvar.c
index e5252ff..d2957b2 100644
--- a/modules/control/http/mvar.c
+++ b/modules/control/http/mvar.c
@@ -182,7 +182,7 @@ mvar_t *mvar_GetVar( mvar_t *s, const char *name )
     return NULL;
 }
 
-char *mvar_GetValue( mvar_t *v, char *field )
+const char *mvar_GetValue( mvar_t *v, const char *field )
 {
     if( *field == '\0' )
     {
diff --git a/modules/control/http/rpn.c b/modules/control/http/rpn.c
index 712b145..75c62d1 100644
--- a/modules/control/http/rpn.c
+++ b/modules/control/http/rpn.c
@@ -100,7 +100,6 @@ char *SSPop( rpn_stack_t *st )
 int SSPopN( rpn_stack_t *st, mvar_t  *vars )
 {
     char *name;
-    char *value;
 
     char *end;
     int  i;
@@ -109,7 +108,7 @@ int SSPopN( rpn_stack_t *st, mvar_t  *vars )
     i = strtol( name, &end, 0 );
     if( end == name )
     {
-        value = mvar_GetValue( vars, name );
+        const char *value = mvar_GetValue( vars, name );
         i = atoi( value );
     }
     free( name );
@@ -348,7 +347,7 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t  *vars,
         }
         else if( !strcmp( s, "url_extract" ) )
         {
-            char *url = mvar_GetValue( vars, "url_value" );
+            const char *url = mvar_GetValue( vars, "url_value" );
             char *name = SSPop( st );
             char *value = ExtractURIString( url, name );
             if( value != NULL )
@@ -483,7 +482,7 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t  *vars,
         else if( !strcmp( s, "value" ) )
         {
             char *name  = SSPop( st );
-            char *value = mvar_GetValue( vars, name );
+            const char *value = mvar_GetValue( vars, name );
 
             SSPush( st, value );
 
@@ -855,11 +854,19 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t  *vars,
                 i_ret = playlist_AddInput( p_sys->p_playlist, p_input,
                                    PLAYLIST_APPEND, PLAYLIST_END, true,
                                    pl_Unlocked );
-                vlc_gc_decref( p_input );
                 if( i_ret == VLC_SUCCESS )
+                {
+                    playlist_item_t *p_item;
                     msg_Dbg( p_intf, "requested mrl add: %s", mrl );
+                    p_item = playlist_ItemGetByInput( p_sys->p_playlist,
+                                                      p_input,
+                                                      pl_Unlocked );
+                    if( p_item )
+                        i_ret = p_item->i_id;
+                }
                 else
                     msg_Warn( p_intf, "adding mrl %s failed", mrl );
+                vlc_gc_decref( p_input );
             }
             free( psz_uri );
             SSPushN( st, i_ret );
diff --git a/modules/control/http/util.c b/modules/control/http/util.c
index 54ba5c4..8abfb35 100644
--- a/modules/control/http/util.c
+++ b/modules/control/http/util.c
@@ -650,10 +650,10 @@ int TestURIParam( char *psz_uri, const char *psz_name )
     return false;
 }
 
-static char *FindURIValue( char *psz_uri, const char *restrict psz_name,
+static const char *FindURIValue( const char *psz_uri, const char *restrict psz_name,
                            size_t *restrict p_len )
 {
-    char *p = psz_uri, *end;
+    const char *p = psz_uri, *end;
     size_t len;
 
     while( (p = strstr( p, psz_name )) )
@@ -695,13 +695,13 @@ static char *FindURIValue( char *psz_uri, const char *restrict psz_name,
     return p;
 }
 
-char *ExtractURIValue( char *restrict psz_uri,
+const char *ExtractURIValue( const char *restrict psz_uri,
                            const char *restrict psz_name,
                            char *restrict psz_buf, size_t bufsize )
 {
     size_t len;
-    char *psz_value = FindURIValue( psz_uri, psz_name, &len );
-    char *psz_next;
+    const char *psz_value = FindURIValue( psz_uri, psz_name, &len );
+    const char *psz_next;
 
     if( psz_value == NULL )
     {
@@ -723,11 +723,11 @@ char *ExtractURIValue( char *restrict psz_uri,
     return psz_next;
 }
 
-char *ExtractURIString( char *restrict psz_uri,
+char *ExtractURIString( const char *restrict psz_uri,
                             const char *restrict psz_name )
 {
     size_t len;
-    char *psz_value = FindURIValue( psz_uri, psz_name, &len );
+    const char *psz_value = FindURIValue( psz_uri, psz_name, &len );
 
     if( psz_value == NULL )
         return NULL;




More information about the vlc-devel mailing list