OSDN Git Service

Better names for control API
[android-x86/external-alsa-lib.git] / include / mixer.h
1 /****************************************************************************
2  *                                                                          *
3  *                               mixer.h                                    *
4  *                           Mixer Interface                                *
5  *                                                                          *
6  ****************************************************************************/
7
8 typedef struct _snd_mixer snd_mixer_t;
9
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13
14 int snd_mixer_open(snd_mixer_t **handle, char *name);
15 int snd_mixer_close(snd_mixer_t *handle);
16 int snd_mixer_card(snd_mixer_t *handle);
17 int snd_mixer_poll_descriptor(snd_mixer_t *handle);
18
19 #ifdef __cplusplus
20 }
21 #endif
22
23 /*
24  *  Simple (legacy) mixer API
25  */
26
27 enum _snd_mixer_channel_id {
28         SND_MIXER_CHN_UNKNOWN = -1,
29         SND_MIXER_CHN_FRONT_LEFT = 0,
30         SND_MIXER_CHN_FRONT_RIGHT,
31         SND_MIXER_CHN_FRONT_CENTER,
32         SND_MIXER_CHN_REAR_LEFT,
33         SND_MIXER_CHN_REAR_RIGHT,
34         SND_MIXER_CHN_WOOFER,
35         SND_MIXER_CHN_LAST = 31,
36         SND_MIXER_CHN_MONO = SND_MIXER_CHN_FRONT_LEFT
37 };
38
39 #ifdef SND_ENUM_TYPECHECK
40 typedef struct __snd_mixer_channel_id *snd_mixer_channel_id_t;
41 #else
42 typedef enum _snd_mixer_channel_id snd_mixer_channel_id_t;
43 #endif
44
45 #define SND_MIXER_CHN_UNKNOWN ((snd_mixer_channel_id_t) SND_MIXER_CHN_UNKNOWN)
46 #define SND_MIXER_CHN_FRONT_LEFT ((snd_mixer_channel_id_t) SND_MIXER_CHN_FRONT_LEFT)
47 #define SND_MIXER_CHN_FRONT_RIGHT ((snd_mixer_channel_id_t) SND_MIXER_CHN_FRONT_RIGHT)
48 #define SND_MIXER_CHN_FRONT_CENTER ((snd_mixer_channel_id_t) SND_MIXER_CHN_FRONT_CENTER)
49 #define SND_MIXER_CHN_REAR_LEFT ((snd_mixer_channel_id_t) SND_MIXER_CHN_REAR_LEFT)
50 #define SND_MIXER_CHN_REAR_RIGHT ((snd_mixer_channel_id_t) SND_MIXER_CHN_REAR_RIGHT)
51 #define SND_MIXER_CHN_WOOFER ((snd_mixer_channel_id_t) SND_MIXER_CHN_WOOFER)
52 #define SND_MIXER_CHN_LAST ((snd_mixer_channel_id_t) SND_MIXER_CHN_LAST)
53 #define SND_MIXER_CHN_MONO ((snd_mixer_channel_id_t) SND_MIXER_CHN_MONO)
54
55 #define SND_MIXER_CHN_MASK_MONO         (1<<snd_enum_to_int(SND_MIXER_CHN_MONO))
56 #define SND_MIXER_CHN_MASK_FRONT_LEFT   (1<<snd_enum_to_int(SND_MIXER_CHN_FRONT_LEFT))
57 #define SND_MIXER_CHN_MASK_FRONT_RIGHT  (1<<snd_enum_to_int(SND_MIXER_CHN_FRONT_RIGHT))
58 #define SND_MIXER_CHN_MASK_FRONT_CENTER (1<<snd_enum_to_int(SND_MIXER_CHN_FRONT_CENTER))
59 #define SND_MIXER_CHN_MASK_REAR_LEFT    (1<<snd_enum_to_int(SND_MIXER_CHN_REAR_LEFT))
60 #define SND_MIXER_CHN_MASK_REAR_RIGHT   (1<<snd_enum_to_int(SND_MIXER_CHN_REAR_RIGHT))
61 #define SND_MIXER_CHN_MASK_WOOFER       (1<<snd_enum_to_int(SND_MIXER_CHN_WOOFER))
62 #define SND_MIXER_CHN_MASK_STEREO       (SND_MIXER_CHN_MASK_FRONT_LEFT|SND_MIXER_CHN_MASK_FRONT_RIGHT)
63
64 #define SND_MIXER_SCTCAP_VOLUME         (1<<0)
65 #define SND_MIXER_SCTCAP_JOINTLY_VOLUME (1<<1)
66 #define SND_MIXER_SCTCAP_MUTE           (1<<2)
67 #define SND_MIXER_SCTCAP_JOINTLY_MUTE   (1<<3)
68 #define SND_MIXER_SCTCAP_CAPTURE        (1<<4)
69 #define SND_MIXER_SCTCAP_JOINTLY_CAPTURE (1<<5)
70 #define SND_MIXER_SCTCAP_EXCL_CAPTURE   (1<<6)
71
72 typedef struct _snd_mixer_sid {
73         unsigned char name[60];
74         unsigned int index;
75 } snd_mixer_sid_t;
76
77 typedef struct _snd_mixer_simple_element_list {
78         unsigned int controls_offset;   /* W: first control ID to get */
79         unsigned int controls_request;  /* W: count of control IDs to get */
80         unsigned int controls_count;    /* R: count of available (set) IDs */
81         unsigned int controls;          /* R: count of all available controls */
82         snd_mixer_sid_t *pids;          /* W: IDs */
83         char reserved[50];
84 } snd_mixer_simple_element_list_t;
85
86 typedef struct _snd_mixer_simple_element {
87         snd_mixer_sid_t sid;            /* WR: simple control identification */
88         unsigned int caps;              /* RO: capabilities */
89         unsigned int channels;          /* RO: bitmap of active channels */
90         unsigned int mute;              /* RW: bitmap of muted channels */
91         unsigned int capture;           /* RW: bitmap of capture channels */
92         int capture_group;              /* RO: capture group (for exclusive capture) */
93         long min;                       /* RO: minimum value */
94         long max;                       /* RO: maximum value */
95         char reserved[32];
96         union {
97                 struct {
98                         long front_left;        /* front left value */
99                         long front_right;       /* front right value */
100                         long front_center;      /* front center */
101                         long rear_left;         /* left rear */
102                         long rear_right;        /* right rear */
103                         long woofer;            /* woofer */
104                 } names;
105                 long values[32];
106         } volume;                       /* RW */
107 } snd_mixer_simple_element_t;
108
109 typedef struct _snd_mixer_simple_callbacks {
110         void *private_data;     /* may be used by an application */
111         void (*rebuild) (snd_mixer_t *handle, void *private_data);
112         void (*value) (snd_mixer_t *handle, void *private_data, snd_mixer_sid_t *id);
113         void (*change) (snd_mixer_t *handle, void *private_data, snd_mixer_sid_t *id);
114         void (*add) (snd_mixer_t *handle, void *private_data, snd_mixer_sid_t *id);
115         void (*remove) (snd_mixer_t *handle, void *private_data, snd_mixer_sid_t *id);
116         void *reserved[58];     /* reserved for future use - must be NULL!!! */
117 } snd_mixer_simple_callbacks_t;
118
119 #ifdef __cplusplus
120 extern "C" {
121 #endif
122
123 const char *snd_mixer_simple_channel_name(snd_mixer_channel_id_t channel);
124 int snd_mixer_simple_element_list(snd_mixer_t *handle, snd_mixer_simple_element_list_t *list);
125 int snd_mixer_simple_element_read(snd_mixer_t *handle, snd_mixer_simple_element_t *simple);
126 int snd_mixer_simple_element_write(snd_mixer_t *handle, snd_mixer_simple_element_t *simple);
127 int snd_mixer_simple_read(snd_mixer_t *handle, snd_mixer_simple_callbacks_t *callbacks);
128
129 #ifdef __cplusplus
130 }
131 #endif
132