summaryrefslogtreecommitdiff
path: root/cras/src/server/cras_alsa_mixer_name.h
blob: 67f8e9e33f6da5529f162f4698e4a4b673996c96 (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
/* Copyright 2016 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef _CRAS_ALSA_MIXER_NAME_H
#define _CRAS_ALSA_MIXER_NAME_H

#include "cras_types.h"

#ifdef __cplusplus
extern "C" {
#endif

/* Type of mixer control. */
typedef enum mixer_name_type {
	MIXER_NAME_UNDEFINED,
	MIXER_NAME_MAIN_VOLUME,
	MIXER_NAME_VOLUME,
} mixer_name_type;

/* Represents a list of mixer names found in ALSA. */
struct mixer_name {
	const char *name;
	enum CRAS_STREAM_DIRECTION dir;
	mixer_name_type type;
	struct mixer_name *prev, *next;
};

/* Add a name to the list.
 *
 * Args:
 *    names - A list of controls (may be NULL).
 *    name - The name to add.
 *    dir - The direction for this control.
 *    type - The type control being added.
 *
 * Returns:
 *    Returns the new head of the list (which changes only
 *    when names is NULL).
 */
struct mixer_name *mixer_name_add(struct mixer_name *names, const char *name,
				  enum CRAS_STREAM_DIRECTION dir,
				  mixer_name_type type);

/* Add an array of name to the list.
 *
 * Args:
 *    names - A list of controls (may be NULL).
 *    name_array - The names to add.
 *    name_array_size - The size of name_array.
 *    dir - The direction for these controls.
 *    type - The type controls being added.
 *
 * Returns:
 *    Returns the new head of the list (which changes only
 *    when names is NULL).
 */
struct mixer_name *mixer_name_add_array(struct mixer_name *names,
					const char *const *name_array,
					size_t name_array_size,
					enum CRAS_STREAM_DIRECTION dir,
					mixer_name_type type);

/* Frees a list of names.
 *
 * Args:
 *    names - A list of names.
 */
void mixer_name_free(struct mixer_name *names);

/* Find the mixer_name for the given direction, name, and type.
 *
 * Args:
 *    names - A list of names (may be NULL).
 *    name - The name to find, or NULL to match by type.

 *    dir - The direction to match.
 *    type - The type to match, or MIXER_NAME_UNDEFINED to
 *           match by name only.
 *
 * Returns:
 *    Returns a pointer to the matching struct mixer_name or NULL if
 *    not found.
 */
struct mixer_name *mixer_name_find(struct mixer_name *names, const char *name,
				   enum CRAS_STREAM_DIRECTION dir,
				   mixer_name_type type);

/* Dump the list of mixer names to DEBUG logs.
 *
 * Args:
 *    names - A list of names to dump.
 *    message - A message to print beforehand.
 */
void mixer_name_dump(struct mixer_name *names, const char *message);

#ifdef __cplusplus
}
#endif

#endif /* _CRAS_ALSA_MIXER_NAME_H */