# HG changeset patch # User alex # Date 1088190173 0 # Node ID ce6ab8cb8597b2238235b7b3dfceef71936ba28b # Parent 265925e642e275fcf072f8eaf3af3bc5999d569d Send a command throught the filter chain until some item returns AF_OK. Patch by Reimar Doeffinger diff -r 265925e642e2 -r ce6ab8cb8597 libaf/af.c --- 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); +} + diff -r 265925e642e2 -r ce6ab8cb8597 libaf/af.h --- 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 */