[vlc-commits] commit: vlm: make proper use of semaphore (Pierre Ynard )

git at videolan.org git at videolan.org
Fri Nov 26 03:23:45 CET 2010


vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Fri Nov 26 03:23:53 2010 +0100| [48029873dd449de187979e0e9c46c9fed0887715] | committer: Pierre Ynard 

vlm: make proper use of semaphore

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=48029873dd449de187979e0e9c46c9fed0887715
---

 include/vlc_sout.h               |    1 -
 modules/stream_out/description.c |    3 ---
 src/input/vlm.c                  |   28 ++++++++++++++++++----------
 3 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/include/vlc_sout.h b/include/vlc_sout.h
index 2c8f2a1..1374856 100644
--- a/include/vlc_sout.h
+++ b/include/vlc_sout.h
@@ -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
diff --git a/modules/stream_out/description.c b/modules/stream_out/description.c
index a53ae96..ba44fb0 100644
--- a/modules/stream_out/description.c
+++ b/modules/stream_out/description.c
@@ -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;
 }
diff --git a/src/input/vlm.c b/src/input/vlm.c
index df2674d..8bae04d 100644
--- a/src/input/vlm.c
+++ b/src/input/vlm.c
@@ -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;
 }
@@ -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 );



More information about the vlc-commits mailing list