Skip to content

Commit

Permalink
vlm: make proper use of semaphore
Browse files Browse the repository at this point in the history
  • Loading branch information
linkfanel committed Nov 26, 2010
1 parent ca29b79 commit 4802987
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
1 change: 0 additions & 1 deletion include/vlc_sout.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ typedef struct sout_description_data_t
int i_es;
es_format_t **es;
vlc_sem_t *sem;
bool stop;
} sout_description_data_t;

#ifdef __cplusplus
Expand Down
3 changes: 0 additions & 3 deletions modules/stream_out/description.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,7 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
block_ChainRelease( p_buffer );

if( p_sys->i_stream_start + 1500000 < mdate() )
{
p_sys->data->stop = true;
vlc_sem_post(p_sys->data->sem);
}

return VLC_SUCCESS;
}
28 changes: 18 additions & 10 deletions src/input/vlm.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,21 @@ static void vlm_Destructor( vlm_t *p_vlm );
static void* Manage( void * );
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,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
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 ||
newval.i_int == INPUT_EVENT_ITEM_META )
vlc_sem_post( p_sem_preparse );
( p_pre->b_mux && newval.i_int == INPUT_EVENT_ITEM_META ) )
vlc_sem_post( p_pre->p_sem );

return VLC_SUCCESS;
}
Expand Down Expand Up @@ -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_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;
var_Create( p_input, "sout-description-data", VLC_VAR_ADDRESS );
var_SetAddress( p_input, "sout-description-data", &data );

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 );
vlc_thread_join( p_input );
Expand Down

0 comments on commit 4802987

Please sign in to comment.