demux_t *p_demux = (demux_t *)vlclua_get_this( L );
int n = luaL_checkint( L, 1 );
const uint8_t *p_peek;
+
int i_peek = stream_Peek( p_demux->s, &p_peek, n );
- lua_pushlstring( L, (const char *)p_peek, i_peek );
+ if( i_peek > 0 )
+ lua_pushlstring( L, (const char *)p_peek, i_peek );
+ else
+ lua_pushnil( L );
return 1;
}
const uint8_t *p_read;
int n = luaL_checkint( L, 1 );
int i_read = stream_Peek( p_demux->s, &p_read, n );
- lua_pushlstring( L, (const char *)p_read, i_read );
- int i_seek = stream_Read( p_demux->s, NULL, i_read );
- assert(i_read==i_seek);
+
+ if( i_read > 0 )
+ {
+ lua_pushlstring( L, (const char *)p_read, i_read );
+ int i_seek = stream_Read( p_demux->s, NULL, i_read );
+ assert( i_read == i_seek );
+ }
+ else
+ lua_pushnil( L );
+
return 1;
}
luaopen_msg( L );
luaopen_strings( L );
luaopen_stream( L );
+ luaopen_variables( L );
luaopen_xml( L );
- luaopen_md5( L );
lua_pushstring( L, p_demux->psz_location );
lua_setfield( L, -2, "path" );
lua_pushstring( L, p_demux->psz_access );
lua_pop( L, 1 );
/* Setup the module search path */
- if( vlclua_add_modules_path( p_demux, L, psz_filename ) )
+ if( vlclua_add_modules_path( L, psz_filename ) )
{
msg_Warn( p_demux, "Error while setting the module search path for %s",
psz_filename );
input_thread_t *p_input_thread = demux_GetParentInput( p_demux );
input_item_t *p_current_input = input_GetItem( p_input_thread );
- playlist_t *p_playlist = pl_Get( p_demux );
luaL_register( L, "vlc", p_reg_parse );
}
if( lua_gettop( L ) )
- vlclua_playlist_add_internal( p_demux, L, p_playlist,
- p_current_input, 0 );
+ vlclua_playlist_add_internal( p_demux, L, NULL, p_current_input, 0 );
else
msg_Err( p_demux, "Script went completely foobar" );