summaryrefslogtreecommitdiff
path: root/toxav/av_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxav/av_test.c')
-rw-r--r--toxav/av_test.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/toxav/av_test.c b/toxav/av_test.c
index 9be648f6..7948445d 100644
--- a/toxav/av_test.c
+++ b/toxav/av_test.c
@@ -26,6 +26,8 @@
26#define c_sleep(x) usleep(1000*x) 26#define c_sleep(x) usleep(1000*x)
27#endif 27#endif
28 28
29#define MIN(a,b) (((a)<(b))?(a):(b))
30
29/* Enable/disable tests */ 31/* Enable/disable tests */
30#define TEST_REGULAR_AV 0 32#define TEST_REGULAR_AV 0
31#define TEST_REGULAR_A 0 33#define TEST_REGULAR_A 0
@@ -156,12 +158,15 @@ void iterate(Tox* Bsn, ToxAV* AliceAV, ToxAV* BobAV)
156 toxav_iteration(AliceAV); 158 toxav_iteration(AliceAV);
157 toxav_iteration(BobAV); 159 toxav_iteration(BobAV);
158 160
159 c_sleep(toxav_iteration_interval(AliceAV)); 161 int mina = MIN(tox_do_interval(toxav_get_tox(AliceAV)), toxav_iteration_interval(AliceAV));
162 int minb = MIN(tox_do_interval(toxav_get_tox(BobAV)), toxav_iteration_interval(BobAV));
163
164 c_sleep(MIN(mina, minb));
160} 165}
161 166
162int device_read_frame(ALCdevice* device, int32_t frame_dur, int16_t* PCM, size_t max_size) 167int device_read_frame(ALCdevice* device, int32_t frame_dur, int16_t* PCM, size_t max_size)
163{ 168{
164 int f_size = (48000 * frame_dur / 1000); 169 int f_size = (8000 * frame_dur / 1000);
165 170
166 if (max_size < f_size) 171 if (max_size < f_size)
167 return -1; 172 return -1;
@@ -645,7 +650,7 @@ int main (int argc, char** argv)
645 int frame_size = device_read_frame(in_device, 20, PCM, sizeof(PCM)); 650 int frame_size = device_read_frame(in_device, 20, PCM, sizeof(PCM));
646 if (frame_size > 0) { 651 if (frame_size > 0) {
647 TOXAV_ERR_SEND_FRAME rc; 652 TOXAV_ERR_SEND_FRAME rc;
648 if (toxav_send_audio_frame(AliceAV, 0, PCM, frame_size, 2, 48000, &rc) == false) { 653 if (toxav_send_audio_frame(AliceAV, 0, PCM, frame_size, 2, 8000, &rc) == false) {
649 printf("Error sending frame of size %d: %d\n", frame_size, rc); 654 printf("Error sending frame of size %d: %d\n", frame_size, rc);
650 exit (1); 655 exit (1);
651 } 656 }