OSDN Git Service

e1221a76744a1ed4bae502967436b3697416991b
[android-x86/external-alsa-lib.git] / include / control.h
1 /****************************************************************************
2  *                                                                          *
3  *                              control.h                                   *
4  *                          Control Interface                               *
5  *                                                                          *
6  ****************************************************************************/
7
8 typedef struct snd_ctl snd_ctl_t;
9
10 typedef enum { SND_CTL_TYPE_HW,
11                SND_CTL_TYPE_SHM,
12                SND_CTL_TYPE_INET
13  } snd_ctl_type_t;
14
15 typedef struct snd_ctl_callbacks {
16         void *private_data;     /* may be used by an application */
17         void (*rebuild) (snd_ctl_t *handle, void *private_data);
18         void (*value) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id);
19         void (*change) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id);
20         void (*add) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id);
21         void (*remove) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id);
22         void *reserved[58];     /* reserved for the future use - must be NULL!!! */
23 } snd_ctl_callbacks_t;
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 int snd_card_load(int card);
30 int snd_cards(void);
31 unsigned int snd_cards_mask(void);
32 int snd_card_get_index(const char *name);
33 int snd_card_get_name(int card, char **name);
34 int snd_card_get_longname(int card, char **name);
35
36 int snd_defaults_card(void);
37 int snd_defaults_mixer_card(void);
38 int snd_defaults_pcm_card(void);
39 int snd_defaults_pcm_device(void);
40 int snd_defaults_rawmidi_card(void);
41 int snd_defaults_rawmidi_device(void);
42
43 int snd_ctl_hw_open(snd_ctl_t **handle, char *name, int card);
44 int snd_ctl_shm_open(snd_ctl_t **handlep, char *name, char *socket, char *sname);
45 snd_ctl_type_t snd_ctl_type(snd_ctl_t *handle);
46 int snd_ctl_open(snd_ctl_t **handle, char *name);
47 int snd_ctl_close(snd_ctl_t *handle);
48 int snd_ctl_poll_descriptor(snd_ctl_t *handle);
49 int snd_ctl_hw_info(snd_ctl_t *handle, snd_ctl_hw_info_t *info);
50 int snd_ctl_clist(snd_ctl_t *handle, snd_control_list_t * list);
51 int snd_ctl_cinfo(snd_ctl_t *handle, snd_control_info_t * sw);
52 int snd_ctl_cread(snd_ctl_t *handle, snd_control_t * control);
53 int snd_ctl_cwrite(snd_ctl_t *handle, snd_control_t * control);
54 int snd_ctl_hwdep_info(snd_ctl_t *handle, snd_hwdep_info_t * info);
55 int snd_ctl_pcm_info(snd_ctl_t *handle, snd_pcm_info_t * info);
56 int snd_ctl_pcm_prefer_subdevice(snd_ctl_t *handle, int subdev);
57 int snd_ctl_rawmidi_info(snd_ctl_t *handle, snd_rawmidi_info_t * info);
58
59 int snd_ctl_read(snd_ctl_t *handle, snd_ctl_callbacks_t * callbacks);
60
61 #ifdef __cplusplus
62 }
63 #endif
64
65 /*
66  *  Highlevel API for controls
67  */
68
69 #define LIST_HEAD_IS_DEFINED
70 struct list_head {
71         struct list_head *next, *prev;
72 };        
73
74 /**
75  * list_entry - get the struct for this entry
76  * @ptr:        the &struct list_head pointer.
77  * @type:       the type of the struct this is embedded in.
78  * @member:     the name of the list_struct within the struct.
79  */
80 #define list_entry(ptr, type, member) \
81         ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
82
83
84 typedef struct snd_hcontrol_list_stru snd_hcontrol_list_t;
85 typedef struct snd_hcontrol_stru snd_hcontrol_t;
86
87 struct snd_hcontrol_list_stru {
88         unsigned int controls_offset;   /* W: first control ID to get */
89         unsigned int controls_request;  /* W: count of control IDs to get */
90         unsigned int controls_count;    /* R: count of available (set) controls */
91         unsigned int controls;          /* R: count of all available controls */
92         snd_control_id_t *pids;         /* W: IDs */
93 };
94
95 struct snd_hcontrol_stru {
96         snd_control_id_t id;    /* must be always on top */
97         struct list_head list;  /* links for list of all hcontrols */
98         int change: 1,          /* structure change */
99             value: 1;           /* value change */
100         /* event callbacks */
101         void (*event_change)(snd_ctl_t *handle, snd_hcontrol_t *hcontrol);
102         void (*event_value)(snd_ctl_t *handle, snd_hcontrol_t *hcontrol);
103         void (*event_remove)(snd_ctl_t *handle, snd_hcontrol_t *hcontrol);
104         /* private data */
105         void *private_data;
106         void (*private_free)(void *private_data);
107         /* links */
108         snd_ctl_t *handle;      /* associated handle */
109 };
110
111 #ifdef __cplusplus
112 extern "C" {
113 #endif
114
115 typedef int (snd_ctl_hsort_t)(const snd_hcontrol_t *c1, const snd_hcontrol_t *c2);
116 typedef void (snd_ctl_hcallback_rebuild_t)(snd_ctl_t *handle, void *private_data);
117 typedef void (snd_ctl_hcallback_add_t)(snd_ctl_t *handle, void *private_data, snd_hcontrol_t *hcontrol);
118
119 int snd_ctl_hbuild(snd_ctl_t *handle, snd_ctl_hsort_t *csort);
120 int snd_ctl_hfree(snd_ctl_t *handle);
121 snd_hcontrol_t *snd_ctl_hfirst(snd_ctl_t *handle);
122 snd_hcontrol_t *snd_ctl_hlast(snd_ctl_t *handle);
123 snd_hcontrol_t *snd_ctl_hnext(snd_ctl_t *handle, snd_hcontrol_t *hcontrol);
124 snd_hcontrol_t *snd_ctl_hprev(snd_ctl_t *handle, snd_hcontrol_t *hcontrol);
125 int snd_ctl_hcount(snd_ctl_t *handle);
126 snd_hcontrol_t *snd_ctl_hfind(snd_ctl_t *handle, snd_control_id_t *id);
127 int snd_ctl_hlist(snd_ctl_t *handle, snd_hcontrol_list_t *hlist);
128 int snd_ctl_hsort(const snd_hcontrol_t *c1, const snd_hcontrol_t *c2);
129 int snd_ctl_hresort(snd_ctl_t *handle, snd_ctl_hsort_t *csort);
130 int snd_ctl_hcallback_rebuild(snd_ctl_t *handle, snd_ctl_hcallback_rebuild_t *callback, void *private_data);
131 int snd_ctl_hcallback_add(snd_ctl_t *handle, snd_ctl_hcallback_add_t *callback, void *private_data);
132 int snd_ctl_hevent(snd_ctl_t *handle);
133
134 int snd_ctl_hbag_create(void **bag);
135 int snd_ctl_hbag_destroy(void **bag, void (*hcontrol_free)(snd_hcontrol_t *hcontrol));
136 int snd_ctl_hbag_add(void **bag, snd_hcontrol_t *hcontrol);
137 int snd_ctl_hbag_del(void **bag, snd_hcontrol_t *hcontrol);
138 snd_hcontrol_t *snd_ctl_hbag_find(void **bag, snd_control_id_t *id);
139
140 #ifdef __cplusplus
141 }
142 #endif
143