Commit 97ac6ec0 authored by Steve Lhomme's avatar Steve Lhomme

filter_chain: add a specific function to clear (empty) a filter chain

filter_chain_Reset is reserved for restating new input/output formats and does
not allow empty format anymore.

filter_chain_Clear doesn't change the input/output formats, only remove all the
filters.
parent 0f2ef8de
......@@ -350,11 +350,18 @@ VLC_API void filter_chain_Delete( filter_chain_t * );
* reset p_fmt_in and p_fmt_out to the new values.
*
* \param p_chain pointer to filter chain
* \param p_fmt_in new fmt_in params, may be NULL to leave input fmt unchanged
* \param p_fmt_out new fmt_out params, may be NULL to leave output fmt unchanged
* \param p_fmt_in new fmt_in params
* \param p_fmt_out new fmt_out params
*/
VLC_API void filter_chain_Reset( filter_chain_t *, const es_format_t *, const es_format_t * );
/**
* Remove all existing filters
*
* \param p_chain pointer to filter chain
*/
VLC_API void filter_chain_Clear(filter_chain_t *);
/**
* Append a filter to the chain.
*
......
......@@ -457,7 +457,7 @@ static int CreateChain( filter_t *p_parent, const es_format_t *p_fmt_mid )
return VLC_SUCCESS;
error:
//Clean up.
filter_chain_Reset( p_sys->p_chain, NULL, NULL );
filter_chain_Clear( p_sys->p_chain );
return VLC_EGENERIC;
}
......@@ -491,7 +491,7 @@ static int CreateResizeChromaChain( filter_t *p_parent, const es_format_t *p_fmt
NULL, &p_parent->fmt_out );
if( i_ret != VLC_SUCCESS )
filter_chain_Reset( p_sys->p_chain, NULL, NULL );
filter_chain_Clear( p_sys->p_chain );
return i_ret;
}
......
......@@ -112,6 +112,7 @@ filter_chain_IsEmpty
filter_chain_MouseFilter
filter_chain_NewVideo
filter_chain_Reset
filter_chain_Clear
filter_chain_SubFilter
filter_chain_VideoFilter
filter_chain_VideoFlush
......
......@@ -149,13 +149,18 @@ filter_chain_t *filter_chain_NewVideo( vlc_object_t *obj, bool allow_change,
return chain;
}
void filter_chain_Clear( filter_chain_t *p_chain )
{
while( p_chain->first != NULL )
filter_chain_DeleteFilter( p_chain, &p_chain->first->filter );
}
/**
* Filter chain destruction
*/
void filter_chain_Delete( filter_chain_t *p_chain )
{
while( p_chain->first != NULL )
filter_chain_DeleteFilter( p_chain, &p_chain->first->filter );
filter_chain_Clear( p_chain );
es_format_Clean( &p_chain->fmt_in );
es_format_Clean( &p_chain->fmt_out );
......@@ -168,19 +173,15 @@ void filter_chain_Delete( filter_chain_t *p_chain )
void filter_chain_Reset( filter_chain_t *p_chain, const es_format_t *p_fmt_in,
const es_format_t *p_fmt_out )
{
while( p_chain->first != NULL )
filter_chain_DeleteFilter( p_chain, &p_chain->first->filter );
filter_chain_Clear( p_chain );
if( p_fmt_in )
{
es_format_Clean( &p_chain->fmt_in );
es_format_Copy( &p_chain->fmt_in, p_fmt_in );
}
if( p_fmt_out )
{
es_format_Clean( &p_chain->fmt_out );
es_format_Copy( &p_chain->fmt_out, p_fmt_out );
}
assert(p_fmt_in != NULL);
es_format_Clean( &p_chain->fmt_in );
es_format_Copy( &p_chain->fmt_in, p_fmt_in );
assert(p_fmt_out != NULL);
es_format_Clean( &p_chain->fmt_out );
es_format_Copy( &p_chain->fmt_out, p_fmt_out );
}
static filter_t *filter_chain_AppendInner( filter_chain_t *chain,
......
......@@ -1806,7 +1806,7 @@ void spu_PutSubpicture(spu_t *spu, subpicture_t *subpic)
filter_chain_ForEach(sys->filter_chain,
SubFilterDelProxyCallbacks,
sys->vout);
filter_chain_Reset(sys->filter_chain, NULL, NULL);
filter_chain_Clear(sys->filter_chain);
filter_chain_AppendFromString(spu->p->filter_chain, chain_update);
if (sys->vout)
......@@ -1815,7 +1815,7 @@ void spu_PutSubpicture(spu_t *spu, subpicture_t *subpic)
sys->vout);
}
else
filter_chain_Reset(sys->filter_chain, NULL, NULL);
filter_chain_Clear(sys->filter_chain);
/* "sub-source" was formerly "sub-filter", so now the "sub-filter"
configuration may contain sub-filters or sub-sources configurations.
......@@ -1913,7 +1913,7 @@ subpicture_t *spu_Render(spu_t *spu,
filter_chain_ForEach(sys->source_chain,
SubSourceDelProxyCallbacks,
sys->vout);
filter_chain_Reset(sys->source_chain, NULL, NULL);
filter_chain_Clear(sys->source_chain);
filter_chain_AppendFromString(spu->p->source_chain, chain_update);
if (sys->vout)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment