OSDN Git Service

Added functions:
[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 int snd_ctl_rawmidi_prefer_subdevice(snd_ctl_t *handle, int subdev);
59
60 int snd_ctl_read(snd_ctl_t *handle, snd_ctl_callbacks_t * callbacks);
61
62 #ifdef __cplusplus
63 }
64 #endif
65
66 /*
67  *  Highlevel API for controls
68  */
69
70 #define LIST_HEAD_IS_DEFINED
71 struct list_head {
72         struct list_head *next, *prev;
73 };        
74
75 /**
76  * list_entry - get the struct for this entry
77  * @ptr:        the &struct list_head pointer.
78  * @type:       the type of the struct this is embedded in.
79  * @member:     the name of the list_struct within the struct.
80  */
81 #define list_entry(ptr, type, member) \
82         ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
83
84
85 typedef struct snd_hcontrol_list_stru snd_hcontrol_list_t;
86 typedef struct snd_hcontrol_stru snd_hcontrol_t;
87
88 struct snd_hcontrol_list_stru {
89         unsigned int controls_offset;   /* W: first control ID to get */
90         unsigned int controls_request;  /* W: count of control IDs to get */
91         unsigned int controls_count;    /* R: count of available (set) controls */
92         unsigned int controls;          /* R: count of all available controls */
93         snd_control_id_t *pids;         /* W: IDs */
94 };
95
96 struct snd_hcontrol_stru {
97         snd_control_id_t id;    /* must be always on top */
98         struct list_head list;  /* links for list of all hcontrols */
99         int change: 1,          /* structure change */
100             value: 1;           /* value change */
101         /* event callbacks */
102         void (*event_change)(snd_ctl_t *handle, snd_hcontrol_t *hcontrol);
103         void (*event_value)(snd_ctl_t *handle, snd_hcontrol_t *hcontrol);
104         void (*event_remove)(snd_ctl_t *handle, snd_hcontrol_t *hcontrol);
105         /* private data */
106         void *private_data;
107         void (*private_free)(void *private_data);
108         /* links */
109         snd_ctl_t *handle;      /* associated handle */
110 };
111
112 #ifdef __cplusplus
113 extern "C" {
114 #endif
115
116 typedef int (snd_ctl_hsort_t)(const snd_hcontrol_t *c1, const snd_hcontrol_t *c2);
117 typedef void (snd_ctl_hcallback_rebuild_t)(snd_ctl_t *handle, void *private_data);
118 typedef void (snd_ctl_hcallback_add_t)(snd_ctl_t *handle, void *private_data, snd_hcontrol_t *hcontrol);
119
120 int snd_ctl_hbuild(snd_ctl_t *handle, snd_ctl_hsort_t *csort);
121 int snd_ctl_hfree(snd_ctl_t *handle);
122 snd_hcontrol_t *snd_ctl_hfirst(snd_ctl_t *handle);
123 snd_hcontrol_t *snd_ctl_hlast(snd_ctl_t *handle);
124 snd_hcontrol_t *snd_ctl_hnext(snd_ctl_t *handle, snd_hcontrol_t *hcontrol);
125 snd_hcontrol_t *snd_ctl_hprev(snd_ctl_t *handle, snd_hcontrol_t *hcontrol);
126 int snd_ctl_hcount(snd_ctl_t *handle);
127 snd_hcontrol_t *snd_ctl_hfind(snd_ctl_t *handle, snd_control_id_t *id);
128 int snd_ctl_hlist(snd_ctl_t *handle, snd_hcontrol_list_t *hlist);
129 int snd_ctl_hsort(const snd_hcontrol_t *c1, const snd_hcontrol_t *c2);
130 int snd_ctl_hresort(snd_ctl_t *handle, snd_ctl_hsort_t *csort);
131 int snd_ctl_hcallback_rebuild(snd_ctl_t *handle, snd_ctl_hcallback_rebuild_t *callback, void *private_data);
132 int snd_ctl_hcallback_add(snd_ctl_t *handle, snd_ctl_hcallback_add_t *callback, void *private_data);
133 int snd_ctl_hevent(snd_ctl_t *handle);
134
135 int snd_ctl_hbag_create(void **bag);
136 int snd_ctl_hbag_destroy(void **bag, void (*hcontrol_free)(snd_hcontrol_t *hcontrol));
137 int snd_ctl_hbag_add(void **bag, snd_hcontrol_t *hcontrol);
138 int snd_ctl_hbag_del(void **bag, snd_hcontrol_t *hcontrol);
139 snd_hcontrol_t *snd_ctl_hbag_find(void **bag, snd_control_id_t *id);
140
141 #ifdef __cplusplus
142 }
143 #endif
144