summaryrefslogtreecommitdiff
path: root/pjmedia
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2008-02-29 18:00:34 +0000
committerBenny Prijono <bennylp@teluu.com>2008-02-29 18:00:34 +0000
commitd7c0bb6c5eb3f7274618c831695cb1f3c5e4803b (patch)
tree52e6ae18a985a46ee45c849465367f866411c8c0 /pjmedia
parent364a4cee9f53d438b67fa048e0d7f717ed7b1ab4 (diff)
Added checking in delaybuf for buffer empty before calling shrink_buffer()
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1834 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjmedia')
-rw-r--r--pjmedia/src/pjmedia/delaybuf.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/pjmedia/src/pjmedia/delaybuf.c b/pjmedia/src/pjmedia/delaybuf.c
index 69c1e45b..5a039a7c 100644
--- a/pjmedia/src/pjmedia/delaybuf.c
+++ b/pjmedia/src/pjmedia/delaybuf.c
@@ -197,7 +197,7 @@ static void shrink_buffer(pjmedia_delay_buf *b, unsigned erase_cnt)
unsigned buf2len;
pj_status_t status;
- pj_assert(b && erase_cnt);
+ pj_assert(b && erase_cnt && b->buf_cnt);
if (b->get_pos < b->put_pos) {
/* sssss .. sssss
@@ -273,6 +273,13 @@ static void set_max_cnt(pjmedia_delay_buf *b, unsigned new_max_cnt)
/* For now, only support shrinking */
pj_assert(old_max_cnt > new_max_cnt);
+ /* Buffer empty, only need to reset pointers then set new max directly */
+ if (b->buf_cnt == 0) {
+ b->put_pos = b->get_pos = 0;
+ b->max_cnt = new_max_cnt;
+ return;
+ }
+
shrink_buffer(b, old_max_cnt - new_max_cnt);
/* Adjust buffer to accomodate the new max_cnt so the samples is secured.