diff --git a/lib/auxlib.h b/lib/auxlib.h index 5877a5e33..68ae7661e 100644 --- a/lib/auxlib.h +++ b/lib/auxlib.h @@ -266,6 +266,21 @@ INLINE double ntp_ts_to_double(u_int32_t whole, u_int32_t frac) { } +/*** GLIB HELPERS ***/ + +INLINE int g_tree_clear_cb(void *k, void *v, void *p) { + GQueue *q = p; + g_queue_push_tail(q, k); + return 0; +} +INLINE void g_tree_clear(GTree *t) { + GQueue q = G_QUEUE_INIT; + g_tree_foreach(t, g_tree_clear_cb, &q); + while (q.length) { + void *k = g_queue_pop_head(&q); + g_tree_remove(t, k); + } +} #endif diff --git a/lib/codeclib.c b/lib/codeclib.c index 9162db468..f0fa0a61c 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -618,6 +618,8 @@ int decoder_input_data(decoder_t *dec, const str *data, unsigned long ts, if (!data || !data->s || !data->len) return 0; + ts *= dec->def->clockrate_mult; + dbg("%p dec pts %llu rtp_ts %llu incoming ts %lu", dec, (unsigned long long) dec->pts, (unsigned long long) dec->rtp_ts, (unsigned long) ts); @@ -933,6 +935,7 @@ int packet_sequencer_insert(packet_sequencer_t *ps, seq_packet_t *p) { ps->seq = p->seq; ret = 1; // seq ok - fall thru + g_tree_clear(ps->packets); seq_ok: if (g_tree_lookup(ps->packets, GINT_TO_POINTER(p->seq))) return -1; diff --git a/recording-daemon/decoder.c b/recording-daemon/decoder.c index 429ffbad0..0c04ec0c0 100644 --- a/recording-daemon/decoder.c +++ b/recording-daemon/decoder.c @@ -56,6 +56,8 @@ decode_t *decoder_new(const char *payload_str, output_t *outp) { if (def->avcodec_id == -1) // not a real audio codec return NULL; + // decoder_new_fmt already handles the clockrate_mult scaling + int rtp_clockrate = clockrate; clockrate *= def->clockrate_mult; // we can now config our output, which determines the sample format we convert to @@ -77,7 +79,7 @@ decode_t *decoder_new(const char *payload_str, output_t *outp) { outp->encoder->requested_format.format = out_format.format; } - decoder_t *dec = decoder_new_fmt(def, clockrate, channels, &out_format); + decoder_t *dec = decoder_new_fmt(def, rtp_clockrate, channels, &out_format); if (!dec) return NULL; decode_t *deco = g_slice_alloc0(sizeof(decode_t));