diff options
author | irungentoo <irungentoo@gmail.com> | 2015-03-19 18:02:46 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2015-03-19 18:02:46 -0400 |
commit | 2b2c9f37a61d677ecca47c88bb993d1d4f88e3ee (patch) | |
tree | 750fc3184e7b077200b765684bcdd0f8d9a82840 /toxav | |
parent | 4d242231a8b7449b8d275e6c0ae8a186558e10ac (diff) |
Fixed group audio issues when getting an old audio packet.
Diffstat (limited to 'toxav')
-rw-r--r-- | toxav/group.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/toxav/group.c b/toxav/group.c index 3c09878a..ee556d29 100644 --- a/toxav/group.c +++ b/toxav/group.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include "../toxcore/logger.h" | 26 | #include "../toxcore/logger.h" |
27 | 27 | ||
28 | #define GROUP_JBUF_SIZE 6 | 28 | #define GROUP_JBUF_SIZE 6 |
29 | #define GROUP_JBUF_DEAD_SECONDS 4 | ||
29 | 30 | ||
30 | typedef struct { | 31 | typedef struct { |
31 | uint16_t sequnum; | 32 | uint16_t sequnum; |
@@ -39,6 +40,7 @@ typedef struct { | |||
39 | uint32_t capacity; | 40 | uint32_t capacity; |
40 | uint16_t bottom; | 41 | uint16_t bottom; |
41 | uint16_t top; | 42 | uint16_t top; |
43 | uint64_t last_queued_time; | ||
42 | } Group_JitterBuffer; | 44 | } Group_JitterBuffer; |
43 | 45 | ||
44 | static Group_JitterBuffer *create_queue(unsigned int capacity) | 46 | static Group_JitterBuffer *create_queue(unsigned int capacity) |
@@ -90,11 +92,19 @@ static int queue(Group_JitterBuffer *q, Group_Audio_Packet *pk) | |||
90 | 92 | ||
91 | unsigned int num = sequnum % q->size; | 93 | unsigned int num = sequnum % q->size; |
92 | 94 | ||
95 | if (!is_timeout(q->last_queued_time, GROUP_JBUF_DEAD_SECONDS)) { | ||
96 | if ((uint32_t)(sequnum - q->bottom) > (1 << 15)) { | ||
97 | /* Drop old packet. */ | ||
98 | return -1; | ||
99 | } | ||
100 | } | ||
101 | |||
93 | if ((uint32_t)(sequnum - q->bottom) > q->size) { | 102 | if ((uint32_t)(sequnum - q->bottom) > q->size) { |
94 | clear_queue(q); | 103 | clear_queue(q); |
95 | q->bottom = sequnum - q->capacity; | 104 | q->bottom = sequnum - q->capacity; |
96 | q->queue[num] = pk; | 105 | q->queue[num] = pk; |
97 | q->top = sequnum + 1; | 106 | q->top = sequnum + 1; |
107 | q->last_queued_time = unix_time(); | ||
98 | return 0; | 108 | return 0; |
99 | } | 109 | } |
100 | 110 | ||
@@ -106,6 +116,7 @@ static int queue(Group_JitterBuffer *q, Group_Audio_Packet *pk) | |||
106 | if ((sequnum - q->bottom) >= (q->top - q->bottom)) | 116 | if ((sequnum - q->bottom) >= (q->top - q->bottom)) |
107 | q->top = sequnum + 1; | 117 | q->top = sequnum + 1; |
108 | 118 | ||
119 | q->last_queued_time = unix_time(); | ||
109 | return 0; | 120 | return 0; |
110 | } | 121 | } |
111 | 122 | ||