]> code.delx.au - pulseaudio/blobdiff - src/modules/module-native-protocol-fd.c
alsa: Allow channel count probe on open by mapping
[pulseaudio] / src / modules / module-native-protocol-fd.c
index 53f4189603f64e37456d28761b223f3f74426e1c..7021a26b9b1af97faf2496342e0adc3d402c8eba 100644 (file)
@@ -1,5 +1,3 @@
-/* $Id$ */
-
 /***
   This file is part of PulseAudio.
 
@@ -7,7 +5,7 @@
 
   PulseAudio is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published
-  by the Free Software Foundation; either version 2 of the License,
+  by the Free Software Foundation; either version 2.1 of the License,
   or (at your option) any later version.
 
   PulseAudio is distributed in the hope that it will be useful, but
@@ -44,15 +42,15 @@ PA_MODULE_LOAD_ONCE(TRUE);
 
 static const char* const valid_modargs[] = {
     "fd",
-    "public",
-    "cookie",
     NULL,
 };
 
 int pa__init(pa_module*m) {
     pa_iochannel *io;
     pa_modargs *ma;
-    int fd, r = -1;
+    int32_t fd = -1;
+    int r = -1;
+    pa_native_options *options = NULL;
 
     pa_assert(m);
 
@@ -61,17 +59,20 @@ int pa__init(pa_module*m) {
         goto finish;
     }
 
-    if (pa_modargs_get_value_s32(ma, "fd", &fd) < 0) {
+    if (pa_modargs_get_value_s32(ma, "fd", &fd) < 0 || fd < 0) {
         pa_log("Invalid file descriptor.");
         goto finish;
     }
 
+    m->userdata = pa_native_protocol_get(m->core);
+
     io = pa_iochannel_new(m->core->mainloop, fd, fd);
 
-    if (!(m->userdata = pa_protocol_native_new_iochannel(m->core, io, m, ma))) {
-        pa_iochannel_free(io);
-        goto finish;
-    }
+    options = pa_native_options_new();
+    options->module = m;
+    options->auth_anonymous = TRUE;
+
+    pa_native_protocol_connect(m->userdata, io, options);
 
     r = 0;
 
@@ -79,11 +80,17 @@ finish:
     if (ma)
         pa_modargs_free(ma);
 
+    if (options)
+        pa_native_options_unref(options);
+
     return r;
 }
 
 void pa__done(pa_module*m) {
     pa_assert(m);
 
-    pa_protocol_native_free(m->userdata);
+    if (m->userdata) {
+        pa_native_protocol_disconnect(m->userdata, m);
+        pa_native_protocol_unref(m->userdata);
+    }
 }