1/*** 2 This file is part of PulseAudio. 3 4 Copyright 2004-2006 Lennart Poettering 5 Copyright 2008 Colin Guthrie 6 7 PulseAudio is free software; you can redistribute it and/or modify 8 it under the terms of the GNU Lesser General Public License as published 9 by the Free Software Foundation; either version 2.1 of the License, 10 or (at your option) any later version. 11 12 PulseAudio is distributed in the hope that it will be useful, but 13 WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 General Public License for more details. 16 17 You should have received a copy of the GNU Lesser General Public License 18 along with PulseAudio; if not, see <http://www.gnu.org/licenses/>. 19***/ 20 21#ifdef HAVE_CONFIG_H 22#include <config.h> 23#endif 24 25#include <pulsecore/module.h> 26#include <pulsecore/sink.h> 27#include <pulsecore/modargs.h> 28 29#include "raop-sink.h" 30 31PA_MODULE_AUTHOR("Colin Guthrie"); 32PA_MODULE_DESCRIPTION("RAOP Sink"); 33PA_MODULE_VERSION(PACKAGE_VERSION); 34PA_MODULE_LOAD_ONCE(false); 35PA_MODULE_USAGE( 36 "name=<name of the sink, to be prefixed> " 37 "sink_name=<name for the sink> " 38 "sink_properties=<properties for the sink> " 39 "server=<address> " 40 "protocol=<transport protocol> " 41 "encryption=<encryption type> " 42 "codec=<audio codec> " 43 "format=<sample format> " 44 "rate=<sample rate> " 45 "channels=<number of channels> " 46 "username=<authentication user name, default: \"iTunes\"> " 47 "password=<authentication password> " 48 "latency_msec=<audio latency>"); 49 50static const char* const valid_modargs[] = { 51 "name", 52 "sink_name", 53 "sink_properties", 54 "server", 55 "protocol", 56 "encryption", 57 "codec", 58 "format", 59 "rate", 60 "channels", 61 "channel_map", 62 "username", 63 "password", 64 "latency_msec", 65 "autoreconnect", 66 NULL 67}; 68 69int pa__init(pa_module *m) { 70 pa_modargs *ma = NULL; 71 72 pa_assert(m); 73 74 if (!(ma = pa_modargs_new(m->argument, valid_modargs))) { 75 pa_log("Failed to parse module arguments"); 76 goto fail; 77 } 78 79 if (!(m->userdata = pa_raop_sink_new(m, ma, __FILE__))) 80 goto fail; 81 82 pa_modargs_free(ma); 83 84 return 0; 85 86fail: 87 88 if (ma) 89 pa_modargs_free(ma); 90 91 pa__done(m); 92 93 return -1; 94} 95 96int pa__get_n_used(pa_module *m) { 97 pa_sink *sink; 98 99 pa_assert(m); 100 pa_assert_se(sink = m->userdata); 101 102 return pa_sink_linked_by(sink); 103} 104 105void pa__done(pa_module *m) { 106 pa_sink *sink; 107 108 pa_assert(m); 109 110 if ((sink = m->userdata)) 111 pa_raop_sink_free(sink); 112} 113