Commit 133d57fe authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Don't write R/O memory + clean up

parent fbf4c806
...@@ -28,59 +28,62 @@ static void RunSD( services_discovery_t *p_sd ); ...@@ -28,59 +28,62 @@ static void RunSD( services_discovery_t *p_sd );
int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, const char *psz_modules ) int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, const char *psz_modules )
{ {
if( psz_modules && *psz_modules ) const char *psz_parser = psz_modules ?: "";
{ int retval = VLC_SUCCESS;
const char *psz_parser = psz_modules;
char *psz_next;
while( psz_parser && *psz_parser ) for (;;)
{ {
while( *psz_parser == ' ' || *psz_parser == ':' || *psz_parser == ',' ) while( *psz_parser == ' ' || *psz_parser == ':' || *psz_parser == ',' )
psz_parser++; psz_parser++;
if( (psz_next = strchr( psz_parser, ':' ) ) )
*psz_next++ = '\0';
if( *psz_parser == '\0' ) if( *psz_parser == '\0' )
break; break;
msg_Dbg( p_playlist, "Add services_discovery %s", psz_parser );
const char *psz_next = strchr( psz_parser, ':' );
if( psz_next == NULL )
psz_next = psz_parser + strlen( psz_parser );
char psz_plugin[psz_next - psz_parser + 1];
memcpy (psz_plugin, psz_parser, sizeof (psz_plugin) - 1);
psz_plugin[sizeof (psz_plugin) - 1] = '\0';
psz_parser = psz_next;
/* Perform the addition */ /* Perform the addition */
{ msg_Dbg( p_playlist, "Add services_discovery %s", psz_plugin );
services_discovery_t *p_sd = vlc_object_create( p_playlist, services_discovery_t *p_sd = vlc_object_create( p_playlist,
VLC_OBJECT_SD ); VLC_OBJECT_SD );
if( p_sd == NULL )
return VLC_ENOMEM;
p_sd->pf_run = NULL; p_sd->pf_run = NULL;
p_sd->p_module = module_Need( p_sd, "services_discovery", psz_parser, 0 ); p_sd->p_module = module_Need( p_sd, "services_discovery", psz_plugin, 0 );
if( p_sd->p_module == NULL ) if( p_sd->p_module == NULL )
{ {
msg_Err( p_playlist, "no suitable services discovery module" ); msg_Err( p_playlist, "no suitable services discovery module" );
vlc_object_destroy( p_sd ); vlc_object_destroy( p_sd );
return VLC_EGENERIC; retval = VLC_EGENERIC;
continue;
} }
p_sd->psz_module = strdup( psz_parser ); p_sd->psz_module = strdup( psz_plugin );
p_sd->b_die = VLC_FALSE; p_sd->b_die = VLC_FALSE;
PL_LOCK; PL_LOCK;
TAB_APPEND( p_playlist->i_sds, p_playlist->pp_sds, p_sd ); TAB_APPEND( p_playlist->i_sds, p_playlist->pp_sds, p_sd );
PL_UNLOCK; PL_UNLOCK;
if( !p_sd->pf_run ) { if ((p_sd->pf_run != NULL)
psz_parser = psz_next; && vlc_thread_create( p_sd, "services_discovery", RunSD,
continue; VLC_THREAD_PRIORITY_LOW, VLC_FALSE))
}
if( vlc_thread_create( p_sd, "services_discovery", RunSD,
VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
{ {
msg_Err( p_sd, "cannot create services discovery thread" ); msg_Err( p_sd, "cannot create services discovery thread" );
vlc_object_destroy( p_sd ); vlc_object_destroy( p_sd );
return VLC_EGENERIC; retval = VLC_EGENERIC;
} continue;
}
psz_parser = psz_next;
} }
} }
return VLC_SUCCESS;
return retval;
} }
int playlist_ServicesDiscoveryRemove( playlist_t * p_playlist, int playlist_ServicesDiscoveryRemove( playlist_t * p_playlist,
......
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