diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2014-07-09 14:27:13 (GMT) |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2014-07-09 14:27:15 (GMT) |
commit | 5ed7da826915cae8a1fc12301a6a3868f8367844 (patch) | |
tree | 4c78a474e90d3817dd3c25fda07bd08d1c792d98 /src | |
parent | 195cca6063f05bd4657773ef78d0517c1c19ac60 (diff) | |
download | soup-transcoding-proxy-5ed7da826915cae8a1fc12301a6a3868f8367844.zip soup-transcoding-proxy-5ed7da826915cae8a1fc12301a6a3868f8367844.tar.gz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 50 |
1 files changed, 16 insertions, 34 deletions
@@ -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); |