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
|
/*
* Copyright (C) 2012 Paul Kocialkowski <contact@paulk.fr>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TINYALSA_AUDIO_MIXER_H
#define TINYALSA_AUDIO_MIXER_H
#include <tinyalsa/asoundlib.h>
#include <hardware/audio.h>
#include <system/audio.h>
#define TINYALSA_MIXER_CONFIG_FILE "/system/etc/tinyalsa-audio.xml"
struct list_head {
struct list_head *prev;
struct list_head *next;
void *data;
};
enum tinyalsa_mixer_data_type {
MIXER_DATA_TYPE_CTRL,
MIXER_DATA_TYPE_WRITE,
MIXER_DATA_TYPE_MAX
};
struct tinyalsa_mixer_data {
enum tinyalsa_mixer_data_type type;
char *name;
char *value;
char *attr;
};
struct tinyalsa_mixer_device_props {
audio_devices_t type;
};
struct tinyalsa_mixer_device {
struct tinyalsa_mixer_device_props props;
struct list_head *enable;
struct list_head *disable;
};
struct tinyalsa_mixer_io_props {
int card;
int device;
int rate;
audio_channel_mask_t channel_mask;
audio_format_t format;
int period_size;
int period_count;
};
struct tinyalsa_mixer_io {
struct tinyalsa_mixer_io_props props;
struct tinyalsa_mixer_device *device_current;
struct list_head *devices;
int state;
};
struct tinyalsa_mixer {
struct tinyalsa_mixer_io output;
struct tinyalsa_mixer_io input;
struct tinyalsa_mixer_io modem;
struct mixer *mixer;
};
enum tinyalsa_mixer_direction {
TINYALSA_MIXER_DIRECTION_OUTPUT,
TINYALSA_MIXER_DIRECTION_INPUT,
TINYALSA_MIXER_DIRECTION_MODEM,
TINYALSA_MIXER_DIRECTION_MAX
};
struct tinyalsa_mixer_config_data {
struct tinyalsa_mixer *mixer;
struct tinyalsa_mixer_io_props io_props;
struct tinyalsa_mixer_device_props device_props;
enum tinyalsa_mixer_direction direction;
struct tinyalsa_mixer_device *device;
struct list_head **list_start;
struct list_head *list;
};
int tinyalsa_mixer_set_output_state(struct tinyalsa_mixer *mixer, int state);
int tinyalsa_mixer_set_input_state(struct tinyalsa_mixer *mixer, int state);
int tinyalsa_mixer_set_modem_state(struct tinyalsa_mixer *mixer, int state);
int tinyalsa_mixer_set_device(struct tinyalsa_mixer *mixer, audio_devices_t device);
int tinyalsa_mixer_set_output_volume(struct tinyalsa_mixer *mixer,
audio_devices_t device, float volume);
int tinyalsa_mixer_set_master_volume(struct tinyalsa_mixer *mixer, float volume);
int tinyalsa_mixer_set_mic_mute(struct tinyalsa_mixer *mixer,
audio_devices_t device, int mute);
int tinyalsa_mixer_set_input_gain(struct tinyalsa_mixer *mixer,
audio_devices_t device, float gain);
int tinyalsa_mixer_set_voice_volume(struct tinyalsa_mixer *mixer,
audio_devices_t device, float volume);
struct tinyalsa_mixer_io_props *tinyalsa_mixer_get_output_props(struct tinyalsa_mixer *mixer);
struct tinyalsa_mixer_io_props *tinyalsa_mixer_get_input_props(struct tinyalsa_mixer *mixer);
struct tinyalsa_mixer_io_props *tinyalsa_mixer_get_modem_props(struct tinyalsa_mixer *mixer);
void tinyalsa_mixer_close(struct tinyalsa_mixer *mixer);
int tinyalsa_mixer_open(struct tinyalsa_mixer **mixer_p, char *config_file);
#endif
|