Commit ada9d79b authored by smorlat's avatar smorlat

add new method ms_filter_find_neighbours()



git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@475 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent f00fe07e
......@@ -352,6 +352,14 @@ void ms_filter_set_notify_callback(MSFilter *f, MSFilterNotifyFunc fn, void *use
*/
MSFilterId ms_filter_get_id(MSFilter *f);
/**
* Obtain the list of current filter's neighbours, ie filters that are part of same graph.
*
* Returns: a MSList of MSFilter, that needs to be freed by the caller when no more needed.
**/
MSList * ms_filter_find_neighbours(MSFilter *me);
/**
* Destroy a filter object.
*
......
......@@ -232,6 +232,47 @@ void ms_filter_notify_no_arg(MSFilter *f, unsigned int id){
f->notify(f->notify_ud,id,NULL);
}
static void find_filters(MSList **filters, MSFilter *f ){
int i,found;
MSQueue *link;
if (f==NULL) ms_fatal("Bad graph.");
/*ms_message("seeing %s, seen=%i",f->desc->name,f->seen);*/
if (f->seen){
return;
}
f->seen=TRUE;
*filters=ms_list_append(*filters,f);
/* go upstream */
for(i=0;i<f->desc->ninputs;i++){
link=f->inputs[i];
if (link!=NULL) find_filters(filters,link->prev.filter);
}
/* go downstream */
for(i=0,found=0;i<f->desc->noutputs;i++){
link=f->outputs[i];
if (link!=NULL) {
found++;
find_filters(filters,link->next.filter);
}
}
if (f->desc->noutputs>=1 && found==0){
ms_fatal("Bad graph: filter %s has %i outputs, none is connected.",f->desc->name,f->desc->noutputs);
}
}
MSList * ms_filter_find_neighbours(MSFilter *me){
MSList *l=NULL;
MSList *it;
find_filters(&l,me);
/*reset seen boolean for further lookups to succeed !*/
for(it=l;it!=NULL;it=it->next){
MSFilter *f=(MSFilter*)it->data;
f->seen=FALSE;
}
return l;
}
void ms_connection_helper_start(MSConnectionHelper *h){
h->last.filter=0;
h->last.pin=-1;
......
......@@ -79,33 +79,6 @@ void ms_ticker_destroy(MSTicker *ticker){
ms_free(ticker);
}
void find_filters(MSList **filters, MSFilter *f ){
int i,found;
MSQueue *link;
if (f==NULL) ms_fatal("Bad graph.");
/*ms_message("seeing %s, seen=%i",f->desc->name,f->seen);*/
if (f->seen){
return;
}
f->seen=TRUE;
*filters=ms_list_append(*filters,f);
/* go upstream */
for(i=0;i<f->desc->ninputs;i++){
link=f->inputs[i];
if (link!=NULL) find_filters(filters,link->prev.filter);
}
/* go downstream */
for(i=0,found=0;i<f->desc->noutputs;i++){
link=f->outputs[i];
if (link!=NULL) {
found++;
find_filters(filters,link->next.filter);
}
}
if (f->desc->noutputs>=1 && found==0){
ms_fatal("Bad graph: filter %s has %i outputs, none is connected.",f->desc->name,f->desc->noutputs);
}
}
static MSList *get_sources(MSList *filters){
MSList *sources=NULL;
......@@ -130,7 +103,7 @@ int ms_ticker_attach(MSTicker *ticker,MSFilter *f)
return 0;
}
find_filters(&filters,f);
filters=ms_filter_find_neighbours(f);
sources=get_sources(filters);
if (sources==NULL){
ms_fatal("No sources found around filter %s",f->desc->name);
......@@ -161,7 +134,7 @@ int ms_ticker_detach(MSTicker *ticker,MSFilter *f){
ms_mutex_lock(&ticker->lock);
find_filters(&filters,f);
filters=ms_filter_find_neighbours(f);
sources=get_sources(filters);
if (sources==NULL){
ms_fatal("No sources found around filter %s",f->desc->name);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment