[vlc-commits] luasd: set description field by directly calling script descriptor

Pierre Ynard git at videolan.org
Wed Nov 16 08:57:02 CET 2016


vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Wed Nov 16 08:37:43 2016 +0100| [0f82c2b597d0103510ac3d4facc8cfb335d181b4] | committer: Pierre Ynard

luasd: set description field by directly calling script descriptor

Instead of expecting the longname to be passed in the config chain and
parsing it from there

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

 modules/lua/services_discovery.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/modules/lua/services_discovery.c b/modules/lua/services_discovery.c
index 51d9d9f..14b6c18 100644
--- a/modules/lua/services_discovery.c
+++ b/modules/lua/services_discovery.c
@@ -74,6 +74,7 @@ const char *vlclua_sd_description( vlc_object_t *obj, lua_State *L,
 
     return lua_tostring( L, -1 );
 }
+#define vlclua_sd_description(a, b, c) vlclua_sd_description(VLC_OBJECT(a), b, c)
 
 static const char * const ppsz_sd_options[] = { "sd", "longname", NULL };
 
@@ -118,15 +119,6 @@ int Open_LuaSD( vlc_object_t *p_this )
         psz_name = strdup(p_sd->psz_name);
     }
 
-    p_sd->description = p_sd->psz_name;
-
-    for( const config_chain_t *cc = p_sd->p_cfg; cc != NULL; cc = cc->p_next )
-        if( strcmp( cc->psz_name, "longname" ) == 0 )
-        {
-            p_sd->description = cc->psz_value;
-            break;
-        }
-
     if( !( p_sys = malloc( sizeof( services_discovery_sys_t ) ) ) )
     {
         free( psz_name );
@@ -176,6 +168,12 @@ int Open_LuaSD( vlc_object_t *p_this )
         lua_pop( L, 1 );
         goto error;
     }
+
+    // No strdup(), just don't remove the string from the lua stack
+    p_sd->description = vlclua_sd_description( p_sd, L, p_sys->psz_filename );
+    if( p_sd->description == NULL )
+        p_sd->description = p_sd->psz_name;
+
     p_sys->L = L;
     vlc_mutex_init( &p_sys->lock );
     vlc_cond_init( &p_sys->cond );



More information about the vlc-commits mailing list