]>
code.delx.au - pulseaudio/blob - src/modules/alsa/module-alsa-source.c
2 This file is part of PulseAudio.
4 Copyright 2004-2008 Lennart Poettering
5 Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
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 of the License,
10 or (at your option) any later version.
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.
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
29 #include <asoundlib.h>
31 #ifdef HAVE_VALGRIND_MEMCHECK_H
32 #include <valgrind/memcheck.h>
35 #include <pulse/xmalloc.h>
36 #include <pulse/util.h>
37 #include <pulse/timeval.h>
39 #include <pulsecore/core-error.h>
40 #include <pulsecore/core.h>
41 #include <pulsecore/module.h>
42 #include <pulsecore/memchunk.h>
43 #include <pulsecore/sink.h>
44 #include <pulsecore/modargs.h>
45 #include <pulsecore/core-util.h>
46 #include <pulsecore/sample-util.h>
47 #include <pulsecore/log.h>
48 #include <pulsecore/macro.h>
49 #include <pulsecore/thread.h>
50 #include <pulsecore/core-error.h>
51 #include <pulsecore/thread-mq.h>
52 #include <pulsecore/rtpoll.h>
53 #include <pulsecore/time-smoother.h>
54 #include <pulsecore/rtclock.h>
56 #include "alsa-util.h"
57 #include "alsa-source.h"
58 #include "module-alsa-source-symdef.h"
60 PA_MODULE_AUTHOR("Lennart Poettering");
61 PA_MODULE_DESCRIPTION("ALSA Source");
62 PA_MODULE_VERSION(PACKAGE_VERSION
);
63 PA_MODULE_LOAD_ONCE(FALSE
);
65 "name=<name for the source, to be prefixed> "
66 "source_name=<name for the source> "
67 "device=<ALSA device> "
68 "device_id=<ALSA card index> "
69 "format=<sample format> "
71 "channels=<number of channels> "
72 "channel_map=<channel map> "
73 "fragments=<number of fragments> "
74 "fragment_size=<fragment size> "
75 "mmap=<enable memory mapping?> "
76 "tsched=<enable system timer based scheduling mode?> "
77 "tsched_buffer_size=<buffer size when using timer based scheduling> "
78 "tsched_buffer_watermark=<upper fill watermark> "
79 "ignore_dB=<ignore dB information from the device?>");
81 static const char* const valid_modargs
[] = {
95 "tsched_buffer_watermark",
100 int pa__init(pa_module
*m
) {
101 pa_modargs
*ma
= NULL
;
105 pa_alsa_redirect_errors_inc();
106 snd_config_update_free_global();
108 if (!(ma
= pa_modargs_new(m
->argument
, valid_modargs
))) {
109 pa_log("Failed to parse module arguments");
113 if (!(m
->userdata
= pa_alsa_source_new(m
, ma
, __FILE__
, NULL
, NULL
)))
130 int pa__get_n_used(pa_module
*m
) {
134 pa_assert_se(source
= m
->userdata
);
136 return pa_source_linked_by(source
);
139 void pa__done(pa_module
*m
) {
144 if ((source
= m
->userdata
))
145 pa_alsa_source_free(source
);
147 snd_config_update_free_global();
148 pa_alsa_redirect_errors_dec();