[vlc-devel] commit: Do not set object b_eof/b_error after sending the event. ( Laurent Aimar )

git version control git at videolan.org
Sun Sep 7 20:16:12 CEST 2008


vlc | branch: 0.9-bugfix | Laurent Aimar <fenrir at videolan.org> | Sat Sep  6 15:49:02 2008 +0200| [993b7237cd0dd5de7adbe8eecae86e15011ae093] | committer: Laurent Aimar 

Do not set object b_eof/b_error after sending the event.

This fixes a few "deadlocks" with input waiting for playlist, while
playlist is waiting for input event.

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

 src/input/input.c          |    7 ++-----
 src/input/input_internal.h |   18 +++++++++++-------
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/input/input.c b/src/input/input.c
index 356c679..bbccf7e 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -494,8 +494,6 @@ static void* Run( vlc_object_t *p_this )
     if( Init( p_input ) )
     {
         /* If we failed, wait before we are killed, and exit */
-        p_input->b_error = true;
-
         WaitDie( p_input );
 
         /* Tell we're dead */
@@ -520,7 +518,6 @@ static void* Run( vlc_object_t *p_this )
         }
 
         /* We have finished */
-        p_input->b_eof = true;
         input_ChangeState( p_input, END_S );
     }
 
@@ -566,7 +563,7 @@ static void* RunAndDestroy( vlc_object_t *p_this )
         }
 
         /* We have finished */
-        p_input->b_eof = true;
+        input_ChangeState( p_input, END_S );
     }
 
     /* Clean up */
@@ -680,7 +677,7 @@ static void MainLoop( input_thread_t *p_input )
             }
             else if( i_ret < 0 )
             {
-                p_input->b_error = true;
+                input_ChangeState( p_input, ERROR_S );
             }
 
             if( i_ret > 0 && p_input->p->i_slave > 0 )
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index c8e0641..8658449 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -382,29 +382,33 @@ void    input_ClockSetRate( input_clock_t *cl, int i_rate );
 char **subtitles_Detect( input_thread_t *, char* path, const char *fname );
 int subtitles_Filter( const char *);
 
-static inline void input_ChangeStateWithVarCallback( input_thread_t *p_input, int state, bool callback )
+static inline void input_ChangeStateWithVarCallback( input_thread_t *p_input, int i_state, bool callback )
 {
-    const bool changed = p_input->i_state != state;
+    const bool changed = p_input->i_state != i_state;
 
-    p_input->i_state = state;
+    p_input->i_state = i_state;
+    if( i_state == ERROR_S )
+        p_input->b_error = true;
+    else if( i_state == END_S )
+        p_input->b_eof = true;
 
-    input_item_SetHasErrorWhenReading( p_input->p->input.p_item, (state == ERROR_S) );
+    input_item_SetHasErrorWhenReading( p_input->p->input.p_item, (i_state == ERROR_S) );
 
     if( callback )
     {
-        var_SetInteger( p_input, "state", state );
+        var_SetInteger( p_input, "state", i_state );
     }
     else
     {
         vlc_value_t val;
-        val.i_int = state;
+        val.i_int = i_state;
         var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL );
     }
     if( changed )
     {
         vlc_event_t event;
         event.type = vlc_InputStateChanged;
-        event.u.input_state_changed.new_state = state;
+        event.u.input_state_changed.new_state = i_state;
         vlc_event_send( &p_input->p->event_manager, &event );
     }
 }




More information about the vlc-devel mailing list