diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/audio.c | 25 | ||||
-rw-r--r-- | src/cmumble.c | 5 | ||||
-rw-r--r-- | src/cmumble.h | 1 |
3 files changed, 30 insertions, 1 deletions
diff --git a/src/audio.c b/src/audio.c index d77434b..a373871 100644 --- a/src/audio.c +++ b/src/audio.c @@ -62,6 +62,29 @@ pull_buffer(GstAppSink *sink, gpointer user_data) return GST_FLOW_OK; } +static gboolean +idle(gpointer user_data) +{ + struct cmumble *cm = user_data; + GstAppSink *sink; + + while ((sink = g_async_queue_try_pop(cm->async_queue)) != NULL) + pull_buffer(sink, cm); + + return FALSE; +} + +static GstFlowReturn +new_buffer(GstAppSink *sink, gpointer user_data) +{ + struct cmumble *cm = user_data; + + g_async_queue_push(cm->async_queue, sink); + g_idle_add(idle, cm); + + return GST_FLOW_OK; +} + static int setup_recording_gst_pipeline(struct cmumble *cm) { @@ -88,7 +111,7 @@ setup_recording_gst_pipeline(struct cmumble *cm) gst_app_sink_set_emit_signals(cm->audio.sink, TRUE); gst_app_sink_set_drop(cm->audio.sink, FALSE);; - g_signal_connect(sink, "new-buffer", G_CALLBACK(pull_buffer), cm); + g_signal_connect(sink, "new-buffer", G_CALLBACK(new_buffer), cm); caps = gst_caps_new_simple("audio/x-celt", "rate", G_TYPE_INT, SAMPLERATE, diff --git a/src/cmumble.c b/src/cmumble.c index 247d661..0b3a6f5 100644 --- a/src/cmumble.c +++ b/src/cmumble.c @@ -358,6 +358,10 @@ int main(int argc, char **argv) cm.loop = g_main_loop_new(NULL, FALSE); cm.callbacks = (const callback_t *) &callbacks; + cm.async_queue = g_async_queue_new_full(g_free); + if (cm.async_queue == NULL) + return 1; + cmumble_commands_init(&cm); if (cmumble_connection_init(&cm, host, port) < 0) return 1; @@ -375,6 +379,7 @@ int main(int argc, char **argv) cmumble_io_fini(&cm); cmumble_audio_fini(&cm); cmumble_connection_fini(&cm); + g_async_queue_unref(cm.async_queue); return 0; } diff --git a/src/cmumble.h b/src/cmumble.h index 847b384..2dac580 100644 --- a/src/cmumble.h +++ b/src/cmumble.h @@ -22,6 +22,7 @@ struct cmumble { const struct cmumble_command *commands; GMainLoop *loop; + GAsyncQueue *async_queue; uint32_t session; gboolean authenticated; |