]> git.sesse.net Git - vlc/blobdiff - src/input/decoder.c
* src/input/input.c: fixed potential deadlock.
[vlc] / src / input / decoder.c
index 3eee0e8fecd121037cc88fd7f05d3b35ce0c7b74..6447ccedfe65384085f0f5e38f26c4abb52a33dd 100644 (file)
@@ -193,6 +193,9 @@ void input_DecoderDelete( decoder_t *p_dec )
     }
     else
     {
+        /* Flush */
+        input_DecoderDecode( p_dec, NULL );
+
         module_Unneed( p_dec, p_dec->p_module );
     }
 
@@ -589,6 +592,15 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block )
             while( (p_packetized_block =
                     p_packetizer->pf_packetize( p_packetizer, &p_block )) )
             {
+                if( p_packetizer->fmt_out.i_extra && !p_dec->fmt_in.i_extra )
+                {
+                    p_dec->fmt_in.i_extra = p_packetizer->fmt_out.i_extra;
+                    p_dec->fmt_in.p_extra = malloc( p_dec->fmt_in.i_extra );
+                    memcpy( p_dec->fmt_in.p_extra,
+                            p_packetizer->fmt_out.p_extra,
+                            p_dec->fmt_in.i_extra );
+                }
+
                 while( p_packetized_block )
                 {
                     block_t *p_next = p_packetized_block->p_next;
@@ -658,7 +670,7 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block )
             p_vout = vlc_object_find( p_dec, VLC_OBJECT_VOUT, FIND_ANYWHERE );
             if( p_vout )
             {
-                vout_DisplaySubPicture( p_vout, p_spu );
+                spu_DisplaySubpicture( p_vout->p_spu, p_spu );
                 vlc_object_release( p_vout );
             }
         }
@@ -725,7 +737,8 @@ static void DeleteDecoder( decoder_t * p_dec )
         p_vout = vlc_object_find( p_dec, VLC_OBJECT_VOUT, FIND_ANYWHERE );
         if( p_vout )
         {
-            vout_ClearOSDChannel( p_vout, p_dec->p_owner->i_spu_channel );
+            spu_Control( p_vout->p_spu, SPU_CHANNEL_CLEAR,
+                         p_dec->p_owner->i_spu_channel );
             vlc_object_release( p_vout );
         }
     }
@@ -907,7 +920,7 @@ static subpicture_t *spu_new_buffer( decoder_t *p_dec )
 {
     decoder_owner_sys_t *p_sys = (decoder_owner_sys_t *)p_dec->p_owner;
     vout_thread_t *p_vout = NULL;
-    subpicture_t *p_spu;
+    subpicture_t *p_subpic;
     int i_attempts = 30;
 
     while( i_attempts-- )
@@ -928,20 +941,23 @@ static subpicture_t *spu_new_buffer( decoder_t *p_dec )
 
     if( p_sys->p_spu_vout != p_vout )
     {
-        p_sys->i_spu_channel =
-            vout_RegisterOSDChannel( p_vout );
+        spu_Control( p_vout->p_spu, SPU_CHANNEL_REGISTER,
+                     &p_sys->i_spu_channel );
         p_sys->p_spu_vout = p_vout;
     }
 
-    p_spu = vout_CreateSubPicture( p_vout, p_sys->i_spu_channel,
-                                   MEMORY_SUBPICTURE );
+    p_subpic = spu_CreateSubpicture( p_vout->p_spu );
+    if( p_subpic )
+    {
+        p_subpic->i_channel = p_sys->i_spu_channel;
+    }
 
     vlc_object_release( p_vout );
 
-    return p_spu;
+    return p_subpic;
 }
 
-static void spu_del_buffer( decoder_t *p_dec, subpicture_t *p_spu )
+static void spu_del_buffer( decoder_t *p_dec, subpicture_t *p_subpic )
 {
-    vout_DestroySubPicture( p_dec->p_owner->p_vout, p_spu );
+    spu_DestroySubpicture( p_dec->p_owner->p_vout->p_spu, p_subpic );
 }