mirror of
https://github.com/Genymobile/scrcpy
synced 2024-12-13 18:56:40 +00:00
Add buffering debugging tools
Output buffering and clock logs by disabling a compilation flag.
This commit is contained in:
parent
2f03141e9f
commit
4c4d02295c
@ -1,5 +1,9 @@
|
|||||||
#include "clock.h"
|
#include "clock.h"
|
||||||
|
|
||||||
|
#include "util/log.h"
|
||||||
|
|
||||||
|
#define SC_CLOCK_NDEBUG // comment to debug
|
||||||
|
|
||||||
void
|
void
|
||||||
sc_clock_init(struct sc_clock *clock) {
|
sc_clock_init(struct sc_clock *clock) {
|
||||||
clock->count = 0;
|
clock->count = 0;
|
||||||
@ -80,6 +84,11 @@ sc_clock_update(struct sc_clock *clock, sc_tick system, sc_tick stream) {
|
|||||||
if (clock->count > 1) {
|
if (clock->count > 1) {
|
||||||
// Update estimation
|
// Update estimation
|
||||||
sc_clock_estimate(clock, &clock->slope, &clock->offset);
|
sc_clock_estimate(clock, &clock->slope, &clock->offset);
|
||||||
|
|
||||||
|
#ifndef SC_CLOCK_NDEBUG
|
||||||
|
LOGD("Clock estimation: %g * pts + %" PRItick,
|
||||||
|
clock->slope, clock->offset);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef int64_t sc_tick;
|
typedef int64_t sc_tick;
|
||||||
|
#define PRItick PRIi64
|
||||||
#define SC_TICK_FREQ 1000000 // microsecond
|
#define SC_TICK_FREQ 1000000 // microsecond
|
||||||
|
|
||||||
// To be adapted if SC_TICK_FREQ changes
|
// To be adapted if SC_TICK_FREQ changes
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
|
#define SC_BUFFERING_NDEBUG // comment to debug
|
||||||
|
|
||||||
static struct sc_video_buffer_frame *
|
static struct sc_video_buffer_frame *
|
||||||
sc_video_buffer_frame_new(const AVFrame *frame) {
|
sc_video_buffer_frame_new(const AVFrame *frame) {
|
||||||
struct sc_video_buffer_frame *vb_frame = malloc(sizeof(*vb_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);
|
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_offer(vb, vb_frame->frame);
|
||||||
|
|
||||||
sc_video_buffer_frame_delete(vb_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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef SC_BUFFERING_NDEBUG
|
||||||
|
vb_frame->push_date = sc_tick_now();
|
||||||
|
#endif
|
||||||
sc_queue_push(&vb->b.queue, next, vb_frame);
|
sc_queue_push(&vb->b.queue, next, vb_frame);
|
||||||
sc_cond_signal(&vb->b.queue_cond);
|
sc_cond_signal(&vb->b.queue_cond);
|
||||||
|
|
||||||
|
@ -17,6 +17,9 @@ typedef struct AVFrame AVFrame;
|
|||||||
struct sc_video_buffer_frame {
|
struct sc_video_buffer_frame {
|
||||||
AVFrame *frame;
|
AVFrame *frame;
|
||||||
struct sc_video_buffer_frame *next;
|
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);
|
struct sc_video_buffer_frame_queue SC_QUEUE(struct sc_video_buffer_frame);
|
||||||
|
Loading…
Reference in New Issue
Block a user