OSDN Git Service

Added bag operations for the high-level control interface.
[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 struct snd_ctl_callbacks {
11         void *private_data;     /* may be used by an application */
12         void (*rebuild) (snd_ctl_t *handle, void *private_data);
13         void (*value) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id);
14         void (*change) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id);
15         void (*add) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id);
16         void (*remove) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id);
17         void *reserved[58];     /* reserved for the future use - must be NULL!!! */
18 } snd_ctl_callbacks_t;
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 int snd_card_load(int card);
25 int snd_cards(void);
26 unsigned int snd_cards_mask(void);
27 int snd_card_name(const char *name);
28 int snd_card_get_name(int card, char **name);
29 int snd_card_get_longname(int card, char **name);
30
31 int snd_defaults_card(void);
32 int snd_defaults_mixer_card(void);
33 int snd_defaults_pcm_card(void);
34 int snd_defaults_pcm_device(void);
35 int snd_defaults_rawmidi_card(void);
36 int snd_defaults_rawmidi_device(void);
37
38 int snd_ctl_open(snd_ctl_t **handle, int card);
39 int snd_ctl_close(snd_ctl_t *handle);
40 int snd_ctl_file_descriptor(snd_ctl_t *handle);
41 int snd_ctl_hw_info(snd_ctl_t *handle, struct snd_ctl_hw_info *info);
42 int snd_ctl_clist(snd_ctl_t *handle, snd_control_list_t * list);
43 int snd_ctl_cinfo(snd_ctl_t *handle, snd_control_info_t * sw);
44 int snd_ctl_cread(snd_ctl_t *handle, snd_control_t * control);
45 int snd_ctl_cwrite(snd_ctl_t *handle, snd_control_t * control);
46 int snd_ctl_hwdep_info(snd_ctl_t *handle, snd_hwdep_info_t * info);
47 int snd_ctl_pcm_info(snd_ctl_t *handle, snd_pcm_info_t * info);
48 int snd_ctl_pcm_prefer_subdevice(snd_ctl_t *handle, int subdev);
49 int snd_ctl_rawmidi_info(snd_ctl_t *handle, snd_rawmidi_info_t * info);
50
51 int snd_ctl_read(snd_ctl_t *handle, snd_ctl_callbacks_t * callbacks);
52
53 #ifdef __cplusplus
54 }
55 #endif
56
57 /*
58  *  Highlevel API for controls
59  */
60
61 #define LIST_HEAD_IS_DEFINED
62 struct list_head {
63         struct list_head *next, *prev;
64 };        
65
66 typedef struct snd_hcontrol_list_stru snd_hcontrol_list_t;
67 typedef struct snd_hcontrol_stru snd_hcontrol_t;
68
69 struct snd_hcontrol_list_stru {
70         unsigned int controls_offset;   /* W: first control ID to get */
71         unsigned int controls_request;  /* W: count of control IDs to get */
72         unsigned int controls_count;    /* R: count of available (set) controls */
73         unsigned int controls;          /* R: count of all available controls */
74         snd_control_id_t *pids;         /* W: IDs */
75 };
76
77 struct snd_hcontrol_stru {
78         snd_control_id_t id;    /* must be always on top */
79         struct list_head list;  /* links for list of all hcontrols */
80         int change: 1,          /* structure change */
81             value: 1;           /* value change */
82         /* event callbacks */
83         void (*event_change)(snd_ctl_t *handle, snd_hcontrol_t *hcontrol);
84         void (*event_value)(snd_ctl_t *handle, snd_hcontrol_t *hcontrol);
85         void (*event_remove)(snd_ctl_t *handle, snd_hcontrol_t *hcontrol);
86         /* private data */
87         void *private_data;
88         void (*private_free)(void *private_data);
89         /* links */
90         snd_ctl_t *handle;      /* associated handle */
91 };
92
93 #ifdef __cplusplus
94 extern "C" {
95 #endif
96
97 typedef int (snd_ctl_hsort_t)(const snd_hcontrol_t *c1, const snd_hcontrol_t *c2);
98 typedef void (snd_ctl_hcallback_rebuild_t)(snd_ctl_t *handle, void *private_data);
99 typedef void (snd_ctl_hcallback_add_t)(snd_ctl_t *handle, void *private_data, snd_hcontrol_t *hcontrol);
100
101 int snd_ctl_hbuild(snd_ctl_t *handle, snd_ctl_hsort_t *csort);
102 int snd_ctl_hfree(snd_ctl_t *handle);
103 snd_hcontrol_t *snd_ctl_hfirst(snd_ctl_t *handle);
104 snd_hcontrol_t *snd_ctl_hlast(snd_ctl_t *handle);
105 snd_hcontrol_t *snd_ctl_hnext(snd_ctl_t *handle, snd_hcontrol_t *hcontrol);
106 snd_hcontrol_t *snd_ctl_hprev(snd_ctl_t *handle, snd_hcontrol_t *hcontrol);
107 int snd_ctl_hcount(snd_ctl_t *handle);
108 snd_hcontrol_t *snd_ctl_hfind(snd_ctl_t *handle, snd_control_id_t *id);
109 int snd_ctl_hlist(snd_ctl_t *handle, snd_hcontrol_list_t *hlist);
110 int snd_ctl_hsort(const snd_hcontrol_t *c1, const snd_hcontrol_t *c2);
111 int snd_ctl_hresort(snd_ctl_t *handle, snd_ctl_hsort_t *csort);
112 int snd_ctl_hcallback_rebuild(snd_ctl_t *handle, snd_ctl_hcallback_rebuild_t *callback, void *private_data);
113 int snd_ctl_hcallback_add(snd_ctl_t *handle, snd_ctl_hcallback_add_t *callback, void *private_data);
114 int snd_ctl_hevent(snd_ctl_t *handle);
115
116 int snd_ctl_hbag_create(void **bag);
117 int snd_ctl_hbag_destroy(void **bag, void (*hcontrol_free)(snd_hcontrol_t *hcontrol));
118 int snd_ctl_hbag_add(void **bag, snd_hcontrol_t *hcontrol);
119 int snd_ctl_hbag_del(void **bag, snd_hcontrol_t *hcontrol);
120 snd_hcontrol_t *snd_ctl_hbag_find(void **bag, snd_control_id_t *id);
121
122 #ifdef __cplusplus
123 }
124 #endif
125