]> code.delx.au - pulseaudio/blob - src/modules/alsa/module-alsa-sink.c
alsa-mixer: Add special profiles for some laptops missing speaker and/or internal mic
[pulseaudio] / src / modules / alsa / module-alsa-sink.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 <pulsecore/module.h>
28 #include <pulsecore/sink.h>
29 #include <pulsecore/modargs.h>
30
31 #include "alsa-util.h"
32 #include "alsa-sink.h"
33 #include "module-alsa-sink-symdef.h"
34
35 PA_MODULE_AUTHOR("Lennart Poettering");
36 PA_MODULE_DESCRIPTION("ALSA Sink");
37 PA_MODULE_VERSION(PACKAGE_VERSION);
38 PA_MODULE_LOAD_ONCE(FALSE);
39 PA_MODULE_USAGE(
40 "name=<name of the sink, to be prefixed> "
41 "sink_name=<name for the sink> "
42 "sink_properties=<properties for the sink> "
43 "namereg_fail=<when false attempt to synthesise new sink_name if it is already taken> "
44 "device=<ALSA device> "
45 "device_id=<ALSA card index> "
46 "format=<sample format> "
47 "rate=<sample rate> "
48 "alternate_rate=<alternate sample rate> "
49 "channels=<number of channels> "
50 "channel_map=<channel map> "
51 "fragments=<number of fragments> "
52 "fragment_size=<fragment size> "
53 "mmap=<enable memory mapping?> "
54 "tsched=<enable system timer based scheduling mode?> "
55 "tsched_buffer_size=<buffer size when using timer based scheduling> "
56 "tsched_buffer_watermark=<lower fill watermark> "
57 "ignore_dB=<ignore dB information from the device?> "
58 "control=<name of mixer control> "
59 "rewind_safeguard=<number of bytes that cannot be rewound> "
60 "deferred_volume=<Synchronize software and hardware volume changes to avoid momentary jumps?> "
61 "deferred_volume_safety_margin=<usec adjustment depending on volume direction> "
62 "deferred_volume_extra_delay=<usec adjustment to HW volume changes> "
63 "fixed_latency_range=<disable latency range changes on underrun?>");
64
65 static const char* const valid_modargs[] = {
66 "name",
67 "sink_name",
68 "sink_properties",
69 "namereg_fail",
70 "device",
71 "device_id",
72 "format",
73 "rate",
74 "alternate_rate",
75 "channels",
76 "channel_map",
77 "fragments",
78 "fragment_size",
79 "mmap",
80 "tsched",
81 "tsched_buffer_size",
82 "tsched_buffer_watermark",
83 "ignore_dB",
84 "control",
85 "rewind_safeguard",
86 "deferred_volume",
87 "deferred_volume_safety_margin",
88 "deferred_volume_extra_delay",
89 "fixed_latency_range",
90 NULL
91 };
92
93 int pa__init(pa_module*m) {
94 pa_modargs *ma = NULL;
95
96 pa_assert(m);
97
98 pa_alsa_refcnt_inc();
99
100 if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
101 pa_log("Failed to parse module arguments");
102 goto fail;
103 }
104
105 if (!(m->userdata = pa_alsa_sink_new(m, ma, __FILE__, NULL, NULL)))
106 goto fail;
107
108 pa_modargs_free(ma);
109
110 return 0;
111
112 fail:
113
114 if (ma)
115 pa_modargs_free(ma);
116
117 pa__done(m);
118
119 return -1;
120 }
121
122 int pa__get_n_used(pa_module *m) {
123 pa_sink *sink;
124
125 pa_assert(m);
126 pa_assert_se(sink = m->userdata);
127
128 return pa_sink_linked_by(sink);
129 }
130
131 void pa__done(pa_module*m) {
132 pa_sink *sink;
133
134 pa_assert(m);
135
136 if ((sink = m->userdata))
137 pa_alsa_sink_free(sink);
138
139 pa_alsa_refcnt_dec();
140 }