From b5bf6a7d30e53cb4d07577c8c743b9fb11373c55 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Thu, 7 Mar 2013 15:10:37 +0000 Subject: [PATCH] timeshift: minor mod to htsp to flush output buffer on skip (cherry picked from commit c862269c622579629a2ca80c3bfe521a751cb8ba) --- src/htsp_server.c | 9 +++++++++ src/timeshift/timeshift_reader.c | 5 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/htsp_server.c b/src/htsp_server.c index ad7bb1a3..1c578a42 100644 --- a/src/htsp_server.c +++ b/src/htsp_server.c @@ -267,6 +267,10 @@ htsp_flush_queue(htsp_connection_t *htsp, htsp_msg_q_t *hmq) TAILQ_REMOVE(&hmq->hmq_q, hm, hm_link); htsp_msg_destroy(hm); } + + // reset + hmq->hmq_length = 0; + hmq->hmq_payload = 0; pthread_mutex_unlock(&htsp->htsp_out_mutex); } @@ -2434,6 +2438,11 @@ htsp_subscription_skip(htsp_subscription_t *hs, streaming_skip_t *skip) htsmsg_t *m = htsmsg_create_map(); htsmsg_add_str(m, "method", "subscriptionSkip"); htsmsg_add_u32(m, "subscriptionId", hs->hs_sid); + + /* Flush pkt buffers */ + if (skip->type != SMT_SKIP_ERROR) + htsp_flush_queue(hs->hs_htsp, &hs->hs_q); + if (skip->type == SMT_SKIP_ABS_TIME || skip->type == SMT_SKIP_ABS_SIZE) htsmsg_add_u32(m, "absolute", 1); if (skip->type == SMT_SKIP_ERROR) diff --git a/src/timeshift/timeshift_reader.c b/src/timeshift/timeshift_reader.c index 1e9e5483..1f9e739b 100644 --- a/src/timeshift/timeshift_reader.c +++ b/src/timeshift/timeshift_reader.c @@ -545,7 +545,7 @@ void *timeshift_reader ( void *p ) /* Convert */ skip_time = ts_rescale(skip->time, 1000000); - tvhlog(LOG_DEBUG, "timeshift", "ts %d skip %"PRId64" requested", ts->id, skip->time); + tvhlog(LOG_DEBUG, "timeshift", "ts %d skip %"PRId64" requested %"PRId64, ts->id, skip_time, skip->time); /* Live playback (stage1) */ if (ts->state == TS_LIVE) { @@ -562,7 +562,8 @@ void *timeshift_reader ( void *p ) /* May have failed */ if (skip) { - tvhlog(LOG_DEBUG, "timeshift", "ts %d skip last_time %"PRId64, ts->id, last_time); + tvhlog(LOG_DEBUG, "timeshift", "ts %d skip last_time %"PRId64" pts_delta %"PRId64, + ts->id, last_time, ts->pts_delta); skip_time += (skip->type == SMT_SKIP_ABS_TIME) ? ts->pts_delta : last_time; /* Live (stage2) */