]> code.delx.au - pulseaudio/blob - src/modules/alsa/module-alsa-source.c
Update PA_MODULE_USAGE to be in line with actual implementation
[pulseaudio] / src / modules / alsa / module-alsa-source.c
1 /***
2 This file is part of PulseAudio.
3
4 Copyright 2004-2008 Lennart Poettering
5 Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
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, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA.
21 ***/
22
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27 #include <stdio.h>
28
29 #include <asoundlib.h>
30
31 #ifdef HAVE_VALGRIND_MEMCHECK_H
32 #include <valgrind/memcheck.h>
33 #endif
34
35 #include <pulse/xmalloc.h>
36 #include <pulse/util.h>
37 #include <pulse/timeval.h>
38
39 #include <pulsecore/core-error.h>
40 #include <pulsecore/core-rtclock.h>
41 #include <pulsecore/core.h>
42 #include <pulsecore/module.h>
43 #include <pulsecore/memchunk.h>
44 #include <pulsecore/sink.h>
45 #include <pulsecore/modargs.h>
46 #include <pulsecore/core-util.h>
47 #include <pulsecore/sample-util.h>
48 #include <pulsecore/log.h>
49 #include <pulsecore/macro.h>
50 #include <pulsecore/thread.h>
51 #include <pulsecore/core-error.h>
52 #include <pulsecore/thread-mq.h>
53 #include <pulsecore/rtpoll.h>
54 #include <pulsecore/time-smoother.h>
55
56 #include "alsa-util.h"
57 #include "alsa-source.h"
58 #include "module-alsa-source-symdef.h"
59
60 PA_MODULE_AUTHOR("Lennart Poettering");
61 PA_MODULE_DESCRIPTION("ALSA Source");
62 PA_MODULE_VERSION(PACKAGE_VERSION);
63 PA_MODULE_LOAD_ONCE(FALSE);
64 PA_MODULE_USAGE(
65 "name=<name for the source, to be prefixed> "
66 "source_name=<name for the source> "
67 "source_properties=<properties for the source> "
68 "namereg_fail=<pa_namereg_register() fail parameter value> "
69 "device=<ALSA device> "
70 "device_id=<ALSA card index> "
71 "format=<sample format> "
72 "rate=<sample rate> "
73 "channels=<number of channels> "
74 "channel_map=<channel map> "
75 "fragments=<number of fragments> "
76 "fragment_size=<fragment size> "
77 "mmap=<enable memory mapping?> "
78 "tsched=<enable system timer based scheduling mode?> "
79 "tsched_buffer_size=<buffer size when using timer based scheduling> "
80 "tsched_buffer_watermark=<upper fill watermark> "
81 "ignore_dB=<ignore dB information from the device?> "
82 "control=<name of mixer control>");
83
84 static const char* const valid_modargs[] = {
85 "name",
86 "source_name",
87 "source_properties",
88 "namereg_fail",
89 "device",
90 "device_id",
91 "format",
92 "rate",
93 "channels",
94 "channel_map",
95 "fragments",
96 "fragment_size",
97 "mmap",
98 "tsched",
99 "tsched_buffer_size",
100 "tsched_buffer_watermark",
101 "ignore_dB",
102 "control",
103 NULL
104 };
105
106 int pa__init(pa_module*m) {
107 pa_modargs *ma = NULL;
108
109 pa_assert(m);
110
111 pa_alsa_refcnt_inc();
112
113 if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
114 pa_log("Failed to parse module arguments");
115 goto fail;
116 }
117
118 if (!(m->userdata = pa_alsa_source_new(m, ma, __FILE__, NULL, NULL)))
119 goto fail;
120
121 pa_modargs_free(ma);
122
123 return 0;
124
125 fail:
126
127 if (ma)
128 pa_modargs_free(ma);
129
130 pa__done(m);
131
132 return -1;
133 }
134
135 int pa__get_n_used(pa_module *m) {
136 pa_source *source;
137
138 pa_assert(m);
139 pa_assert_se(source = m->userdata);
140
141 return pa_source_linked_by(source);
142 }
143
144 void pa__done(pa_module*m) {
145 pa_source *source;
146
147 pa_assert(m);
148
149 if ((source = m->userdata))
150 pa_alsa_source_free(source);
151
152 pa_alsa_refcnt_dec();
153 }