#include <stdio.h>
#include <ctype.h> /* tolower() */
+#include <time.h> /* ctime() */
+#include <limits.h>
#include <assert.h>
+#include <sys/time.h> /* gettimeofday() */
#include <vlc_vlm.h>
#include <vlc_modules.h>
-#ifndef WIN32
-# include <sys/time.h> /* gettimeofday() */
-#endif
-
-#include <time.h> /* ctime() */
-#if defined (WIN32)
-#include <sys/timeb.h> /* ftime() */
-#endif
-#include <limits.h>
-
#include <vlc_input.h>
#include <vlc_stream.h>
#include "vlm_internal.h"
TAB_CLEAN( p_vlm->i_schedule, p_vlm->schedule );
vlc_mutex_unlock( &p_vlm->lock );
- vlc_object_kill( p_vlm );
+ vlc_cancel( p_vlm->thread );
if( p_vlm->p_vod )
{
libvlc_priv(p_vlm->p_libvlc)->p_vlm = NULL;
vlc_mutex_unlock( &vlm_mutex );
- vlc_mutex_lock( &p_vlm->lock_manage );
- p_vlm->input_state_changed = true;
- vlc_cond_signal( &p_vlm->wait_manage );
- vlc_mutex_unlock( &p_vlm->lock_manage );
-
- /*vlc_cancel( p_vlm->thread ); */
vlc_join( p_vlm->thread, NULL );
vlc_cond_destroy( &p_vlm->wait_manage );
int64_t vlm_Date(void)
{
-#if defined (WIN32)
- struct timeb tm;
- ftime( &tm );
- return ((int64_t)tm.time) * 1000000 + ((int64_t)tm.millitm) * 1000;
-#else
- struct timeval tv_date;
-
- /* gettimeofday() cannot fail given &tv_date is a valid address */
- (void)gettimeofday( &tv_date, NULL );
- return (mtime_t) tv_date.tv_sec * 1000000 + (mtime_t) tv_date.tv_usec;
-#endif
+ struct timeval tv;
+
+ (void)gettimeofday( &tv, NULL );
+ return tv.tv_sec * INT64_C(1000000) + tv.tv_usec;
}
mtime_t i_time;
mtime_t i_nextschedule = 0;
- int canc = vlc_savecancel ();
i_lastcheck = vlm_Date();
- while( vlc_object_alive( vlm ) )
+ for( ;; )
{
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( i_nextschedule )
vlc_cond_wait( &vlm->wait_manage, &vlm->lock_manage );
}
vlm->input_state_changed = false;
- vlc_mutex_unlock( &vlm->lock_manage );
+ vlc_cleanup_run( );
+
+ int canc = vlc_savecancel ();
/* destroy the inputs that wants to die, and launch the next input */
vlc_mutex_lock( &vlm->lock );
for( i = 0; i < vlm->i_media; i++ )
i_lastcheck = i_time;
vlc_mutex_unlock( &vlm->lock );
-
+ vlc_restorecancel (canc);
}
- vlc_restorecancel (canc);
return NULL;
}
p_instance->b_sout_keep = false;
p_instance->p_parent = vlc_object_create( p_vlm, sizeof (vlc_object_t) );
p_instance->p_input = NULL;
- p_instance->p_input_resource = NULL;
+ p_instance->p_input_resource = input_resource_New( p_instance->p_parent );
return p_instance;
}
vlm_SendEventMediaInstanceStopped( p_vlm, id, p_media->cfg.psz_name );
}
- if( p_instance->p_input_resource )
- {
- input_resource_Terminate( p_instance->p_input_resource );
- input_resource_Release( p_instance->p_input_resource );
- }
+ input_resource_Terminate( p_instance->p_input_resource );
+ input_resource_Release( p_instance->p_input_resource );
vlc_object_release( p_instance->p_parent );
TAB_REMOVE( p_media->i_instance, p_media->instance, p_instance );
if( asprintf( &psz_log, _("Media: %s"), p_media->cfg.psz_name ) != -1 )
{
- if( !p_instance->p_input_resource )
- p_instance->p_input_resource = input_resource_New( p_instance->p_parent );
-
p_instance->p_input = input_Create( p_instance->p_parent,
p_instance->p_item, psz_log,
p_instance->p_input_resource );