]> git.sesse.net Git - vlc/blobdiff - src/misc/filter_chain.c
lower case the module_* functions
[vlc] / src / misc / filter_chain.c
index 5397b067a7d600e8a6393d3a00e4f2a52fe1e161..65a822bd7b661fb02d0add8d55643565e8e7f565 100644 (file)
@@ -54,6 +54,7 @@ static int filter_chain_DeleteFilterInternal( filter_chain_t *, filter_t * );
 
 static int UpdateBufferFunctions( filter_chain_t * );
 static picture_t *VideoBufferNew( filter_t * );
+static void VideoBufferDelete( filter_t *, picture_t * );
 
 /**
  * Filter chain initialisation
@@ -157,7 +158,7 @@ static filter_t *filter_chain_AppendFilterInternal( filter_chain_t *p_chain,
     p_filter->p_cfg = p_cfg;
     p_filter->b_allow_fmt_out_change = p_chain->b_allow_fmt_out_change;
 
-    p_filter->p_module = module_Need( p_filter, p_chain->psz_capability,
+    p_filter->p_module = module_need( p_filter, p_chain->psz_capability,
                                       psz_name, psz_name ? true : false );
 
     if( !p_filter->p_module )
@@ -182,11 +183,12 @@ static filter_t *filter_chain_AppendFilterInternal( filter_chain_t *p_chain,
 
     error:
         if( psz_name )
-            msg_Err( p_chain->p_this, "Failed to create video filter '%s'",
-                     psz_name );
+            msg_Err( p_chain->p_this, "Failed to create %s '%s'",
+                     p_chain->psz_capability, psz_name );
         else
-            msg_Err( p_chain->p_this, "Failed to create video filter" );
-        if( p_filter->p_module ) module_Unneed( p_filter,
+            msg_Err( p_chain->p_this, "Failed to create %s",
+                     p_chain->psz_capability );
+        if( p_filter->p_module ) module_unneed( p_filter,
                                                 p_filter->p_module );
         es_format_Clean( &p_filter->fmt_in );
         es_format_Clean( &p_filter->fmt_out );
@@ -214,10 +216,11 @@ static int filter_chain_AppendFromStringInternal( filter_chain_t *p_chain,
 {
     config_chain_t *p_cfg = NULL;
     char *psz_name = NULL;
+    char* psz_new_string;
 
     if( !psz_string || !*psz_string ) return 0;
 
-    psz_string = config_ChainCreate( &psz_name, &p_cfg, psz_string );
+    psz_new_string = config_ChainCreate( &psz_name, &p_cfg, psz_string );
 
     filter_t *p_filter = filter_chain_AppendFilterInternal( p_chain, psz_name,
                                                             p_cfg, NULL, NULL );
@@ -227,11 +230,13 @@ static int filter_chain_AppendFromStringInternal( filter_chain_t *p_chain,
                  "to filter chain", psz_name );
         free( psz_name );
         free( p_cfg );
+        free( psz_new_string );
         return -1;
     }
     free( psz_name );
 
-    int ret = filter_chain_AppendFromStringInternal( p_chain, psz_string );
+    int ret = filter_chain_AppendFromStringInternal( p_chain, psz_new_string );
+    free( psz_new_string );
     if( ret < 0 )
     {
         filter_chain_DeleteFilterInternal( p_chain, p_filter );
@@ -278,7 +283,7 @@ static int filter_chain_DeleteFilterInternal( filter_chain_t *p_chain,
         p_chain->pf_buffer_allocation_clear( p_filter );
     vlc_object_detach( p_filter );
     if( p_filter->p_module )
-        module_Unneed( p_filter, p_filter->p_module );
+        module_unneed( p_filter, p_filter->p_module );
     vlc_object_release( p_filter );
 
     /* FIXME: check fmt_in/fmt_out consitency */
@@ -328,7 +333,18 @@ int filter_chain_GetLength( filter_chain_t *p_chain )
 
 const es_format_t *filter_chain_GetFmtOut( filter_chain_t *p_chain )
 {
-    return &p_chain->fmt_out;
+
+    if( p_chain->b_allow_fmt_out_change )
+        return &p_chain->fmt_out;
+
+    /* Unless filter_chain_Reset has been called we are doomed */
+    if( p_chain->filters.i_count <= 0 )
+        return &p_chain->fmt_out;
+
+    /* */
+    filter_t *p_last = (filter_t*)p_chain->filters.pp_elems[p_chain->filters.i_count-1];
+
+    return &p_last->fmt_out;
 }
 
 /**
@@ -347,27 +363,6 @@ picture_t *filter_chain_VideoFilter( filter_chain_t *p_chain, picture_t *p_pic )
         filter_t *p_filter = pp_filter[i];
         picture_t *p_newpic = p_filter->pf_video_filter( p_filter, p_pic );
 
-        /* FIXME Ugly hack to make it work in picture core.
-         * FIXME Remove this code when the picture release API has been
-         * FIXME cleaned up (a git revert of the commit should work) */
-        if( p_chain->p_this->i_object_type == VLC_OBJECT_VOUT )
-        {
-            vout_thread_t *p_vout = (vout_thread_t*)p_chain->p_this;
-            vlc_mutex_lock( &p_vout->picture_lock );
-            if( p_pic->i_refcount )
-            {
-                p_pic->i_status = DISPLAYED_PICTURE;
-            }
-            else
-            {
-                p_pic->i_status = DESTROYED_PICTURE;
-                p_vout->i_heap_size--;
-            }
-            vlc_mutex_unlock( &p_vout->picture_lock );
-
-            if( p_newpic )
-                p_newpic->i_status = READY_PICTURE;
-        }
         if( !p_newpic )
             return NULL;
 
@@ -436,7 +431,7 @@ static int UpdateBufferFunctions( filter_chain_t *p_chain )
                 if( p_chain->pf_buffer_allocation_clear )
                     p_chain->pf_buffer_allocation_clear( p_filter );
                 p_filter->pf_vout_buffer_new = VideoBufferNew;
-                p_filter->pf_vout_buffer_del = NULL;
+                p_filter->pf_vout_buffer_del = VideoBufferDelete;
             }
         }
         if( p_chain->filters.i_count >= 1 )
@@ -445,6 +440,7 @@ static int UpdateBufferFunctions( filter_chain_t *p_chain )
             if( p_filter->pf_vout_buffer_new == VideoBufferNew )
             {
                 p_filter->pf_vout_buffer_new = NULL;
+                p_filter->pf_vout_buffer_del = NULL;
                 if( p_chain->pf_buffer_allocation_init( p_filter,
                         p_chain->p_buffer_allocation_data ) != VLC_SUCCESS )
                     return VLC_EGENERIC;
@@ -465,4 +461,8 @@ static picture_t *VideoBufferNew( filter_t *p_filter )
         msg_Err( p_filter, "Failed to allocate picture\n" );
     return p_picture;
 }
+static void VideoBufferDelete( filter_t *p_filter, picture_t *p_picture )
+{
+    picture_Release( p_picture );
+}