[vlc-devel] commit: vod input preparsing : use input events instead of msleep ( Sébastien Escudier )

git version control git at videolan.org
Mon Sep 14 17:05:10 CEST 2009


vlc | branch: master | Sébastien Escudier <sebastien-devel at celeos.eu> | Fri Sep 11 11:26:22 2009 +0200| [e44b8916a9edb01186613aa1a681e3cf0df2a217] | committer: Rémi Denis-Courmont 

vod input preparsing : use input events instead of msleep

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

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

 src/input/vlm.c |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/input/vlm.c b/src/input/vlm.c
index 0f63dd1..8acce0c 100644
--- a/src/input/vlm.c
+++ b/src/input/vlm.c
@@ -69,6 +69,18 @@ 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 );
 
+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;
+
+    if( newval.i_int == INPUT_EVENT_DEAD )
+        vlc_sem_post( p_sem_preparse );
+
+    return VLC_SUCCESS;
+}
+
 static int InputEvent( vlc_object_t *p_this, char const *psz_cmd,
                        vlc_value_t oldval, vlc_value_t newval,
                        void *p_data )
@@ -558,8 +570,15 @@ static int vlm_OnMediaUpdate( vlm_t *p_vlm, vlm_media_sys_t *p_media )
 
             if( (p_input = input_CreateAndStart( p_vlm->p_libvlc, p_media->vod.p_item, psz_header ) ) )
             {
-                while( !p_input->b_eof && !p_input->b_error )
-                    msleep( 100000 );
+                vlc_sem_t sem_preparse;
+                vlc_sem_init( &sem_preparse, 0 );
+                var_AddCallback( p_input, "intf-event", InputEventPreparse, &sem_preparse );
+
+                if( !p_input->b_dead )
+                    vlc_sem_wait( &sem_preparse );
+
+                var_DelCallback( p_input, "intf-event", InputEventPreparse, &sem_preparse );
+                vlc_sem_destroy( &sem_preparse );
 
                 input_Stop( p_input, false );
                 vlc_thread_join( p_input );




More information about the vlc-devel mailing list