diff --git a/lib/auxlib.h b/lib/auxlib.h index 20e0de3cf..d7e508fb2 100644 --- a/lib/auxlib.h +++ b/lib/auxlib.h @@ -202,4 +202,21 @@ INLINE int __debug_rwlock_unlock_w(rwlock_t *m, const char *file, unsigned int l +/*** 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 55756333e..f0b1b756f 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -600,6 +600,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); @@ -909,6 +911,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 b206e05ba..01e35051a 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));