OSDN Git Service

Added abstraction layer to controls. Added client/server support to controls. Cleaned...
[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_file_descriptor(snd_mixer_t *handle);
17
18 #ifdef __cplusplus
19 }
20 #endif
21
22 /*
23  *  Simple (legacy) mixer API
24  */
25
26 typedef enum {
27         SND_MIXER_CHN_FRONT_LEFT = 0,
28         SND_MIXER_CHN_FRONT_RIGHT,
29         SND_MIXER_CHN_FRONT_CENTER,
30         SND_MIXER_CHN_REAR_LEFT,
31         SND_MIXER_CHN_REAR_RIGHT,
32         SND_MIXER_CHN_WOOFER,
33         SND_MIXER_CHN_LAST = 31,
34         SND_MIXER_CHN_MONO = SND_MIXER_CHN_FRONT_LEFT
35 } snd_mixer_channel_id_t;
36
37 #define SND_MIXER_CHN_MASK_MONO         (1<<SND_MIXER_CHN_MONO)
38 #define SND_MIXER_CHN_MASK_FRONT_LEFT   (1<<SND_MIXER_CHN_FRONT_LEFT)
39 #define SND_MIXER_CHN_MASK_FRONT_RIGHT  (1<<SND_MIXER_CHN_FRONT_RIGHT)
40 #define SND_MIXER_CHN_MASK_FRONT_CENTER (1<<SND_MIXER_CHN_FRONT_CENTER)
41 #define SND_MIXER_CHN_MASK_REAR_LEFT    (1<<SND_MIXER_CHN_REAR_LEFT)
42 #define SND_MIXER_CHN_MASK_REAR_RIGHT   (1<<SND_MIXER_CHN_REAR_RIGHT)
43 #define SND_MIXER_CHN_MASK_WOOFER       (1<<SND_MIXER_CHN_WOOFER)
44 #define SND_MIXER_CHN_MASK_STEREO       (SND_MIXER_CHN_MASK_FRONT_LEFT|SND_MIXER_CHN_MASK_FRONT_RIGHT)
45
46 #define SND_MIXER_SCTCAP_VOLUME         (1<<0)
47 #define SND_MIXER_SCTCAP_JOINTLY_VOLUME (1<<1)
48 #define SND_MIXER_SCTCAP_MUTE           (1<<2)
49 #define SND_MIXER_SCTCAP_JOINTLY_MUTE   (1<<3)
50 #define SND_MIXER_SCTCAP_CAPTURE        (1<<4)
51 #define SND_MIXER_SCTCAP_JOINTLY_CAPTURE (1<<5)
52 #define SND_MIXER_SCTCAP_EXCL_CAPTURE   (1<<6)
53
54 typedef struct snd_mixer_sid {
55         unsigned char name[60];
56         unsigned int index;
57 } snd_mixer_sid_t;
58
59 typedef struct snd_mixer_simple_control_list {
60         unsigned int controls_offset;   /* W: first control ID to get */
61         unsigned int controls_request;  /* W: count of control IDs to get */
62         unsigned int controls_count;    /* R: count of available (set) IDs */
63         unsigned int controls;          /* R: count of all available controls */
64         snd_mixer_sid_t *pids;          /* W: IDs */
65         char reserved[50];
66 } snd_mixer_simple_control_list_t;
67
68 typedef struct snd_mixer_simple_control {
69         snd_mixer_sid_t sid;            /* WR: simple control identification */
70         unsigned int caps;              /* RO: capabilities */
71         unsigned int channels;          /* RO: bitmap of active channels */
72         unsigned int mute;              /* RW: bitmap of muted channels */
73         unsigned int capture;           /* RW: bitmap of capture channels */
74         int capture_group;              /* RO: capture group (for exclusive capture) */
75         long min;                       /* RO: minimum value */
76         long max;                       /* RO: maximum value */
77         char reserved[32];
78         union {
79                 struct {
80                         long front_left;        /* front left value */
81                         long front_right;       /* front right value */
82                         long front_center;      /* front center */
83                         long rear_left;         /* left rear */
84                         long rear_right;        /* right rear */
85                         long woofer;            /* woofer */
86                 } names;
87                 long values[32];
88         } volume;                       /* RW */
89 } snd_mixer_simple_control_t;
90
91 typedef struct snd_mixer_simple_callbacks {
92         void *private_data;     /* may be used by an application */
93         void (*rebuild) (snd_mixer_t *handle, void *private_data);
94         void (*value) (snd_mixer_t *handle, void *private_data, snd_mixer_sid_t *id);
95         void (*change) (snd_mixer_t *handle, void *private_data, snd_mixer_sid_t *id);
96         void (*add) (snd_mixer_t *handle, void *private_data, snd_mixer_sid_t *id);
97         void (*remove) (snd_mixer_t *handle, void *private_data, snd_mixer_sid_t *id);
98         void *reserved[58];     /* reserved for future use - must be NULL!!! */
99 } snd_mixer_simple_callbacks_t;
100
101 #ifdef __cplusplus
102 extern "C" {
103 #endif
104
105 const char *snd_mixer_simple_channel_name(int channel);
106 int snd_mixer_simple_control_list(snd_mixer_t *handle, snd_mixer_simple_control_list_t *list);
107 int snd_mixer_simple_control_read(snd_mixer_t *handle, snd_mixer_simple_control_t *simple);
108 int snd_mixer_simple_control_write(snd_mixer_t *handle, snd_mixer_simple_control_t *simple);
109 int snd_mixer_simple_read(snd_mixer_t *handle, snd_mixer_simple_callbacks_t *callbacks);
110
111 #ifdef __cplusplus
112 }
113 #endif
114