diff options
Diffstat (limited to 'toxav/groupav.c')
-rw-r--r-- | toxav/groupav.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/toxav/groupav.c b/toxav/groupav.c index b10a7f8e..40338fb8 100644 --- a/toxav/groupav.c +++ b/toxav/groupav.c | |||
@@ -97,13 +97,13 @@ static void terminate_queue(Group_JitterBuffer *q) | |||
97 | 97 | ||
98 | /* Return 0 if packet was queued, -1 if it wasn't. | 98 | /* Return 0 if packet was queued, -1 if it wasn't. |
99 | */ | 99 | */ |
100 | static int queue(Group_JitterBuffer *q, Group_Audio_Packet *pk) | 100 | static int queue(Group_JitterBuffer *q, const Mono_Time *mono_time, Group_Audio_Packet *pk) |
101 | { | 101 | { |
102 | uint16_t sequnum = pk->sequnum; | 102 | uint16_t sequnum = pk->sequnum; |
103 | 103 | ||
104 | unsigned int num = sequnum % q->size; | 104 | unsigned int num = sequnum % q->size; |
105 | 105 | ||
106 | if (!is_timeout(q->last_queued_time, GROUP_JBUF_DEAD_SECONDS)) { | 106 | if (!mono_time_is_timeout(mono_time, q->last_queued_time, GROUP_JBUF_DEAD_SECONDS)) { |
107 | if ((uint32_t)(sequnum - q->bottom) > (1 << 15)) { | 107 | if ((uint32_t)(sequnum - q->bottom) > (1 << 15)) { |
108 | /* Drop old packet. */ | 108 | /* Drop old packet. */ |
109 | return -1; | 109 | return -1; |
@@ -115,7 +115,7 @@ static int queue(Group_JitterBuffer *q, Group_Audio_Packet *pk) | |||
115 | q->bottom = sequnum - q->capacity; | 115 | q->bottom = sequnum - q->capacity; |
116 | q->queue[num] = pk; | 116 | q->queue[num] = pk; |
117 | q->top = sequnum + 1; | 117 | q->top = sequnum + 1; |
118 | q->last_queued_time = unix_time(); | 118 | q->last_queued_time = mono_time_get(mono_time); |
119 | return 0; | 119 | return 0; |
120 | } | 120 | } |
121 | 121 | ||
@@ -129,7 +129,7 @@ static int queue(Group_JitterBuffer *q, Group_Audio_Packet *pk) | |||
129 | q->top = sequnum + 1; | 129 | q->top = sequnum + 1; |
130 | } | 130 | } |
131 | 131 | ||
132 | q->last_queued_time = unix_time(); | 132 | q->last_queued_time = mono_time_get(mono_time); |
133 | return 0; | 133 | return 0; |
134 | } | 134 | } |
135 | 135 | ||
@@ -178,6 +178,7 @@ typedef struct Group_AV { | |||
178 | } Group_AV; | 178 | } Group_AV; |
179 | 179 | ||
180 | typedef struct Group_Peer_AV { | 180 | typedef struct Group_Peer_AV { |
181 | const Mono_Time *mono_time; | ||
181 | Group_JitterBuffer *buffer; | 182 | Group_JitterBuffer *buffer; |
182 | 183 | ||
183 | OpusDecoder *audio_decoder; | 184 | OpusDecoder *audio_decoder; |
@@ -264,6 +265,7 @@ static void group_av_peer_new(void *object, uint32_t groupnumber, uint32_t frien | |||
264 | return; | 265 | return; |
265 | } | 266 | } |
266 | 267 | ||
268 | peer_av->mono_time = group_av->g_c->mono_time; | ||
267 | peer_av->buffer = create_queue(GROUP_JBUF_SIZE); | 269 | peer_av->buffer = create_queue(GROUP_JBUF_SIZE); |
268 | 270 | ||
269 | if (group_peer_set_object(group_av->g_c, groupnumber, friendgroupnumber, peer_av) == -1) { | 271 | if (group_peer_set_object(group_av->g_c, groupnumber, friendgroupnumber, peer_av) == -1) { |
@@ -419,7 +421,7 @@ static int handle_group_audio_packet(void *object, uint32_t groupnumber, uint32_ | |||
419 | pk->length = length - sizeof(uint16_t); | 421 | pk->length = length - sizeof(uint16_t); |
420 | memcpy(pk->data, packet + sizeof(uint16_t), pk->length); | 422 | memcpy(pk->data, packet + sizeof(uint16_t), pk->length); |
421 | 423 | ||
422 | if (queue(peer_av->buffer, pk) == -1) { | 424 | if (queue(peer_av->buffer, peer_av->mono_time, pk) == -1) { |
423 | free(pk); | 425 | free(pk); |
424 | return -1; | 426 | return -1; |
425 | } | 427 | } |