summaryrefslogtreecommitdiff
path: root/toxav/toxav.c
diff options
context:
space:
mode:
authorzoff99 <zoff@zoff.cc>2020-04-07 15:56:29 +0200
committeriphydf <iphydf@users.noreply.github.com>2020-04-07 17:16:17 +0000
commit97fc2f4c0b68d8c4eed3987943b3e4efafc361e0 (patch)
tree57eee1eaae44281d22f8ff0a3763c5f983c14600 /toxav/toxav.c
parent27f24e61b2bcb7da616503729ead05c4520b64a3 (diff)
Create own instance of MonoTime for ToxAV.
Diffstat (limited to 'toxav/toxav.c')
-rw-r--r--toxav/toxav.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/toxav/toxav.c b/toxav/toxav.c
index 3d0fe718..777daab8 100644
--- a/toxav/toxav.c
+++ b/toxav/toxav.c
@@ -100,6 +100,7 @@ struct ToxAV {
100 int32_t dmssa; /** Average decoding time in ms */ 100 int32_t dmssa; /** Average decoding time in ms */
101 101
102 uint32_t interval; /** Calculated interval */ 102 uint32_t interval; /** Calculated interval */
103 Mono_Time *toxav_mono_time; /** ToxAV's own mono_time instance */
103}; 104};
104 105
105static void callback_bwc(BWController *bwc, uint32_t friend_number, float loss, void *user_data); 106static void callback_bwc(BWController *bwc, uint32_t friend_number, float loss, void *user_data);
@@ -156,6 +157,7 @@ ToxAV *toxav_new(Tox *tox, Toxav_Err_New *error)
156 157
157 av->tox = tox; 158 av->tox = tox;
158 av->m = m; 159 av->m = m;
160 av->toxav_mono_time = mono_time_new();
159 av->msi = msi_new(av->m); 161 av->msi = msi_new(av->m);
160 162
161 if (av->msi == nullptr) { 163 if (av->msi == nullptr) {
@@ -212,6 +214,8 @@ void toxav_kill(ToxAV *av)
212 } 214 }
213 } 215 }
214 216
217 mono_time_free(av->toxav_mono_time);
218
215 pthread_mutex_unlock(av->mutex); 219 pthread_mutex_unlock(av->mutex);
216 pthread_mutex_destroy(av->mutex); 220 pthread_mutex_destroy(av->mutex);
217 221
@@ -235,7 +239,7 @@ void toxav_iterate(ToxAV *av)
235 return; 239 return;
236 } 240 }
237 241
238 uint64_t start = current_time_monotonic(av->m->mono_time); 242 uint64_t start = current_time_monotonic(av->toxav_mono_time);
239 int32_t rc = 500; 243 int32_t rc = 500;
240 244
241 ToxAVCall *i = av->calls[av->calls_head]; 245 ToxAVCall *i = av->calls[av->calls_head];
@@ -273,7 +277,7 @@ void toxav_iterate(ToxAV *av)
273 } 277 }
274 278
275 av->interval = rc < av->dmssa ? 0 : (rc - av->dmssa); 279 av->interval = rc < av->dmssa ? 0 : (rc - av->dmssa);
276 av->dmsst += current_time_monotonic(av->m->mono_time) - start; 280 av->dmsst += current_time_monotonic(av->toxav_mono_time) - start;
277 281
278 if (++av->dmssc == 3) { 282 if (++av->dmssc == 3) {
279 av->dmssa = av->dmsst / 3 + 5; /* NOTE Magic Offset 5 for precision */ 283 av->dmssa = av->dmsst / 3 + 5; /* NOTE Magic Offset 5 for precision */
@@ -1317,10 +1321,10 @@ static bool call_prepare_transmission(ToxAVCall *call)
1317 } 1321 }
1318 1322
1319 /* Prepare bwc */ 1323 /* Prepare bwc */
1320 call->bwc = bwc_new(av->m, call->friend_number, callback_bwc, call, av->m->mono_time); 1324 call->bwc = bwc_new(av->m, call->friend_number, callback_bwc, call, av->toxav_mono_time);
1321 1325
1322 { /* Prepare audio */ 1326 { /* Prepare audio */
1323 call->audio = ac_new(av->m->mono_time, av->m->log, av, call->friend_number, av->acb, av->acb_user_data); 1327 call->audio = ac_new(av->toxav_mono_time, av->m->log, av, call->friend_number, av->acb, av->acb_user_data);
1324 1328
1325 if (!call->audio) { 1329 if (!call->audio) {
1326 LOGGER_ERROR(av->m->log, "Failed to create audio codec session"); 1330 LOGGER_ERROR(av->m->log, "Failed to create audio codec session");
@@ -1336,7 +1340,7 @@ static bool call_prepare_transmission(ToxAVCall *call)
1336 } 1340 }
1337 } 1341 }
1338 { /* Prepare video */ 1342 { /* Prepare video */
1339 call->video = vc_new(av->m->mono_time, av->m->log, av, call->friend_number, av->vcb, av->vcb_user_data); 1343 call->video = vc_new(av->toxav_mono_time, av->m->log, av, call->friend_number, av->vcb, av->vcb_user_data);
1340 1344
1341 if (!call->video) { 1345 if (!call->video) {
1342 LOGGER_ERROR(av->m->log, "Failed to create video codec session"); 1346 LOGGER_ERROR(av->m->log, "Failed to create video codec session");