From c0cb1a7cf2396b244121b7151ed7e1b0fa5b927a Mon Sep 17 00:00:00 2001 From: Aaro Altonen Date: Fri, 15 May 2020 07:46:50 +0300 Subject: [PATCH] Deallocate frames in example code --- benchmarks/uvgrtp/latency.cc | 5 ++++- examples/sending_generic.cc | 3 +++ examples/srtp_user.cc | 3 +++ examples/srtp_zrtp.cc | 3 +++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/benchmarks/uvgrtp/latency.cc b/benchmarks/uvgrtp/latency.cc index f06b1b8..c82bef3 100644 --- a/benchmarks/uvgrtp/latency.cc +++ b/benchmarks/uvgrtp/latency.cc @@ -61,8 +61,11 @@ int main(void) /* If the difference is more than 10 seconds, it's very likely that the frame was dropped * and this latency value is bogus and should be discarded */ - if (diff <= 10 * 1000 * 1000) + if (diff >= 10 * 1000 * 1000) + frames--; + else total += diff; + offset += csize; } rtp_ctx.destroy_session(sess); diff --git a/examples/sending_generic.cc b/examples/sending_generic.cc index 3deb38e..80a2bc5 100644 --- a/examples/sending_generic.cc +++ b/examples/sending_generic.cc @@ -47,6 +47,9 @@ int main(void) fprintf(stderr, "frame was corrupted during transfer!\n"); } + /* the frame must be destroyed manually */ + (void)uvg_rtp::frame::dealloc_frame(frame); + /* Session must be destroyed manually */ ctx.destroy_session(sess); diff --git a/examples/srtp_user.cc b/examples/srtp_user.cc index 45f271b..0f0d319 100644 --- a/examples/srtp_user.cc +++ b/examples/srtp_user.cc @@ -33,6 +33,9 @@ void thread_func(void) for (;;) { auto frame = recv->pull_frame(); fprintf(stderr, "Message: '%s'\n", frame->payload); + + /* the frame must be destroyed manually */ + (void)uvg_rtp::frame::dealloc_frame(frame); } } diff --git a/examples/srtp_zrtp.cc b/examples/srtp_zrtp.cc index a27cc65..26fb733 100644 --- a/examples/srtp_zrtp.cc +++ b/examples/srtp_zrtp.cc @@ -16,6 +16,9 @@ void thread_func(void) for (;;) { auto frame = recv->pull_frame(); fprintf(stderr, "Message: '%s'\n", frame->payload); + + /* the frame must be destroyed manually */ + (void)uvg_rtp::frame::dealloc_frame(frame); } }