summaryrefslogtreecommitdiffstats
path: root/libaf/af.c
diff options
context:
space:
mode:
authoranders <anders@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-10-07 10:46:01 +0000
committeranders <anders@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-10-07 10:46:01 +0000
commitf8e93e8037402c154827696bf04cbd41f3f21a48 (patch)
tree3a441baadfad0ca9f998dd28bfa6b3835f4f0c07 /libaf/af.c
parent1b19920692736aec1c7e5b268a1d53e621d0461d (diff)
downloadmpv-f8e93e8037402c154827696bf04cbd41f3f21a48.tar.bz2
mpv-f8e93e8037402c154827696bf04cbd41f3f21a48.tar.xz
Adding functionality for adding filters during execution
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7650 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libaf/af.c')
-rw-r--r--libaf/af.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/libaf/af.c b/libaf/af.c
index 393f6e3cb1..e4d496464d 100644
--- a/libaf/af.c
+++ b/libaf/af.c
@@ -156,7 +156,9 @@ void af_remove(af_stream_t* s, af_instance_t* af)
free(af);
}
-/* Reinitializes all filters downstream from the filter given in the argument */
+/* Reinitializes all filters downstream from the filter given in the
+ argument the return value is AF_OK if success and AF_ERROR if
+ failure */
int af_reinit(af_stream_t* s, af_instance_t* af)
{
if(!af)
@@ -364,6 +366,31 @@ int af_init(af_stream_t* s)
return 0;
}
+/* Add filter during execution. This function adds the filter "name"
+ to the stream s. The filter will be inserted somewhere nice in the
+ list of filters. The return value is a pointer to the new filter,
+ If the filter couldn't be added the return value is NULL. */
+af_instance_t* af_add(af_stream_t* s, char* name){
+ af_instance_t* new;
+ // Sanity check
+ if(!s || !s->first || !name)
+ return NULL;
+ // Insert the filter somwhere nice
+ if(!strcmp(s->first->info->name,"format"))
+ new = af_append(s, s->first, name);
+ else
+ new = af_prepend(s, s->first, name);
+ if(!new)
+ return NULL;
+
+ // Reinitalize the filter list
+ if(AF_OK != af_reinit(s, s->first)){
+ free(new);
+ return NULL;
+ }
+ return new;
+}
+
// Filter data chunk through the filters in the list
af_data_t* af_play(af_stream_t* s, af_data_t* data)
{
@@ -451,9 +478,6 @@ int af_calc_insize_constrained(af_stream_t* s, int len,
in+=t;
}
-// printf("Could no meet constraint nr 3. in=%d out=%d len=%d max_in=%d max_out=%d",
-// in,out,len,max_insize,max_outsize);
-
// Could no meet constraint nr 3.
while(out > max_outsize || in > max_insize){
in-=t;