}
}
vlm_SendEventMediaInstanceState( p_vlm, p_media->cfg.id, p_media->cfg.psz_name, psz_instance_name, var_GetInteger( p_input, "state" ) );
+
+ vlc_cond_signal( &p_vlm->wait_manage );
}
return VLC_SUCCESS;
}
}
vlc_mutex_init( &p_vlm->lock );
+ vlc_mutex_init( &p_vlm->lock_manage );
+ vlc_cond_init( &p_vlm->wait_manage );
p_vlm->i_id = 1;
TAB_INIT( p_vlm->i_media, p_vlm->media );
TAB_INIT( p_vlm->i_schedule, p_vlm->schedule );
if( vlc_clone( &p_vlm->thread, Manage, p_vlm, VLC_THREAD_PRIORITY_LOW ) )
{
+ vlc_cond_destroy( &p_vlm->wait_manage );
+ vlc_mutex_destroy( &p_vlm->lock_manage );
vlc_mutex_destroy( &p_vlm->lock );
vlc_object_release( p_vlm );
vlc_mutex_unlock( &vlm_mutex );
vlm_ControlInternal( p_vlm, VLM_CLEAR_SCHEDULES );
TAB_CLEAN( p_vlm->schedule, p_vlm->schedule );
+ vlc_cond_signal( &p_vlm->wait_manage );
+
libvlc_priv(p_vlm->p_libvlc)->p_vlm = NULL;
vlc_object_kill( p_vlm );
/*vlc_cancel( p_vlm->thread ); */
vlc_join( p_vlm->thread, NULL );
+
+ vlc_cond_destroy( &p_vlm->wait_manage );
+ vlc_mutex_destroy( &p_vlm->lock_manage );
vlc_mutex_destroy( &p_vlm->lock );
}
int i, j;
mtime_t i_lastcheck;
mtime_t i_time;
+ mtime_t i_nextschedule = 0;
int canc = vlc_savecancel ();
i_lastcheck = vlm_Date();
char **ppsz_scheduled_commands = NULL;
int i_scheduled_commands = 0;
+ vlc_mutex_lock( &vlm->lock_manage );
+ if( i_nextschedule )
+ vlc_cond_timedwait( &vlm->wait_manage, &vlm->lock_manage, i_nextschedule-mdate() );
+ else
+ vlc_cond_wait( &vlm->wait_manage, &vlm->lock_manage );
+ vlc_mutex_unlock( &vlm->lock_manage );
+
vlc_mutex_lock( &vlm->lock );
/* destroy the inputs that wants to die, and launch the next input */
/* scheduling */
i_time = vlm_Date();
+ i_nextschedule = 0;
for( i = 0; i < vlm->i_schedule; i++ )
{
vlm->schedule[i]->i_period;
}
- if( i_real_date <= i_time && i_real_date > i_lastcheck )
+ if( i_real_date <= i_time )
{
- for( j = 0; j < vlm->schedule[i]->i_command; j++ )
+ if( i_real_date > i_lastcheck )
{
- TAB_APPEND( i_scheduled_commands,
- ppsz_scheduled_commands,
- strdup(vlm->schedule[i]->command[j] ) );
+ for( j = 0; j < vlm->schedule[i]->i_command; j++ )
+ {
+ TAB_APPEND( i_scheduled_commands,
+ ppsz_scheduled_commands,
+ strdup(vlm->schedule[i]->command[j] ) );
+ }
}
}
+ else
+ {
+ i_nextschedule = i_real_date;
+ }
}
}
+
while( i_scheduled_commands )
{
vlm_message_t *message = NULL;
i_lastcheck = i_time;
vlc_mutex_unlock( &vlm->lock );
-
- msleep( 100000 );
}
vlc_restorecancel (canc);