changeset 12668:ce6ab8cb8597

Send a command throught the filter chain until some item returns AF_OK. Patch by Reimar Doeffinger
author alex
date Fri, 25 Jun 2004 19:02:53 +0000
parents 265925e642e2
children e93facc2c020
files libaf/af.c libaf/af.h
diffstat 2 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libaf/af.c	Fri Jun 25 19:01:56 2004 +0000
+++ b/libaf/af.c	Fri Jun 25 19:02:53 2004 +0000
@@ -82,7 +82,6 @@
 af_instance_t* af_create(af_stream_t* s, char* name)
 {
   char* cmdline = name;
-  char* delim   = "=";
 
   // Allocate space for the new filter and reset all pointers
   af_instance_t* new=malloc(sizeof(af_instance_t));
@@ -93,7 +92,7 @@
   memset(new,0,sizeof(af_instance_t));
 
   // Check for commandline parameters
-  strsep(&cmdline, delim);
+  strsep(&cmdline, "=");
 
   // Find filter from name
   if(NULL == (new->info=af_find(name)))
@@ -598,3 +597,16 @@
   af->data->len=len;
   return AF_OK;
 }
+
+// send control to all filters, starting with the last until
+// one responds with AF_OK
+int af_control_any_rev (af_stream_t* s, int cmd, void* arg) {
+  int res = AF_UNKNOWN;
+  af_instance_t* filt = s->last;
+  while (filt && res != AF_OK) {
+    res = filt->control(filt, cmd, arg);
+    filt = filt->prev;
+  }
+  return (res == AF_OK);
+}
+
--- a/libaf/af.h	Fri Jun 25 19:01:56 2004 +0000
+++ b/libaf/af.h	Fri Jun 25 19:02:53 2004 +0000
@@ -151,6 +151,11 @@
 // Filter data chunk through the filters in the list
 af_data_t* af_play(af_stream_t* s, af_data_t* data);
 
+// send control to all filters, starting with the last until
+// one accepts the command with AF_OK.
+// Returns true if accepting filter was found.
+int af_control_any_rev (af_stream_t* s, int cmd, void* arg);
+
 /* Calculate how long the output from the filters will be given the
    input length "len". The calculated length is >= the actual
    length */