]> code.delx.au - pulseaudio/blobdiff - polyp/module-oss-mmap.c
Make the whole stuff LGPL only
[pulseaudio] / polyp / module-oss-mmap.c
index 8151a13af347fd043a406a8f9bc13a17c729aa9f..8aecd560243820c1e54d3c9b0f34eab5eb63defc 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 "modargs.h"
 #include "xmalloc.h"
 #include "log.h"
+#include "module-oss-mmap-symdef.h"
+
+PA_MODULE_AUTHOR("Lennart Poettering")
+PA_MODULE_DESCRIPTION("OSS Sink/Source (mmap)")
+PA_MODULE_VERSION(PACKAGE_VERSION)
+PA_MODULE_USAGE("sink_name=<name for the sink> source_name=<name for the source> device=<OSS device> record=<enable source?> playback=<enable sink?> format=<sample format> channels=<number of channels> rate=<sample rate> fragments=<number of fragments> fragment_size=<fragment size>")
 
 struct userdata {
     struct pa_sink *sink;
@@ -206,7 +212,7 @@ static void io_callback(struct pa_mainloop_api *m, 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) {
     struct userdata *u = s->userdata;
     assert(s && u);
 
@@ -214,7 +220,7 @@ static uint32_t sink_get_latency_cb(struct pa_sink *s) {
     return pa_bytes_to_usec(u->out_fill, &s->sample_spec);
 }
 
-int pa_module_init(struct pa_core *c, struct pa_module*m) {
+int pa__init(struct pa_core *c, struct pa_module*m) {
     struct audio_buf_info info;
     struct userdata *u = NULL;
     const char *p;
@@ -249,7 +255,7 @@ int pa_module_init(struct pa_core *c, struct pa_module*m) {
 
     nfrags = 12;
     frag_size = 1024;
-    if (pa_modargs_get_value_s32(ma, "fragments", &nfrags) < 0 || nfrags < 2 || pa_modargs_get_value_s32(ma, "fragment_size", &frag_size) < 0 || frag_size < 1) {
+    if (pa_modargs_get_value_s32(ma, "fragments", &nfrags) < 0 || pa_modargs_get_value_s32(ma, "fragment_size", &frag_size) < 0) {
         pa_log(__FILE__": failed to parse fragments arguments\n");
         goto fail;
     }
@@ -269,9 +275,10 @@ int pa_module_init(struct pa_core *c, struct pa_module*m) {
     }
 
     pa_log(__FILE__": device opened in %s mode.\n", mode == O_WRONLY ? "O_WRONLY" : (mode == O_RDONLY ? "O_RDONLY" : "O_RDWR"));
-    
-    if (pa_oss_set_fragments(u->fd, nfrags, frag_size) < 0)
-        goto fail;
+
+    if (nfrags >= 2 && frag_size >= 1)
+        if (pa_oss_set_fragments(u->fd, nfrags, frag_size) < 0)
+            goto fail;
     
     if (pa_oss_auto_format(u->fd, &u->sample_spec) < 0)
         goto fail;
@@ -361,7 +368,7 @@ int pa_module_init(struct pa_core *c, struct pa_module*m) {
     return 0;
 
 fail:
-    pa_module_done(c, m);
+    pa__done(c, m);
 
     if (ma)
         pa_modargs_free(ma);
@@ -369,7 +376,7 @@ fail:
     return -1;
 }
 
-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);
 
@@ -398,11 +405,15 @@ void pa_module_done(struct pa_core *c, struct pa_module*m) {
     if (u->out_mmap && u->out_mmap != MAP_FAILED)
         munmap(u->out_mmap, u->out_mmap_length);
     
-    if (u->sink)
-        pa_sink_free(u->sink);
+    if (u->sink) {
+        pa_sink_disconnect(u->sink);
+        pa_sink_unref(u->sink);
+    }
 
-    if (u->source)
-        pa_source_free(u->source);
+    if (u->source) {
+        pa_source_disconnect(u->source);
+        pa_source_unref(u->source);
+    }
 
     if (u->io_event)
         u->core->mainloop->io_free(u->io_event);