From 5ed7da826915cae8a1fc12301a6a3868f8367844 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Wed, 9 Jul 2014 19:57:13 +0530 Subject: appsink: Push samples when availability is signalled This is to demonstrate that this doesn't work. It seems that using the SoupMessage associated with a response outside the signal handler for which it was created can result in a segfault, and eventually does. --- src/main.c | 50 ++++++++++++++++---------------------------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/src/main.c b/src/main.c index 8d016f0..1ee754c 100644 --- a/src/main.c +++ b/src/main.c @@ -104,38 +104,6 @@ err: goto out; } -static GstFlowReturn -write_first_client_chunk_cb (GstElement *appsink, - TranscodeClientCtx *ctx) -{ - GstMapInfo info; - GstSample *sample; - GstBuffer *buffer; - GstMemory *memory; - - g_assert (ctx->first_sample_handler_id); - - g_signal_handler_disconnect (appsink, ctx->first_sample_handler_id); - ctx->first_sample_handler_id = 0; - - /* XXX: If no samples are available, this will block till a sample is available */ - g_signal_emit_by_name (appsink, "pull-sample", &sample); - buffer = gst_sample_get_buffer (sample); - memory = gst_buffer_get_all_memory (buffer); /* copy */ - gst_memory_map (memory, &info, GST_MAP_READ); - - soup_message_body_append (ctx->msg->response_body, SOUP_MEMORY_COPY, - info.data, info.size); /* copy */ - - gst_memory_unmap (memory, &info); - gst_memory_unref (memory); - gst_sample_unref (sample); - - soup_server_unpause_message (server, ctx->msg); - g_print ("."); - return GST_FLOW_OK; -} - static void write_next_client_chunk_cb (SoupMessage *msg, TranscodeClientCtx *ctx) @@ -174,6 +142,20 @@ write_next_client_chunk_cb (SoupMessage *msg, return; } +static GstFlowReturn +write_first_client_chunk_cb (GstElement *appsink, + TranscodeClientCtx *ctx) +{ + g_assert (ctx->first_sample_handler_id); + + //g_signal_handler_disconnect (appsink, ctx->first_sample_handler_id); + //ctx->first_sample_handler_id = 0; + + write_next_client_chunk_cb (ctx->msg, ctx); + + return GST_FLOW_OK; +} + static void client_finished_cb (SoupMessage *msg, TranscodeClientCtx *ctx) @@ -298,8 +280,8 @@ GET: client_ctx->first_sample_handler_id = g_signal_connect (appsink, "new-sample", G_CALLBACK (write_first_client_chunk_cb), client_ctx); - g_signal_connect (client_ctx->msg, "wrote-chunk", - G_CALLBACK (write_next_client_chunk_cb), client_ctx); + /*g_signal_connect (client_ctx->msg, "wrote-chunk", + G_CALLBACK (write_next_client_chunk_cb), client_ctx);*/ g_signal_connect (client_ctx->msg, "finished", G_CALLBACK (client_finished_cb), client_ctx); -- cgit v0.11.2-2-gd1dd