From 5cfeda9077946c21ea2766adf6a17e087644c10a Mon Sep 17 00:00:00 2001 From: Wang xingchao Date: Sun, 7 Jul 2013 19:31:27 +0800 Subject: [PATCH 1/2] protocol-http: Add missing rewind callback for source-output Ths missing process_rewind callback would cause remain stream continous playing out even user started to "Pause" or "Stop" the stream. This patch tried to flush the memblockq instead of only rewinding for specific bytes. Test background: load module-http-protocol-tcp, and you would see the sinks/sources through browser at address: http://localhost:4714. step 1) in first console gst-launch-0.10 souphttpsrc location=http://localhost:4714/listen/source/upnp.monitor ! decodebin2 ! pulsesink device=alsa_output.pci-0000_00_1b.0.analog-stereo gst-launch fetch data in http-protocol from data source upnp.monitor and send back to sink through new pipeline. The data map would be like: source unpn.monitor --> http-protocol --> gst-launch client --> sink-input 0 --> PA --> sink alsa_output.pci-0000_00_1b.0.analog-stereo step 2) in second console gst-launch-0.10 filesrc location=/home/tangtang/Downloads/b.mp3 ! mad ! audioconvert ! audioresample ! pulsesink device=upnp Then you would hear music after step 2. The data map would be like: mp3 data stream --> sink-input 1 --> PA --> sink upnp --> source unpn.monitor Terminating commands in step 2) would cause rewind request. Besides of current implementation, i would prefer two more proposals: - Ask for rewind request to sink-inputs in next stage. In above scenario, it should be sink_input 0. - Stop do_work() calling after rewind request. Currently do_work() would continue to write the whole memblockq data to client even the steam stopped already. It's better as running state of pipeline and pause do_work(). Bug fix for 65703: https://bugs.freedesktop.org/show_bug.cgi?id=65703 Signed-off-by: Wang xingchao --- src/pulsecore/protocol-http.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/pulsecore/protocol-http.c b/src/pulsecore/protocol-http.c index 7d49bf8..c1dd90b 100644 --- a/src/pulsecore/protocol-http.c +++ b/src/pulsecore/protocol-http.c @@ -229,6 +229,20 @@ static void source_output_push_cb(pa_source_output *o, const pa_memchunk *chunk) pa_asyncmsgq_post(pa_thread_mq_get()->outq, PA_MSGOBJECT(o), SOURCE_OUTPUT_MESSAGE_POST_DATA, NULL, 0, chunk, NULL); } +static void source_output_process_rewind_cb(pa_source_output *o, size_t nbytes) { + struct connection *c; + + pa_source_output_assert_ref(o); + pa_source_output_assert_io_context(o); + pa_assert_se(c = o->userdata); + + /* Stop sending out data for client */ + pa_memblockq_flush_write(c->output_memblockq, TRUE); + + pa_log_debug("Http source-output rewind (%lld) %lld", (long long) nbytes, + (long long) pa_memblockq_get_length (c->output_memblockq)); +} + /* Called from main context */ static void source_output_kill_cb(pa_source_output *o) { struct connection*c; @@ -575,6 +589,7 @@ static void handle_listen_prefix(struct connection *c, const char *source_name) } c->source_output->parent.process_msg = source_output_process_msg; + c->source_output->process_rewind = source_output_process_rewind_cb; c->source_output->push = source_output_push_cb; c->source_output->kill = source_output_kill_cb; c->source_output->get_latency = source_output_get_latency_cb; -- 1.7.9.5