[rygel] core: Simpler buffer processing
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [rygel] core: Simpler buffer processing
- Date: Sun, 25 Oct 2009 15:37:08 +0000 (UTC)
commit 332bb78ef9c30ad9a7d0c398ea0cc6ef622b545a
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Sun Oct 25 04:43:35 2009 +0200
core: Simpler buffer processing
No need to keep a queue of buffers. Just use closure to pass the
buffer to the idle handler.
src/rygel/rygel-live-response.vala | 31 ++++++++++++-------------------
1 files changed, 12 insertions(+), 19 deletions(-)
---
diff --git a/src/rygel/rygel-live-response.vala b/src/rygel/rygel-live-response.vala
index 06767e0..8c57af8 100644
--- a/src/rygel/rygel-live-response.vala
+++ b/src/rygel/rygel-live-response.vala
@@ -36,10 +36,9 @@ internal class Rygel.LiveResponse : Rygel.HTTPResponse {
private Pipeline pipeline;
- private AsyncQueue<Buffer> buffers;
-
private HTTPSeek time_range;
+ private uint idle_id;
private SourceFunc continuation;
public LiveResponse (Soup.Server server,
@@ -52,8 +51,6 @@ internal class Rygel.LiveResponse : Rygel.HTTPResponse {
this.msg.response_headers.set_encoding (Soup.Encoding.EOF);
- this.buffers = new AsyncQueue<Buffer> ();
-
this.prepare_pipeline (name, src);
this.time_range = time_range;
}
@@ -73,11 +70,11 @@ internal class Rygel.LiveResponse : Rygel.HTTPResponse {
public override void end (bool aborted, uint status) {
this.pipeline.set_state (State.NULL);
- // Flush the queue of buffers
- Buffer buffer = null;
- do {
- buffer = this.buffers.try_pop ();
- } while (buffer != null);
+
+ if (this.idle_id != 0) {
+ Source.remove (this.idle_id);
+ this.idle_id = 0;
+ }
if (!aborted) {
this.msg.response_body.complete ();
@@ -220,18 +217,14 @@ internal class Rygel.LiveResponse : Rygel.HTTPResponse {
private void on_new_buffer (Element sink,
Buffer buffer,
Pad pad) {
- this.buffers.push (buffer);
- Idle.add_full (Priority.HIGH_IDLE, this.idle_handler);
- }
-
- private bool idle_handler () {
- var buffer = this.buffers.try_pop ();
-
- if (buffer != null) {
+ this.idle_id = Idle.add_full (Priority.HIGH_IDLE,
+ () => {
this.push_data (buffer.data, buffer.size);
- }
- return false;
+ this.idle_id = 0;
+
+ return false;
+ });
}
private bool bus_handler (Gst.Bus bus,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]