diff --git a/dumb/include/dumb.h b/dumb/include/dumb.h index d82afe6f69..f0799c7faa 100644 --- a/dumb/include/dumb.h +++ b/dumb/include/dumb.h @@ -233,7 +233,6 @@ int32 DUMBEXPORT duh_get_length(DUH *duh); const char *DUMBEXPORT duh_get_tag(DUH *duh, const char *key); - /* Signal Rendering Functions */ typedef struct DUH_SIGRENDERER DUH_SIGRENDERER; @@ -610,6 +609,8 @@ sigdata_t *DUMBEXPORT duh_get_raw_sigdata(DUH *duh, int sig, int32 type); DUH_SIGRENDERER *DUMBEXPORT duh_encapsulate_raw_sigrenderer(sigrenderer_t *vsigrenderer, DUH_SIGTYPE_DESC *desc, int n_channels, int32 pos); sigrenderer_t *DUMBEXPORT duh_get_raw_sigrenderer(DUH_SIGRENDERER *sigrenderer, int32 type); +int DUMBEXPORT duh_add_signal(DUH *duh, DUH_SIGTYPE_DESC *desc, sigdata_t *sigdata); + /* Standard Signal Types */ diff --git a/dumb/src/core/makeduh.c b/dumb/src/core/makeduh.c index 598b637bce..24f29259b1 100644 --- a/dumb/src/core/makeduh.c +++ b/dumb/src/core/makeduh.c @@ -130,3 +130,22 @@ DUH *make_duh( return duh; } + +int DUMBEXPORT duh_add_signal(DUH *duh, DUH_SIGTYPE_DESC *desc, sigdata_t *sigdata) +{ + DUH_SIGNAL **signal; + + if ( !duh || !desc || !sigdata ) return -1; + + signal = ( DUH_SIGNAL ** ) realloc( duh->signal, ( duh->n_signals + 1 ) * sizeof( *duh->signal ) ); + if ( !signal ) return -1; + duh->signal = signal; + + memmove( signal + 1, signal, duh->n_signals * sizeof( *signal ) ); + duh->n_signals++; + + signal[ 0 ] = make_signal( desc, sigdata ); + if ( !signal[ 0 ] ) return -1; + + return 0; +} diff --git a/dumb/src/core/rawsig.c b/dumb/src/core/rawsig.c index a1edd60d04..2287bb0684 100644 --- a/dumb/src/core/rawsig.c +++ b/dumb/src/core/rawsig.c @@ -29,16 +29,30 @@ */ sigdata_t *DUMBEXPORT duh_get_raw_sigdata(DUH *duh, int sig, int32 type) { + int i; DUH_SIGNAL *signal; if (!duh) return NULL; - if ((unsigned int)sig >= (unsigned int)duh->n_signals) return NULL; + if ( sig >= 0 ) + { + if ((unsigned int)sig >= (unsigned int)duh->n_signals) return NULL; - signal = duh->signal[sig]; + signal = duh->signal[sig]; - if (signal && signal->desc->type == type) - return signal->sigdata; + if (signal && signal->desc->type == type) + return signal->sigdata; + } + else + { + for ( i = 0; i < duh->n_signals; i++ ) + { + signal = duh->signal[i]; + + if (signal && signal->desc->type == type) + return signal->sigdata; + } + } return NULL; } diff --git a/dumb/src/it/itmisc.c b/dumb/src/it/itmisc.c index 1045af8fa3..5a45d3192e 100644 --- a/dumb/src/it/itmisc.c +++ b/dumb/src/it/itmisc.c @@ -24,7 +24,7 @@ DUMB_IT_SIGDATA *DUMBEXPORT duh_get_it_sigdata(DUH *duh) { - return duh_get_raw_sigdata(duh, 0, SIGTYPE_IT); + return duh_get_raw_sigdata(duh, -1, SIGTYPE_IT); }