]> git.sesse.net Git - vlc/blobdiff - src/input/decoder.c
Fixed segfault with subtitle.
[vlc] / src / input / decoder.c
index 05c405ca7133c30f68cfc81c753e4ebf01241666..6f1b76ae05f14a9d29f61165763f529eb571e3df 100644 (file)
@@ -94,13 +94,23 @@ struct decoder_owner_sys_t
 
 /* decoder_GetInputAttachment:
  */
-input_attachment_t *decoder_GetInputAttachment( decoder_t *p_dec, const char *psz_name )
+input_attachment_t *decoder_GetInputAttachment( decoder_t *p_dec,
+                                                const char *psz_name )
 {
     input_attachment_t *p_attachment;
     if( input_Control( p_dec->p_owner->p_input, INPUT_GET_ATTACHMENT, &p_attachment, psz_name ) )
         return NULL;
     return p_attachment;
 }
+/* decoder_GetInputAttachments:
+ */
+int decoder_GetInputAttachments( decoder_t *p_dec,
+                                 input_attachment_t ***ppp_attachment,
+                                 int *pi_attachment )
+{
+    return input_Control( p_dec->p_owner->p_input, INPUT_GET_ATTACHMENTS,
+                          ppp_attachment, pi_attachment );
+}
 
 /**
  * Spawns a new decoder thread
@@ -458,6 +468,7 @@ static inline void DecoderUpdatePreroll( int64_t *pi_preroll, const block_t *p )
 static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block )
 {
     input_thread_t *p_input = p_dec->p_owner->p_input;
+    const int i_rate = p_block->i_rate;
     aout_buffer_t *p_aout_buf;
 
     while( (p_aout_buf = p_dec->pf_decode_audio( p_dec, &p_block )) )
@@ -481,7 +492,7 @@ static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block )
         }
         aout_DecPlay( p_dec->p_owner->p_aout,
                       p_dec->p_owner->p_aout_input,
-                      p_aout_buf );
+                      p_aout_buf, i_rate );
     }
 }
 static void VoutDisplayedPicture( vout_thread_t *p_vout, picture_t *p_pic )
@@ -513,7 +524,8 @@ static void VoutFlushPicture( vout_thread_t *p_vout )
     {
         picture_t *p_pic = p_vout->render.pp_picture[i];
 
-        if( p_pic->i_status != READY_PICTURE )
+        if( p_pic->i_status == READY_PICTURE ||
+            p_pic->i_status == DISPLAYED_PICTURE )
         {
             /* We cannot change picture status if it is in READY_PICTURE state,
              * Just make sure they won't be displayed */
@@ -563,6 +575,7 @@ static void DecoderDecodeVideo( decoder_t *p_dec, block_t *p_block )
  */
 static int DecoderDecode( decoder_t *p_dec, block_t *p_block )
 {
+    decoder_owner_sys_t *p_sys = (decoder_owner_sys_t *)p_dec->p_owner;
     const int i_rate = p_block ? p_block->i_rate : INPUT_RATE_DEFAULT;
 
     if( p_block && p_block->i_buffer <= 0 )
@@ -724,19 +737,22 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block )
             stats_UpdateInteger( p_dec, p_input->p->counters.p_decoded_sub, 1, NULL );
             vlc_mutex_unlock( &p_input->p->counters.counters_lock );
 
-            if( p_spu->i_start < p_dec->p_owner->i_preroll_end &&
-                ( p_spu->i_stop <= 0 || p_spu->i_stop <= p_dec->p_owner->i_preroll_end ) )
+            p_vout = vlc_object_find( p_dec, VLC_OBJECT_VOUT, FIND_ANYWHERE );
+            if( p_vout && p_sys->p_spu_vout == p_vout )
             {
-                spu_DestroySubpicture( p_dec->p_owner->p_vout->p_spu, p_spu );
-                continue;
+                /* Prerool does not work very well with subtitle */
+                if( p_spu->i_start < p_dec->p_owner->i_preroll_end &&
+                    ( p_spu->i_stop <= 0 || p_spu->i_stop < p_dec->p_owner->i_preroll_end ) )
+                    spu_DestroySubpicture( p_vout->p_spu, p_spu );
+                else
+                    spu_DisplaySubpicture( p_vout->p_spu, p_spu );
             }
-
-            p_vout = vlc_object_find( p_dec, VLC_OBJECT_VOUT, FIND_ANYWHERE );
-            if( p_vout )
+            else
             {
-                spu_DisplaySubpicture( p_vout->p_spu, p_spu );
-                vlc_object_release( p_vout );
+                msg_Warn( p_dec, "no vout found, leaking subpicture" );
             }
+            if( p_vout )
+                vlc_object_release( p_vout );
         }
     }
     else