summaryrefslogtreecommitdiff
path: root/cras/README.dbus-api
blob: f347358e0aff812825854f024e37137899a90da4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
CRAS dbus methods and signals.
==============================

Service		org.chromium.cras
Interface	org.chromium.cras.Control
Object Path	/org/chromium/cras

Methods		void SetOutputVolume(int32 volume)

			Sets the volume of the system.  Volume ranges from
			0 to 100, and will be translated to dB based on the
			output-specific volume curve.

		void SetOutputNodeVolume(uint64 node_id, int32 volume)

			Sets the volume of the given node.  Volume ranges from
			0 to 100, and will be translated to dB based on the
			output-specific volume curve.

		void SwapLeftRight(uint64 node_id, boolean swap)

			Swap the left and right channel of the given node.
			Message will be dropped if this feature is not supported.

		void SetOutputMute(boolean mute_on)

			Sets the system output mute.

		void SetOutputUserMute(boolean mute_on)

			Sets the system output mute from user action.

		void SetInputNodeGain(uint64 node_id, int32 gain)

			Sets the capture gain of the node. gain is a 0-100
			integer which linearly maps [0, 50] to range [-40dB, 0dB]
			and [50, 100] to [0dB, 20dB],
			Default gain value is 50, which is 0dB.

		void SetInputMute(boolean mute_on)

			Sets the capture mute state of the system.  Recordings
			will be muted when this is set.

		void GetVolumeState()

			Returns the volume and capture gain as follows:
				int32 output_volume (0-100)
				boolean output_mute
				int32 input_gain (in dBFS * 100)
				boolean input_mute
				boolean output_user_mute

		void GetDefaultOutputBufferSize()

			Returns the default output buffer size in frames.

		{dict},{dict},... GetNodes()

			Returns information about nodes. A node can be either
			output or input but not both. An output node is
			something like a speaker or a headphone, and an input
			node is like a microphone.  The return value is a
			sequence of dicts mapping from strings to variants
			(e.g. signature "a{sv}a{sv}" for two nodes).  Each dict
			contains information about a node.

			Each dict contains the following properties:
				boolean IsInput
					false for output nodes, true for input
					nodes.
				uint64 Id
					The id of this node. It is unique among
					all nodes including both output and
					input nodes.
				string Type
				        The type of this node. It can be one of
				        following values:
					/* for output nodes. */
					"INTERNAL_SPEAKER","HEADPHONE", "HDMI",
					/* for input nodes. */
					"INTERNAL_MIC", "MIC",
					/* for both output and input nodes. */
					"USB", "BLUETOOTH", "UNKNOWN",
				string Name
					The name of this node. For example,
					"Speaker" or "Internal Mic".
				string DeviceName
					The name of the device that this node
					belongs to. For example,
					"HDA Intel PCH: CA0132 Analog:0,0" or
					"Creative SB Arena Headset".
				uint64 StableDeviceId
					The stable ID does not change due to
					device plug/unplug or reboot.
				uint64 StableDeviceIdNew
					The new stable ID. Keeping both stable
					ID and stable ID new is for backward
					compatibility.
				boolean Active
					Whether this node is currently used
					for output/input. There is one active
					node for output and one active node for
					input.
				uint64 PluggedTime
					The time that this device was plugged
					in. This value is in microseconds.
				unit64 NodeVolume
					The node volume indexed from 0 to 100.
				unit64 NodeCaptureGain
					The capture gain of node in dBFS * 100.
				string HotwordModels
					A string of comma-separated hotword
					language model locales supported by this
					node. e.g. "en_au,en_gb,en_us"
					The string is empty if the node type is
					not HOTWORD.

		void GetSystemAecSupported();

			Returns 1 if system echo cancellation is supported,
			otherwise return 0.

		void SetActiveOutputNode(uint64 node_id);

			Requests the specified node to be used for
			output. If node_id is 0 (which is not a valid
			node id), cras will choose the active node
			automatically.

		void SetActiveInputNode(uint64 node_id);

			Requests the specified node to be used for
			input. If node_id is 0 (which is not a valid
			node id), cras will choose the active node
			automatically.

		int32 GetNumberOfActiveStreams()

			Returns the number of streams currently being
			played or recorded.

		int32 GetNumberOfActiveInputStreams()

			Returns the number of streams currently using input hardware.

		int32 GetNumberOfActiveOutputStreams()

			Returns the number of streams currently using output hardware.

		int32 IsAudioOutputActive()

			Returns 1 if there are currently any active output streams,
			excluding 'fake' streams that are not actually outputting any
			audio. Returns 0 if there are no active streams, or all active
			streams are 'fake' streams.

		void SetGlobalOutputChannelRemix(int32 num_channels,
						 array:double coefficient)

			Sets the conversion matrix for global output channel
			remixing. The coefficient array represents an N * N
			conversion matrix M, where N is num_channels, with
			M[i][j] = coefficient[i * N + j].
			The remix is done by multiplying the conversion matrix
			to each N-channel PCM data, i.e M * [L, R] = [L', R']
			For example, coefficient [0.1, 0.9, 0.4, 0.6] will
			result in:
			L' = 0.1 * L + 0.9 * R
			R' = 0.4 * L + 0.6 * R

		int32 SetHotwordModel(uint64_t node_id, string model_name)

			Set the hotword language model on the specified node.
			The node must have type HOTWORD and the model_name must
			be one of the supported locales returned by
			GetNodes() HotwordModels string.
			Returns 0 on success, or a negative errno on failure.

Signals		OutputVolumeChanged(int32 volume)

			Indicates that the output volume level has changed.

		OutputMuteChanged(boolean muted, boolean user_muted)

			Indicates that the output mute state has changed.  muted
			is true if the system is muted by a system process, such
			as suspend or device switch.  user_muted is set if the
			system has been muted by user action such as the mute
			key.

		InputGainChanged(int32 gain)

			Indicates what the system capture gain is now. gain
			expressed in dBFS*100.

		InputMuteChanged(boolean muted)

			Indicates that the input mute state has changed.

		NodesChanged()

			Indicates that nodes are added/removed.

		ActiveOutputNodeChanged(uint64 node_id)

			Indicates that the active output node has changed.

		ActiveInputNodeChanged(uint64 node_id)

			Indicates that the active input node has changed.

		OutputNodeVolumeChanged(uint64 node_id, int32 volume)

			Indicates the volume of the given node.

		NodeLeftRightSwappedChanged(uint64 node_id, boolean swapped)

			Indicates the left and right channel swapping state of the
			given node.

		InputNodeGainChanged(uint64 node_id, int32 gain)

			Indicates that the capture gain for the node is now gain
			expressed in dBFS*100.

		NumberOfActiveStreamsChanged(int32 num_active_streams)

			Indicates the number of active streams has changed.

		AudioOutputActiveStateChanged(boolean active)

			Indicates active output state has changed.
			See IsAudioOutputActive for details.

		HotwordTriggered(int64 tv_sec, int64 tv_nsec)

			Indicates that hotword was triggered at the given timestamp.