From 5acf56dec41b035b6b3e6e79f89221e67731ac85 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 25 Apr 2017 10:55:25 -0400 Subject: [PATCH] additional debug log output --- recording-daemon/output.c | 16 ++++++++-------- recording-daemon/packet.c | 22 +++++++++++++++++----- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/recording-daemon/output.c b/recording-daemon/output.c index 5ecb18969..a656e9f62 100644 --- a/recording-daemon/output.c +++ b/recording-daemon/output.c @@ -26,7 +26,7 @@ static int output_flush(output_t *output) { output->frame->nb_samples) <= 0) abort(); - dbg("%p output fifo pts %lu", output, (unsigned long) output->fifo_pts); + dbg("{%s} output fifo pts %lu", output->file_name, (unsigned long) output->fifo_pts); output->frame->pts = output->fifo_pts; int keep_going; @@ -38,7 +38,7 @@ static int output_flush(output_t *output) { #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 36, 0) if (have_frame) { int ret = avcodec_send_frame(output->avcctx, output->frame); - dbg("%p send frame ret %i", output, ret); + dbg("{%s} send frame ret %i", output->file_name, ret); if (ret == 0) { // consumed have_frame = 0; @@ -53,7 +53,7 @@ static int output_flush(output_t *output) { } int ret = avcodec_receive_packet(output->avcctx, &output->avpkt); - dbg("%p receive packet ret %i", output, ret); + dbg("{%s} receive packet ret %i", output->file_name, ret); if (ret == 0) { // got some data keep_going = 1; @@ -70,7 +70,7 @@ static int output_flush(output_t *output) { break; int ret = avcodec_encode_audio2(output->avcctx, &output->avpkt, output->frame, &got_packet); - dbg("%p encode frame ret %i, got packet %i", output, ret, got_packet); + dbg("{%s} encode frame ret %i, got packet %i", output->file_name, ret, got_packet); if (ret == 0) have_frame = 0; // consumed else @@ -82,10 +82,10 @@ static int output_flush(output_t *output) { if (!got_packet) continue; - dbg("%p output avpkt size is %i", output, (int) output->avpkt.size); - dbg("%p output pkt pts/dts is %li/%li", output, (long) output->avpkt.pts, + dbg("{%s} output avpkt size is %i", output->file_name, (int) output->avpkt.size); + dbg("{%s} output pkt pts/dts is %li/%li", output->file_name, (long) output->avpkt.pts, (long) output->avpkt.dts); - dbg("%p output dts %li", output, (long) output->mux_dts); + dbg("{%s} output dts %li", output->file_name, (long) output->mux_dts); // the encoder may return frames with the same dts multiple consecutive times. // the muxer may not like this, so ensure monotonically increasing dts. @@ -113,7 +113,7 @@ int output_add(output_t *output, AVFrame *frame) { if (!output->frame) // not ready - not configured return -1; - dbg("%p output fifo size %u fifo_pts %lu", output, (unsigned int) av_audio_fifo_size(output->fifo), + dbg("{%s} output fifo size %u fifo_pts %lu", output->file_name, (unsigned int) av_audio_fifo_size(output->fifo), (unsigned long) output->fifo_pts); // fix up output pts if (av_audio_fifo_size(output->fifo) == 0) diff --git a/recording-daemon/packet.c b/recording-daemon/packet.c index be9bc7d0d..7ec8786f5 100644 --- a/recording-daemon/packet.c +++ b/recording-daemon/packet.c @@ -104,28 +104,39 @@ static int ssrc_tree_search(const void *testseq_p, const void *ts_p) { static packet_t *ssrc_next_packet(ssrc_t *ssrc) { // see if we have a packet with the correct seq nr in the queue packet_t *packet = g_tree_lookup(ssrc->packets, GINT_TO_POINTER(ssrc->seq)); - if (G_LIKELY(packet != NULL)) + if (G_LIKELY(packet != NULL)) { + dbg("returning in-sequence packet (seq %i)", ssrc->seq); return packet; + } // why not? do we have anything? (we should) int nnodes = g_tree_nnodes(ssrc->packets); - if (G_UNLIKELY(nnodes == 0)) + if (G_UNLIKELY(nnodes == 0)) { + dbg("packet queue empty"); return NULL; - if (G_LIKELY(nnodes < 10)) // XXX arbitrary value + } + if (G_LIKELY(nnodes < 10)) { // XXX arbitrary value + dbg("only %i packets in queue - waiting for more", nnodes); return NULL; // need to wait for more + } // packet was probably lost. search for the next highest seq struct tree_searcher ts = { .find_seq = ssrc->seq + 1, .found_seq = -1 }; packet = g_tree_search(ssrc->packets, ssrc_tree_search, &ts); - if (packet) // bullseye + if (packet) { + // bullseye + dbg("lost packet - returning packet with next seq %i", packet->seq); return packet; + } if (G_UNLIKELY(ts.found_seq == -1)) { // didn't find anything. seq must have wrapped around. retry // starting from zero ts.find_seq = 0; packet = g_tree_search(ssrc->packets, ssrc_tree_search, &ts); - if (packet) + if (packet) { + dbg("lost packet - returning packet with next seq %i (after wrap)", packet->seq); return packet; + } if (G_UNLIKELY(ts.found_seq == -1)) abort(); } @@ -135,6 +146,7 @@ static packet_t *ssrc_next_packet(ssrc_t *ssrc) { if (G_UNLIKELY(packet == NULL)) abort(); + dbg("lost multiple packets - returning packet with next highest seq %i", packet->seq); return packet; }