Commit 48029873 authored by Pierre Ynard's avatar Pierre Ynard

vlm: make proper use of semaphore

parent ca29b79f
...@@ -273,7 +273,6 @@ typedef struct sout_description_data_t ...@@ -273,7 +273,6 @@ typedef struct sout_description_data_t
int i_es; int i_es;
es_format_t **es; es_format_t **es;
vlc_sem_t *sem; vlc_sem_t *sem;
bool stop;
} sout_description_data_t; } sout_description_data_t;
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -143,10 +143,7 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -143,10 +143,7 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
block_ChainRelease( p_buffer ); block_ChainRelease( p_buffer );
if( p_sys->i_stream_start + 1500000 < mdate() ) if( p_sys->i_stream_start + 1500000 < mdate() )
{
p_sys->data->stop = true;
vlc_sem_post(p_sys->data->sem); vlc_sem_post(p_sys->data->sem);
}
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -70,15 +70,21 @@ static void vlm_Destructor( vlm_t *p_vlm ); ...@@ -70,15 +70,21 @@ static void vlm_Destructor( vlm_t *p_vlm );
static void* Manage( void * ); static void* Manage( void * );
static int vlm_MediaVodControl( void *, vod_media_t *, const char *, int, va_list ); static int vlm_MediaVodControl( void *, vod_media_t *, const char *, int, va_list );
typedef struct preparse_data_t
{
vlc_sem_t *p_sem;
bool b_mux;
} preparse_data_t;
static int InputEventPreparse( vlc_object_t *p_this, char const *psz_cmd, static int InputEventPreparse( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data ) vlc_value_t oldval, vlc_value_t newval, void *p_data )
{ {
VLC_UNUSED(p_this); VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_this); VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval);
vlc_sem_t *p_sem_preparse = p_data; preparse_data_t *p_pre = p_data;
if( newval.i_int == INPUT_EVENT_DEAD || if( newval.i_int == INPUT_EVENT_DEAD ||
newval.i_int == INPUT_EVENT_ITEM_META ) ( p_pre->b_mux && newval.i_int == INPUT_EVENT_ITEM_META ) )
vlc_sem_post( p_sem_preparse ); vlc_sem_post( p_pre->p_sem );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -623,19 +629,21 @@ static int vlm_OnMediaUpdate( vlm_t *p_vlm, vlm_media_sys_t *p_media ) ...@@ -623,19 +629,21 @@ static int vlm_OnMediaUpdate( vlm_t *p_vlm, vlm_media_sys_t *p_media )
{ {
vlc_sem_t sem_preparse; vlc_sem_t sem_preparse;
vlc_sem_init( &sem_preparse, 0 ); vlc_sem_init( &sem_preparse, 0 );
var_AddCallback( p_input, "intf-event", InputEventPreparse, &sem_preparse );
data.stop = false; preparse_data_t preparse = { .p_sem = &sem_preparse,
.b_mux = (p_cfg->vod.psz_mux != NULL) };
var_AddCallback( p_input, "intf-event", InputEventPreparse,
&preparse );
data.sem = &sem_preparse; data.sem = &sem_preparse;
var_Create( p_input, "sout-description-data", VLC_VAR_ADDRESS ); var_Create( p_input, "sout-description-data", VLC_VAR_ADDRESS );
var_SetAddress( p_input, "sout-description-data", &data ); var_SetAddress( p_input, "sout-description-data", &data );
if( !input_Start( p_input ) ) if( !input_Start( p_input ) )
{
while( !data.stop && !p_input->b_dead && ( !p_cfg->vod.psz_mux || !input_item_IsPreparsed( p_media->vod.p_item ) ) )
vlc_sem_wait( &sem_preparse ); vlc_sem_wait( &sem_preparse );
}
var_DelCallback( p_input, "intf-event", InputEventPreparse, &sem_preparse ); var_DelCallback( p_input, "intf-event", InputEventPreparse,
&preparse );
input_Stop( p_input, true ); input_Stop( p_input, true );
vlc_thread_join( p_input ); vlc_thread_join( p_input );
......
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