summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pjmedia/src/pjmedia/delaybuf.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/pjmedia/src/pjmedia/delaybuf.c b/pjmedia/src/pjmedia/delaybuf.c
index 09903511..2c6aa37b 100644
--- a/pjmedia/src/pjmedia/delaybuf.c
+++ b/pjmedia/src/pjmedia/delaybuf.c
@@ -280,7 +280,9 @@ static void set_max_cnt(pjmedia_delay_buf *b, unsigned new_max_cnt)
return;
}
- shrink_buffer(b, old_max_cnt - new_max_cnt);
+ /* If samples number in the buffer > new_max_cnt, reduce samples first */
+ if (b->buf_cnt > new_max_cnt)
+ shrink_buffer(b, b->buf_cnt - new_max_cnt);
/* Adjust buffer to accomodate the new max_cnt so the samples is secured.
* This is done by make get_pos = 0