[vlc-commits] vlm: check status at thread start
Rémi Denis-Courmont
git at videolan.org
Mon Feb 10 19:04:11 CET 2020
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Feb 9 13:53:18 2020 +0200| [0dcff2b6c6d8e75fffd9d637feecdfd0e201e1e1] | committer: Rémi Denis-Courmont
vlm: check status at thread start
The current time (when the thread starts) is saved as the initial check
time, so actually do the check then. This is achieved by swapping the
sleeping loop and the processing loops.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0dcff2b6c6d8e75fffd9d637feecdfd0e201e1e1
---
src/input/vlm.c | 38 ++++++++++++++++++++++----------------
1 file changed, 22 insertions(+), 16 deletions(-)
diff --git a/src/input/vlm.c b/src/input/vlm.c
index 2cef3024ce..4d75be64c8 100644
--- a/src/input/vlm.c
+++ b/src/input/vlm.c
@@ -396,7 +396,7 @@ static int vlm_MediaVodControl( void *p_private, vod_media_t *p_vod_media,
static void* Manage( void* p_object )
{
vlm_t *vlm = (vlm_t*)p_object;
- time_t lastcheck, now, nextschedule = 0;
+ time_t lastcheck;
time(&lastcheck);
@@ -404,20 +404,6 @@ static void* Manage( void* p_object )
{
char **ppsz_scheduled_commands = NULL;
int i_scheduled_commands = 0;
- bool scheduled_command = false;
-
- vlc_mutex_lock( &vlm->lock_manage );
- mutex_cleanup_push( &vlm->lock_manage );
- while( !vlm->input_state_changed && !scheduled_command )
- {
- if( nextschedule != 0 )
- scheduled_command = vlc_cond_timedwait_daytime( &vlm->wait_manage, &vlm->lock_manage, nextschedule ) != 0;
- else
- vlc_cond_wait( &vlm->wait_manage, &vlm->lock_manage );
- }
- vlm->input_state_changed = false;
- vlc_cleanup_pop( );
- vlc_mutex_unlock( &vlm->lock_manage );
int canc = vlc_savecancel ();
/* destroy the inputs that wants to die, and launch the next input */
@@ -458,8 +444,9 @@ static void* Manage( void* p_object )
}
/* scheduling */
+ time_t now, nextschedule = 0;
+
time(&now);
- nextschedule = 0;
for( int i = 0; i < vlm->i_schedule; i++ )
{
@@ -525,6 +512,25 @@ static void* Manage( void* p_object )
lastcheck = now;
vlc_mutex_unlock( &vlm->lock );
vlc_restorecancel (canc);
+
+ vlc_mutex_lock( &vlm->lock_manage );
+ mutex_cleanup_push( &vlm->lock_manage );
+
+ while( !vlm->input_state_changed )
+ {
+ if( nextschedule )
+ {
+ if( vlc_cond_timedwait_daytime( &vlm->wait_manage,
+ &vlm->lock_manage,
+ nextschedule ) )
+ break;
+ }
+ else
+ vlc_cond_wait( &vlm->wait_manage, &vlm->lock_manage );
+ }
+ vlm->input_state_changed = false;
+ vlc_cleanup_pop( );
+ vlc_mutex_unlock( &vlm->lock_manage );
}
return NULL;
More information about the vlc-commits
mailing list