Commit b4f2f488 authored by zorglub's avatar zorglub
Browse files

Services discovery are not forced to have a run function

parent 360b392d
......@@ -224,7 +224,6 @@ struct services_discovery_sys_t
/* playlist node */
playlist_item_t *p_node_cat;
playlist_item_t *p_node_one;
playlist_t *p_playlist;
/* Table of announces */
int i_announces;
......@@ -304,16 +303,9 @@ static int Open( vlc_object_t *p_this )
? VLC_TRUE : VLC_FALSE;
/* Create our playlist node */
p_sys->p_playlist = (playlist_t *)vlc_object_find( p_sd,
VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( !p_sys->p_playlist )
{
msg_Warn( p_sd, "unable to find playlist, cancelling SAP listening");
return VLC_EGENERIC;
}
pl_Yield( p_sd );
playlist_NodesPairCreate( p_sys->p_playlist, _("SAP sessions"),
playlist_NodesPairCreate( pl_Get( p_sd ), _("SAP sessions"),
&p_sys->p_node_cat, &p_sys->p_node_one,
VLC_TRUE );
......@@ -448,15 +440,11 @@ static void Close( vlc_object_t *p_this )
}
FREENULL( p_sys->pp_announces );
if( p_sys->p_playlist )
{
playlist_NodeDelete( p_sys->p_playlist, p_sys->p_node_cat, VLC_TRUE,
VLC_TRUE );
playlist_NodeDelete( p_sys->p_playlist, p_sys->p_node_one, VLC_TRUE,
VLC_TRUE );
vlc_object_release( p_sys->p_playlist );
}
playlist_NodeDelete( pl_Get(p_sd), p_sys->p_node_cat, VLC_TRUE,
VLC_TRUE );
playlist_NodeDelete( pl_Get(p_sd), p_sys->p_node_one, VLC_TRUE,
VLC_TRUE );
pl_Release( p_sd );
free( p_sys );
}
......@@ -568,20 +556,13 @@ static void Run( services_discovery_t *p_sd )
static int Demux( demux_t *p_demux )
{
sdp_t *p_sdp = p_demux->p_sys->p_sdp;
playlist_t *p_playlist;
input_thread_t *p_input;
input_item_t *p_parent_input;
p_playlist = (playlist_t *)vlc_object_find( p_demux, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( !p_playlist )
{
msg_Err( p_demux, "playlist could not be found" );
return VLC_EGENERIC;
}
playlist_t *p_playlist = pl_Yield( p_demux );
p_input = (input_thread_t *)vlc_object_find( p_demux, VLC_OBJECT_INPUT,
FIND_PARENT );
FIND_PARENT );
assert( p_input );
if( !p_input )
{
msg_Err( p_demux, "parent input could not be found" );
......@@ -862,7 +843,7 @@ sap_announce_t *CreateAnnounce( services_discovery_t *p_sd, uint16_t i_hash,
if( p_child == NULL )
{
p_child = playlist_NodeCreate( p_sys->p_playlist, psz_value,
p_child = playlist_NodeCreate( pl_Get( p_sd ), psz_value,
p_sys->p_node_cat );
p_child->i_flags &= ~PLAYLIST_SKIP_FLAG;
}
......@@ -872,13 +853,13 @@ sap_announce_t *CreateAnnounce( services_discovery_t *p_sd, uint16_t i_hash,
p_child = p_sys->p_node_cat;
}
p_item = playlist_NodeAddInput( p_sys->p_playlist, p_input, p_child,
p_item = playlist_NodeAddInput( pl_Get( p_sd ), p_input, p_child,
PLAYLIST_APPEND, PLAYLIST_END );
p_item->i_flags &= ~PLAYLIST_SKIP_FLAG;
p_item->i_flags &= ~PLAYLIST_SAVE_FLAG;
p_sap->i_item_id_cat = p_item->i_id;
p_item = playlist_NodeAddInput( p_sys->p_playlist, p_input,
p_item = playlist_NodeAddInput( pl_Get( p_sd ), p_input,
p_sys->p_node_one, PLAYLIST_APPEND, PLAYLIST_END );
p_item->i_flags &= ~PLAYLIST_SKIP_FLAG;
p_item->i_flags &= ~PLAYLIST_SAVE_FLAG;
......@@ -1379,10 +1360,7 @@ static int RemoveAnnounce( services_discovery_t *p_sd,
}
if( p_announce->i_input_id > -1 )
{
playlist_LockDeleteAllFromInput(
p_sd->p_sys->p_playlist, p_announce->i_input_id );
}
playlist_LockDeleteAllFromInput( pl_Get(p_sd), p_announce->i_input_id );
for( i = 0; i< p_sd->p_sys->i_announces; i++)
{
......
......@@ -121,25 +121,12 @@ static int OpenTV( vlc_object_t *p_this )
static int Open( vlc_object_t *p_this, int i_type )
{
services_discovery_t *p_sd = ( services_discovery_t* )p_this;
services_discovery_sys_t *p_sys = malloc(
sizeof( services_discovery_sys_t ) );
vlc_value_t val;
playlist_t *p_playlist;
playlist_view_t *p_view;
p_sd->pf_run = Run;
playlist_t *p_playlist = pl_Yield( p_this );
DECMALLOC_ERR( p_sys, services_discovery_sys_t );
p_sd->p_sys = p_sys;
/* Create our playlist node */
p_playlist = (playlist_t *)vlc_object_find( p_sd, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( !p_playlist )
{
msg_Warn( p_sd, "unable to find playlist, cancelling");
return VLC_EGENERIC;
}
switch( i_type )
{
case TV:
......@@ -168,11 +155,11 @@ static int Open( vlc_object_t *p_this, int i_type )
p_sys->p_node_one->i_flags |= PLAYLIST_SKIP_FLAG;
p_sys->p_node_one->p_input->i_id = p_sys->p_node_cat->p_input->i_id;
val.b_bool = VLC_TRUE;
var_Set( p_playlist, "intf-change", val );
var_SetVoid( p_playlist, "intf-change" );
vlc_object_release( p_playlist );
pl_Release( p_this );
input_Read( p_sd, p_sys->p_input, VLC_FALSE );
return VLC_SUCCESS;
}
......@@ -183,26 +170,9 @@ static void Close( vlc_object_t *p_this )
{
services_discovery_t *p_sd = ( services_discovery_t* )p_this;
services_discovery_sys_t *p_sys = p_sd->p_sys;
playlist_t *p_playlist = (playlist_t *) vlc_object_find( p_sd,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( p_playlist )
{
playlist_NodeDelete( p_playlist, p_sys->p_node_cat, VLC_TRUE, VLC_TRUE );
playlist_NodeDelete( p_playlist, p_sys->p_node_one, VLC_TRUE, VLC_TRUE );
vlc_object_release( p_playlist );
}
playlist_t *p_playlist = pl_Yield( p_sd );
playlist_NodeDelete( p_playlist, p_sys->p_node_cat, VLC_TRUE, VLC_TRUE );
playlist_NodeDelete( p_playlist, p_sys->p_node_one, VLC_TRUE, VLC_TRUE );
pl_Release( p_sd );
free( p_sys );
}
/*****************************************************************************
* Run: main thread
*****************************************************************************/
static void Run( services_discovery_t *p_sd )
{
services_discovery_sys_t *p_sys = p_sd->p_sys;
int i_id = input_Read( p_sd, p_sys->p_input, VLC_FALSE );
while( !p_sd->b_die )
{
msleep( 10*INTF_IDLE_SLEEP );
}
}
......@@ -62,6 +62,8 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist,
vlc_mutex_unlock( &p_playlist->object_lock );
if( !p_sd->pf_run ) return VLC_SUCCESS;
if( vlc_thread_create( p_sd, "services_discovery", RunSD,
VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
{
......@@ -79,8 +81,8 @@ int playlist_ServicesDiscoveryRemove( playlist_t * p_playlist,
{
int i;
services_discovery_t *p_sd = NULL;
vlc_mutex_lock( &p_playlist->object_lock );
PL_LOCK;
for( i = 0 ; i< p_playlist->i_sds ; i ++ )
{
if( !strcmp( psz_module, p_playlist->pp_sds[i]->psz_module ) )
......@@ -93,22 +95,22 @@ int playlist_ServicesDiscoveryRemove( playlist_t * p_playlist,
if( p_sd )
{
vlc_mutex_unlock( &p_playlist->object_lock );
PL_UNLOCK;
p_sd->b_die = VLC_TRUE;
vlc_thread_join( p_sd );
if( p_sd->pf_run ) vlc_thread_join( p_sd );
free( p_sd->psz_module );
module_Unneed( p_sd, p_sd->p_module );
vlc_mutex_lock( &p_playlist->object_lock );
PL_LOCK;
vlc_object_destroy( p_sd );
}
else
{
msg_Warn( p_playlist, "module %s is not loaded", psz_module );
vlc_mutex_unlock( &p_playlist->object_lock );
PL_UNLOCK;
return VLC_EGENERIC;
}
vlc_mutex_unlock( &p_playlist->object_lock );
PL_UNLOCK;
return VLC_SUCCESS;
}
......@@ -116,17 +118,17 @@ vlc_bool_t playlist_IsServicesDiscoveryLoaded( playlist_t * p_playlist,
const char *psz_module )
{
int i;
vlc_mutex_lock( &p_playlist->object_lock );
PL_LOCK;
for( i = 0 ; i< p_playlist->i_sds ; i ++ )
{
if( !strcmp( psz_module, p_playlist->pp_sds[i]->psz_module ) )
{
vlc_mutex_unlock( &p_playlist->object_lock );
PL_UNLOCK;
return VLC_TRUE;
}
}
vlc_mutex_unlock( &p_playlist->object_lock );
PL_UNLOCK;
return VLC_FALSE;
}
......@@ -148,14 +150,11 @@ int playlist_AddSDModules( playlist_t *p_playlist, char *psz_modules )
while( psz_parser && *psz_parser )
{
while( *psz_parser == ' ' || *psz_parser == ':' )
{
psz_parser++;
}
if( (psz_next = strchr( psz_parser, ':' ) ) )
{
*psz_next++ = '\0';
}
if( *psz_parser == '\0' )
{
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment