]> code.delx.au - pulseaudio/blobdiff - polyp/protocol-simple.c
Make the whole stuff LGPL only
[pulseaudio] / polyp / protocol-simple.c
index 00db0aa054936a960f649a45c25f329f1973ba14..f7c69d6b4cd5d23f2593f2df7333c6957895b1ac 100644 (file)
@@ -4,7 +4,7 @@
   This file is part of polypaudio.
  
   polypaudio is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published
+  it under the terms of the GNU Lesser General Public License as published
   by the Free Software Foundation; either version 2 of the License,
   or (at your option) any later version.
  
@@ -13,7 +13,7 @@
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   General Public License for more details.
  
-  You should have received a copy of the GNU General Public License
+  You should have received a copy of the GNU Lesser General Public License
   along with polypaudio; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
@@ -80,10 +80,14 @@ static void connection_free(struct connection *c) {
 
     if (c->playback.current_memblock)
         pa_memblock_unref(c->playback.current_memblock);
-    if (c->sink_input)
-        pa_sink_input_free(c->sink_input);
-    if (c->source_output)
-        pa_source_output_free(c->source_output);
+    if (c->sink_input) {
+        pa_sink_input_disconnect(c->sink_input);
+        pa_sink_input_unref(c->sink_input);
+    }
+    if (c->source_output) {
+        pa_source_output_disconnect(c->source_output);
+        pa_source_output_unref(c->source_output);
+    }
     if (c->client)
         pa_client_free(c->client);
     if (c->io)
@@ -244,6 +248,12 @@ static void source_output_kill_cb(struct pa_source_output *o) {
     connection_free((struct connection *) o->userdata);
 }
 
+static pa_usec_t source_output_get_latency_cb(struct pa_source_output *o) {
+    struct connection*c = o->userdata;
+    assert(o && c);
+    return pa_bytes_to_usec(pa_memblockq_get_length(c->output_memblockq), &c->source_output->sample_spec);
+}
+
 /*** client callbacks ***/
 
 static void client_kill_cb(struct pa_client *c) {
@@ -304,7 +314,7 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
             goto fail;
         }
 
-        if (!(c->sink_input = pa_sink_input_new(sink, c->client->name, &p->sample_spec))) {
+        if (!(c->sink_input = pa_sink_input_new(sink, c->client->name, &p->sample_spec, 0, -1))) {
             pa_log(__FILE__": Failed to create sink input.\n");
             goto fail;
         }
@@ -334,7 +344,7 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
             goto fail;
         }
 
-        c->source_output = pa_source_output_new(source, c->client->name, &p->sample_spec);
+        c->source_output = pa_source_output_new(source, c->client->name, &p->sample_spec, -1);
         if (!c->source_output) {
             pa_log(__FILE__": Failed to create source output.\n");
             goto fail;
@@ -344,6 +354,7 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
         
         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;
         c->source_output->userdata = c;
 
         l = (size_t) (pa_bytes_per_second(&p->sample_spec)*RECORD_BUFFER_SECONDS);