[vlc-devel] commit: Remove msleep() from vlm. It should work but testing is recommended . I'll take all the blame in case of issues :D. (Antoine Cellerier )
git version control
git at videolan.org
Sat Feb 6 16:32:58 CET 2010
vlc | branch: master | Antoine Cellerier <dionoea at videolan.org> | Sat Feb 6 16:33:32 2010 +0100| [f37a79b77d4b698c07a4ab4653650ba8c224b8c6] | committer: Antoine Cellerier
Remove msleep() from vlm. It should work but testing is recommended. I'll take all the blame in case of issues :D.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f37a79b77d4b698c07a4ab4653650ba8c224b8c6
---
src/input/vlm.c | 40 +++++++++++++++++++++++++++++++++-------
src/input/vlm_internal.h | 2 ++
src/input/vlmshell.c | 2 ++
3 files changed, 37 insertions(+), 7 deletions(-)
diff --git a/src/input/vlm.c b/src/input/vlm.c
index b483526..18017f4 100644
--- a/src/input/vlm.c
+++ b/src/input/vlm.c
@@ -105,6 +105,8 @@ static int InputEvent( vlc_object_t *p_this, char const *psz_cmd,
}
}
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;
}
@@ -142,6 +144,8 @@ vlm_t *__vlm_New ( vlc_object_t *p_this )
}
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 );
@@ -152,6 +156,8 @@ vlm_t *__vlm_New ( vlc_object_t *p_this )
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 );
@@ -210,10 +216,15 @@ static void vlm_Destructor( vlm_t *p_vlm )
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 );
}
@@ -348,6 +359,7 @@ static void* Manage( void* p_object )
int i, j;
mtime_t i_lastcheck;
mtime_t i_time;
+ mtime_t i_nextschedule = 0;
int canc = vlc_savecancel ();
i_lastcheck = vlm_Date();
@@ -357,6 +369,13 @@ static void* Manage( void* p_object )
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 */
@@ -394,6 +413,7 @@ static void* Manage( void* p_object )
/* scheduling */
i_time = vlm_Date();
+ i_nextschedule = 0;
for( i = 0; i < vlm->i_schedule; i++ )
{
@@ -421,17 +441,25 @@ static void* Manage( void* p_object )
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;
@@ -449,8 +477,6 @@ static void* Manage( void* p_object )
i_lastcheck = i_time;
vlc_mutex_unlock( &vlm->lock );
-
- msleep( 100000 );
}
vlc_restorecancel (canc);
diff --git a/src/input/vlm_internal.h b/src/input/vlm_internal.h
index a8c72fc..7d4c48e 100644
--- a/src/input/vlm_internal.h
+++ b/src/input/vlm_internal.h
@@ -90,6 +90,8 @@ struct vlm_t
vlc_mutex_t lock;
vlc_thread_t thread;
+ vlc_mutex_t lock_manage;
+ vlc_cond_t wait_manage;
/* */
int64_t i_id;
diff --git a/src/input/vlmshell.c b/src/input/vlmshell.c
index 590c8f4..c9fe99c 100644
--- a/src/input/vlmshell.c
+++ b/src/input/vlmshell.c
@@ -995,6 +995,8 @@ static vlm_schedule_sys_t *vlm_ScheduleNew( vlm_t *vlm, const char *psz_name )
TAB_APPEND( vlm->i_schedule, vlm->schedule, p_sched );
+ vlc_cond_signal( &vlm->wait_manage );
+
return p_sched;
}
More information about the vlc-devel
mailing list