]> code.delx.au - pulseaudio/blobdiff - polyp/module-alsa-sink.c
Make the whole stuff LGPL only
[pulseaudio] / polyp / module-alsa-sink.c
index 9c75ff98260048781e6497a274181a31800a6002..a708329d25c47a13e39d373fc4d62b83d7dd3879 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.
 #include "alsa-util.h"
 #include "xmalloc.h"
 #include "log.h"
+#include "module-alsa-sink-symdef.h"
+
+PA_MODULE_AUTHOR("Lennart Poettering")
+PA_MODULE_DESCRIPTION("ALSA Sink")
+PA_MODULE_VERSION(PACKAGE_VERSION)
+PA_MODULE_USAGE("sink_name=<name for the sink> device=<ALSA device> format=<sample format> channels=<number of channels> rate=<sample rate> fragments=<number of fragments> fragment_size=<fragment size>")
 
 struct userdata {
     snd_pcm_t *pcm_handle;
@@ -139,7 +145,8 @@ static void io_callback(struct pa_mainloop_api*a, struct pa_io_event *e, int fd,
     do_write(u);
 }
 
-static uint32_t sink_get_latency_cb(struct pa_sink *s) {
+static pa_usec_t sink_get_latency_cb(struct pa_sink *s) {
+    pa_usec_t r = 0;
     struct userdata *u = s->userdata;
     snd_pcm_sframes_t frames;
     assert(s && u && u->sink);
@@ -153,10 +160,15 @@ static uint32_t sink_get_latency_cb(struct pa_sink *s) {
     if (frames < 0)
         frames = 0;
     
-    return pa_bytes_to_usec(frames * u->frame_size, &s->sample_spec);
+    r += pa_bytes_to_usec(frames * u->frame_size, &s->sample_spec);
+
+    if (u->memchunk.memblock)
+        r += pa_bytes_to_usec(u->memchunk.length, &s->sample_spec);
+
+    return r;
 }
 
-int pa_module_init(struct pa_core *c, struct pa_module*m) {
+int pa__init(struct pa_core *c, struct pa_module*m) {
     struct pa_modargs *ma = NULL;
     int ret = -1;
     struct userdata *u = NULL;
@@ -237,20 +249,22 @@ finish:
 fail:
     
     if (u)
-        pa_module_done(c, m);
+        pa__done(c, m);
 
     goto finish;
 }
 
-void pa_module_done(struct pa_core *c, struct pa_module*m) {
+void pa__done(struct pa_core *c, struct pa_module*m) {
     struct userdata *u;
     assert(c && m);
 
     if (!(u = m->userdata))
         return;
     
-    if (u->sink)
-        pa_sink_free(u->sink);
+    if (u->sink) {
+        pa_sink_disconnect(u->sink);
+        pa_sink_unref(u->sink);
+    }
     
     if (u->io_events)
         pa_free_io_events(c->mainloop, u->io_events, u->n_io_events);