Index: ossp-pkg/l2/l2_stream.c RCS File: /v/ossp/cvs/ossp-pkg/l2/Attic/l2_stream.c,v rcsdiff -q -kk '-r1.10' '-r1.11' -u '/v/ossp/cvs/ossp-pkg/l2/Attic/l2_stream.c,v' 2>/dev/null --- l2_stream.c 2001/09/04 14:56:25 1.10 +++ l2_stream.c 2001/09/05 07:38:04 1.11 @@ -49,15 +49,30 @@ l2_result_t l2_stream_channel(l2_stream_t *st, l2_channel_t *ch, unsigned int levelmask) { int i; + l2_channel_t *chC; + l2_channel_t *chN; if (st == NULL || ch == NULL || levelmask == 0) return L2_ERROR; + + /* make sure the stack of channels consists of zero or more + filter channels followed by exactly one output channel */ + for (chC = ch; (chN = l2_channel_downstream(chC)) != NULL; chC = chN) + if (l2_channel_type(chC) != L2_CHANNEL_FILTER) + return L2_ERROR; + if (l2_channel_type(chC) != L2_CHANNEL_OUTPUT) + return L2_ERROR; + + /* find next free channel position in channel array */ for (i = 0; i < L2_MAX_CHANNELS && st->channels[i].ch != NULL; i++) ; if (i == L2_MAX_CHANNELS) return L2_ERROR; + + /* attach this channel */ st->channels[i].ch = ch; st->channels[i].levelmask = levelmask; + return L2_OK; }