]> git.sesse.net Git - vlc/commitdiff
Another small decoder thread simplification
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Thu, 23 Oct 2008 19:58:01 +0000 (22:58 +0300)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Thu, 23 Oct 2008 19:58:01 +0000 (22:58 +0300)
Conflicts:

src/input/decoder.c

src/input/decoder.c

index 5b5fbbe3e111063efa4931dabaa1585e5e7ad217..b6054cba1a675ddabee18f37a5ef3576afb56d13 100644 (file)
@@ -310,13 +310,8 @@ void input_DecoderDelete( decoder_t *p_dec )
     }
     vlc_mutex_unlock( &p_owner->lock );
 
-    /* Make sure the thread leaves the function */
-    block_FifoWake( p_owner->p_fifo );
-
     vlc_thread_join( p_dec );
-
-    /* Don't module_unneed() here because of the dll loader that wants
-     * close() in the same thread than decode() */
+    module_unneed( p_dec, p_dec->p_module );
 
     /* */
     if( p_dec->p_owner->cc.b_supported )
@@ -782,13 +777,12 @@ static void *DecoderThread( vlc_object_t *p_this )
     decoder_t *p_dec = (decoder_t *)p_this;
     decoder_owner_sys_t *p_owner = p_dec->p_owner;
 
-    int canc = vlc_savecancel();
-
     /* The decoder's main loop */
-    while( vlc_object_alive( p_dec ) )
+    for (;;)
     {
         block_t *p_block = block_FifoGet( p_owner->p_fifo );
-
+        /* Make sure there is no cancellation point other than this one^^.
+         * If you need one, be sure to push cleanup of p_block. */
         DecoderSignalBuffering( p_dec, p_block == NULL );
 
         if( p_block )
@@ -805,11 +799,6 @@ static void *DecoderThread( vlc_object_t *p_this )
     }
 
     DecoderSignalBuffering( p_dec, true );
-
-    /* We do it here because of the dll loader that wants close() in the
-     * same thread than decode() */
-    module_unneed( p_dec, p_dec->p_module );
-    vlc_restorecancel( canc );
     return NULL;
 }
 
@@ -1794,6 +1783,7 @@ static int DecoderProcess( decoder_t *p_dec, block_t *p_block )
         return VLC_SUCCESS;
     }
 
+    int canc = vlc_savecancel ();
 #ifdef ENABLE_SOUT
     if( p_dec->i_object_type == VLC_OBJECT_PACKETIZER )
     {
@@ -1845,6 +1835,7 @@ static int DecoderProcess( decoder_t *p_dec, block_t *p_block )
 
         DecoderSignalFlushed( p_dec );
     }
+    vlc_restorecancel(canc);
 
     return p_dec->b_error ? VLC_EGENERIC : VLC_SUCCESS;
 }