diff --git a/app/src/clock.c b/app/src/clock.c index 7a1e0940..1b353347 100644 --- a/app/src/clock.c +++ b/app/src/clock.c @@ -1,5 +1,9 @@ #include "clock.h" +#include "util/log.h" + +#define SC_CLOCK_NDEBUG // comment to debug + void sc_clock_init(struct sc_clock *clock) { clock->count = 0; @@ -80,6 +84,11 @@ sc_clock_update(struct sc_clock *clock, sc_tick system, sc_tick stream) { if (clock->count > 1) { // Update estimation sc_clock_estimate(clock, &clock->slope, &clock->offset); + +#ifndef SC_CLOCK_NDEBUG + LOGD("Clock estimation: %g * pts + %" PRItick, + clock->slope, clock->offset); +#endif } } diff --git a/app/src/util/tick.h b/app/src/util/tick.h index a7494458..472a18a7 100644 --- a/app/src/util/tick.h +++ b/app/src/util/tick.h @@ -4,6 +4,7 @@ #include typedef int64_t sc_tick; +#define PRItick PRIi64 #define SC_TICK_FREQ 1000000 // microsecond // To be adapted if SC_TICK_FREQ changes diff --git a/app/src/video_buffer.c b/app/src/video_buffer.c index e75c8873..f71a4e78 100644 --- a/app/src/video_buffer.c +++ b/app/src/video_buffer.c @@ -8,6 +8,8 @@ #include "util/log.h" +#define SC_BUFFERING_NDEBUG // comment to debug + static struct sc_video_buffer_frame * sc_video_buffer_frame_new(const AVFrame *frame) { struct sc_video_buffer_frame *vb_frame = malloc(sizeof(*vb_frame)); @@ -94,6 +96,11 @@ run_buffering(void *data) { sc_mutex_unlock(&vb->b.mutex); +#ifndef SC_BUFFERING_NDEBUG + LOGD("Buffering: %" PRItick ";%" PRItick ";%" PRItick, + pts, vb_frame->push_date, sc_tick_now()); +#endif + sc_video_buffer_offer(vb, vb_frame->frame); sc_video_buffer_frame_delete(vb_frame); @@ -231,6 +238,9 @@ sc_video_buffer_push(struct sc_video_buffer *vb, const AVFrame *frame) { return false; } +#ifndef SC_BUFFERING_NDEBUG + vb_frame->push_date = sc_tick_now(); +#endif sc_queue_push(&vb->b.queue, next, vb_frame); sc_cond_signal(&vb->b.queue_cond); diff --git a/app/src/video_buffer.h b/app/src/video_buffer.h index bfdafab5..48777703 100644 --- a/app/src/video_buffer.h +++ b/app/src/video_buffer.h @@ -17,6 +17,9 @@ typedef struct AVFrame AVFrame; struct sc_video_buffer_frame { AVFrame *frame; struct sc_video_buffer_frame *next; +#ifndef NDEBUG + sc_tick push_date; +#endif }; struct sc_video_buffer_frame_queue SC_QUEUE(struct sc_video_buffer_frame);