From 0b9da088025d8dcf07aae282646e517c957d87a5 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Thu, 5 Dec 2013 21:08:42 +0100 Subject: wip --- src/audio.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/audio.c b/src/audio.c index 99d9cbe..b532870 100644 --- a/src/audio.c +++ b/src/audio.c @@ -160,6 +160,9 @@ pull_buffer(GstAppSink *sink, gpointer user_data) return GST_FLOW_ERROR; } + g_print("buf: %lu%s\n", GST_BUFFER_PTS(buf), + GST_BUFFER_FLAG_IS_SET(buf, GST_BUFFER_FLAG_DISCONT) ? " discont" : ""); + if (cm->audio.last_time < GST_BUFFER_PTS(buf) - BUFFER_TIME) { if (!g_queue_is_empty(cm->audio.buffer_queue)) send_queued_celt_buffers(cm); @@ -168,6 +171,9 @@ pull_buffer(GstAppSink *sink, gpointer user_data) cm->audio.last_time = GST_BUFFER_PTS(buf); silence = g_queue_peek_head(cm->audio.silence_timestamps); + //int i = 0; + //if (silence) + //g_print("silence %d: %lu, pts: %lu\n", i++, *silence, GST_BUFFER_PTS(buf)); while (silence && GST_BUFFER_PTS(buf) > *silence) { g_queue_remove(cm->audio.silence_timestamps, silence); g_free(silence); @@ -176,6 +182,9 @@ pull_buffer(GstAppSink *sink, gpointer user_data) g_queue_push_tail(cm->audio.buffer_queue, sample); + if (silence) { + //g_print("silence: %lu, pts: %lu\n", *silence, GST_BUFFER_PTS(buf)); + } if (silence && *silence == (GST_BUFFER_PTS(buf) + BUFFER_TIME)) return send_queued_celt_buffers(cm); @@ -192,6 +201,7 @@ idle(gpointer user_data) struct cmumble *cm = user_data; GstAppSink *sink; + sink = cm->audio.sink; while ((sink = g_async_queue_try_pop(cm->async_queue)) != NULL) pull_buffer(sink, cm); @@ -203,6 +213,7 @@ new_sample(GstAppSink *sink, gpointer user_data) { struct cmumble *cm = user_data; + g_print("new_sample\n"); g_async_queue_push(cm->async_queue, sink); g_idle_add(idle, cm); @@ -224,6 +235,7 @@ handle_cutter_message(struct cmumble *cm, GstMessage *message) if (!gst_structure_get_boolean(s, "above", &above)) return; + g_print("cutter message. above: %d\n", above); /* We are only intrested in below state */ if (above) return; @@ -234,11 +246,10 @@ handle_cutter_message(struct cmumble *cm, GstMessage *message) if (!gst_structure_get_clock_time(s, "timestamp", time)) return; + g_print("cutter message. ts: %lu\n", *time); - if (*time == cm->audio.last_time + BUFFER_TIME) - send_queued_celt_buffers(cm); - else - g_queue_push_tail(cm->audio.silence_timestamps, time); + send_queued_celt_buffers(cm); + g_queue_push_tail(cm->audio.silence_timestamps, time); } static gboolean @@ -265,7 +276,7 @@ setup_recording_gst_pipeline(struct cmumble *cm) GstBus *bus; char *desc = "autoaudiosrc name=src ! cutter name=cutter ! " "audioresample ! audioconvert ! "AUDIO_CAPS" ! " - "celtenc name=enc perfect-timestamp=true hard-resync=true" " ! " + "celtenc name=enc " /*perfect-timestamp=true hard-resync=true" */" ! " "appsink name=sink caps="CELT_CAPS; pipeline = gst_parse_launch(desc, &error); -- cgit