Commit 57aec670 authored by Simon Morlat's avatar Simon Morlat

fix purging of delayed_ref signal

parent 40527375
...@@ -107,6 +107,8 @@ static inline int ms_bufferizer_get_avail(MSBufferizer *obj){ ...@@ -107,6 +107,8 @@ static inline int ms_bufferizer_get_avail(MSBufferizer *obj){
return obj->size; return obj->size;
} }
void ms_bufferizer_skip_bytes(MSBufferizer *obj, int bytes);
/* purge all data pending in the bufferizer */ /* purge all data pending in the bufferizer */
void ms_bufferizer_flush(MSBufferizer *obj); void ms_bufferizer_flush(MSBufferizer *obj);
......
...@@ -102,6 +102,11 @@ int ms_bufferizer_read(MSBufferizer *obj, uint8_t *data, int datalen){ ...@@ -102,6 +102,11 @@ int ms_bufferizer_read(MSBufferizer *obj, uint8_t *data, int datalen){
return 0; return 0;
} }
void ms_bufferizer_skip_bytes(MSBufferizer *obj, int bytes){
uint8_t *tmp=(uint8_t*)alloca(bytes);
ms_bufferizer_read(obj,tmp,bytes);
}
void ms_bufferizer_flush(MSBufferizer *obj){ void ms_bufferizer_flush(MSBufferizer *obj){
obj->size=0; obj->size=0;
flushq(&obj->q,0); flushq(&obj->q,0);
......
...@@ -114,6 +114,7 @@ static void speex_ec_process(MSFilter *f){ ...@@ -114,6 +114,7 @@ static void speex_ec_process(MSFilter *f){
mblk_t *refm; mblk_t *refm;
int ref_samples=0; int ref_samples=0;
uint8_t *ref,*echo; uint8_t *ref,*echo;
int size;
if (f->inputs[0]!=NULL){ if (f->inputs[0]!=NULL){
while((refm=ms_queue_get(f->inputs[0]))!=NULL){ while((refm=ms_queue_get(f->inputs[0]))!=NULL){
...@@ -160,11 +161,11 @@ static void speex_ec_process(MSFilter *f){ ...@@ -160,11 +161,11 @@ static void speex_ec_process(MSFilter *f){
ms_queue_put(f->outputs[1],oecho); ms_queue_put(f->outputs[1],oecho);
} }
/* do not accumulate too much reference signal */ /* do not accumulate too much reference signal */
if (ms_bufferizer_get_avail(&s->ref)> s->ref_bytes_limit) { if ((size=ms_bufferizer_get_avail(&s->ref))> s->ref_bytes_limit) {
/* reset evrything */ /* reset evrything */
ms_warning("purging ref signal"); ms_warning("purging ref signal");
ms_bufferizer_flush(&s->ref); ms_bufferizer_flush(&s->ref);
ms_bufferizer_flush(&s->delayed_ref); ms_bufferizer_skip_bytes(&s->delayed_ref,size);
} }
} }
......
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