OSDN Git Service

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