diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-08-30 19:48:19 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-08-31 20:02:41 +0100 |
commit | 6356eb4e4fe407fa7870f2a685d0d08b5c2ec5bb (patch) | |
tree | 5c279f9df9f7389dd4eff69f980c44b6c6d6fe0c /testing | |
parent | 8595d47e101d0e3118c701c17fca26888b728ce3 (diff) |
Enable build of av_test.
It has not been built in a while. We do want to keep this one working (or at
least compiling).
Diffstat (limited to 'testing')
-rw-r--r-- | testing/av_test.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/testing/av_test.c b/testing/av_test.c index 4b2fe61d..7c2922b7 100644 --- a/testing/av_test.c +++ b/testing/av_test.c | |||
@@ -47,6 +47,11 @@ | |||
47 | #include <errno.h> | 47 | #include <errno.h> |
48 | #include <unistd.h> | 48 | #include <unistd.h> |
49 | 49 | ||
50 | #ifdef __APPLE__ | ||
51 | #include <sched.h> | ||
52 | #define pthread_yield sched_yield | ||
53 | #endif | ||
54 | |||
50 | #define c_sleep(x) usleep(1000*x) | 55 | #define c_sleep(x) usleep(1000*x) |
51 | 56 | ||
52 | 57 | ||
@@ -113,6 +118,8 @@ void *pa_write_thread (void *d) | |||
113 | c_sleep(10); | 118 | c_sleep(10); |
114 | } | 119 | } |
115 | } | 120 | } |
121 | |||
122 | return NULL; | ||
116 | } | 123 | } |
117 | 124 | ||
118 | /** | 125 | /** |
@@ -239,9 +246,9 @@ void initialize_tox(Tox **bootstrap, ToxAV **AliceAV, CallControl *AliceCC, ToxA | |||
239 | uint8_t off = 1; | 246 | uint8_t off = 1; |
240 | 247 | ||
241 | while (1) { | 248 | while (1) { |
242 | tox_iterate(*bootstrap); | 249 | tox_iterate(*bootstrap, &to_compare); |
243 | tox_iterate(Alice); | 250 | tox_iterate(Alice, &to_compare); |
244 | tox_iterate(Bob); | 251 | tox_iterate(Bob, &to_compare); |
245 | 252 | ||
246 | if (tox_self_get_connection_status(*bootstrap) && | 253 | if (tox_self_get_connection_status(*bootstrap) && |
247 | tox_self_get_connection_status(Alice) && | 254 | tox_self_get_connection_status(Alice) && |
@@ -284,11 +291,11 @@ void initialize_tox(Tox **bootstrap, ToxAV **AliceAV, CallControl *AliceCC, ToxA | |||
284 | printf("Created 2 instances of ToxAV\n"); | 291 | printf("Created 2 instances of ToxAV\n"); |
285 | printf("All set after %llu seconds!\n", time(NULL) - cur_time); | 292 | printf("All set after %llu seconds!\n", time(NULL) - cur_time); |
286 | } | 293 | } |
287 | int iterate_tox(Tox *bootstrap, ToxAV *AliceAV, ToxAV *BobAV) | 294 | int iterate_tox(Tox *bootstrap, ToxAV *AliceAV, ToxAV *BobAV, void *userdata) |
288 | { | 295 | { |
289 | tox_iterate(bootstrap); | 296 | tox_iterate(bootstrap, userdata); |
290 | tox_iterate(toxav_get_tox(AliceAV)); | 297 | tox_iterate(toxav_get_tox(AliceAV), userdata); |
291 | tox_iterate(toxav_get_tox(BobAV)); | 298 | tox_iterate(toxav_get_tox(BobAV), userdata); |
292 | 299 | ||
293 | return MIN(tox_iteration_interval(toxav_get_tox(AliceAV)), tox_iteration_interval(toxav_get_tox(BobAV))); | 300 | return MIN(tox_iteration_interval(toxav_get_tox(AliceAV)), tox_iteration_interval(toxav_get_tox(BobAV))); |
294 | } | 301 | } |
@@ -542,7 +549,7 @@ CHECK_ARG: | |||
542 | } | 549 | } |
543 | 550 | ||
544 | while (!BobCC.incoming) | 551 | while (!BobCC.incoming) |
545 | iterate_tox(bootstrap, AliceAV, BobAV); | 552 | iterate_tox(bootstrap, AliceAV, BobAV, NULL); |
546 | 553 | ||
547 | { /* Answer */ | 554 | { /* Answer */ |
548 | TOXAV_ERR_ANSWER rc; | 555 | TOXAV_ERR_ANSWER rc; |
@@ -555,7 +562,7 @@ CHECK_ARG: | |||
555 | } | 562 | } |
556 | 563 | ||
557 | while (AliceCC.state == 0) | 564 | while (AliceCC.state == 0) |
558 | iterate_tox(bootstrap, AliceAV, BobAV); | 565 | iterate_tox(bootstrap, AliceAV, BobAV, NULL); |
559 | 566 | ||
560 | /* Open audio file */ | 567 | /* Open audio file */ |
561 | af_handle = sf_open(af_name, SFM_READ, &af_info); | 568 | af_handle = sf_open(af_name, SFM_READ, &af_info); |
@@ -615,11 +622,11 @@ CHECK_ARG: | |||
615 | 622 | ||
616 | if (toxav_audio_send_frame(AliceAV, 0, PCM, count / af_info.channels, af_info.channels, af_info.samplerate, | 623 | if (toxav_audio_send_frame(AliceAV, 0, PCM, count / af_info.channels, af_info.channels, af_info.samplerate, |
617 | &rc) == false) { | 624 | &rc) == false) { |
618 | printf("Error sending frame of size %ld: %d\n", count, rc); | 625 | printf("Error sending frame of size %ld: %d\n", (long)count, rc); |
619 | } | 626 | } |
620 | } | 627 | } |
621 | 628 | ||
622 | iterate_tox(bootstrap, AliceAV, BobAV); | 629 | iterate_tox(bootstrap, AliceAV, BobAV, NULL); |
623 | c_sleep(abs(audio_frame_duration - (current_time_monotonic() - enc_start_time) - 1)); | 630 | c_sleep(abs(audio_frame_duration - (current_time_monotonic() - enc_start_time) - 1)); |
624 | } | 631 | } |
625 | 632 | ||
@@ -638,7 +645,7 @@ CHECK_ARG: | |||
638 | } | 645 | } |
639 | } | 646 | } |
640 | 647 | ||
641 | iterate_tox(bootstrap, AliceAV, BobAV); | 648 | iterate_tox(bootstrap, AliceAV, BobAV, NULL); |
642 | assert(BobCC.state == TOXAV_FRIEND_CALL_STATE_FINISHED); | 649 | assert(BobCC.state == TOXAV_FRIEND_CALL_STATE_FINISHED); |
643 | 650 | ||
644 | /* Stop decode thread */ | 651 | /* Stop decode thread */ |
@@ -678,7 +685,7 @@ CHECK_ARG: | |||
678 | } | 685 | } |
679 | 686 | ||
680 | while (!BobCC.incoming) | 687 | while (!BobCC.incoming) |
681 | iterate_tox(bootstrap, AliceAV, BobAV); | 688 | iterate_tox(bootstrap, AliceAV, BobAV, NULL); |
682 | 689 | ||
683 | { /* Answer */ | 690 | { /* Answer */ |
684 | TOXAV_ERR_ANSWER rc; | 691 | TOXAV_ERR_ANSWER rc; |
@@ -690,7 +697,7 @@ CHECK_ARG: | |||
690 | } | 697 | } |
691 | } | 698 | } |
692 | 699 | ||
693 | iterate_tox(bootstrap, AliceAV, BobAV); | 700 | iterate_tox(bootstrap, AliceAV, BobAV, NULL); |
694 | 701 | ||
695 | /* Start decode thread */ | 702 | /* Start decode thread */ |
696 | struct toxav_thread_data data = { | 703 | struct toxav_thread_data data = { |
@@ -721,7 +728,7 @@ CHECK_ARG: | |||
721 | break; | 728 | break; |
722 | 729 | ||
723 | send_opencv_img(AliceAV, 0, frame); | 730 | send_opencv_img(AliceAV, 0, frame); |
724 | iterate_tox(bootstrap, AliceAV, BobAV); | 731 | iterate_tox(bootstrap, AliceAV, BobAV, NULL); |
725 | c_sleep(10); | 732 | c_sleep(10); |
726 | } | 733 | } |
727 | 734 | ||
@@ -737,7 +744,7 @@ CHECK_ARG: | |||
737 | } | 744 | } |
738 | } | 745 | } |
739 | 746 | ||
740 | iterate_tox(bootstrap, AliceAV, BobAV); | 747 | iterate_tox(bootstrap, AliceAV, BobAV, NULL); |
741 | assert(BobCC.state == TOXAV_FRIEND_CALL_STATE_FINISHED); | 748 | assert(BobCC.state == TOXAV_FRIEND_CALL_STATE_FINISHED); |
742 | 749 | ||
743 | /* Stop decode thread */ | 750 | /* Stop decode thread */ |