1 /* 2 * Control Interface - local header file 3 * Copyright (c) 2000 by Jaroslav Kysela <perex (at) perex.cz> 4 * 5 * 6 * This library is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU Lesser General Public License as 8 * published by the Free Software Foundation; either version 2.1 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * 20 */ 21 22 #include "local.h" 23 24 typedef struct _snd_ctl_ops { 25 int (*close)(snd_ctl_t *handle); 26 int (*nonblock)(snd_ctl_t *handle, int nonblock); 27 int (*async)(snd_ctl_t *handle, int sig, pid_t pid); 28 int (*subscribe_events)(snd_ctl_t *handle, int subscribe); 29 int (*card_info)(snd_ctl_t *handle, snd_ctl_card_info_t *info); 30 int (*element_list)(snd_ctl_t *handle, snd_ctl_elem_list_t *list); 31 int (*element_info)(snd_ctl_t *handle, snd_ctl_elem_info_t *info); 32 int (*element_add)(snd_ctl_t *handle, snd_ctl_elem_info_t *info); 33 int (*element_replace)(snd_ctl_t *handle, snd_ctl_elem_info_t *info); 34 int (*element_remove)(snd_ctl_t *handle, snd_ctl_elem_id_t *id); 35 int (*element_read)(snd_ctl_t *handle, snd_ctl_elem_value_t *control); 36 int (*element_write)(snd_ctl_t *handle, snd_ctl_elem_value_t *control); 37 int (*element_lock)(snd_ctl_t *handle, snd_ctl_elem_id_t *lock); 38 int (*element_unlock)(snd_ctl_t *handle, snd_ctl_elem_id_t *unlock); 39 int (*element_tlv)(snd_ctl_t *handle, int op_flag, unsigned int numid, 40 unsigned int *tlv, unsigned int tlv_size); 41 int (*hwdep_next_device)(snd_ctl_t *handle, int *device); 42 int (*hwdep_info)(snd_ctl_t *handle, snd_hwdep_info_t * info); 43 int (*pcm_next_device)(snd_ctl_t *handle, int *device); 44 int (*pcm_info)(snd_ctl_t *handle, snd_pcm_info_t * info); 45 int (*pcm_prefer_subdevice)(snd_ctl_t *handle, int subdev); 46 int (*rawmidi_next_device)(snd_ctl_t *handle, int *device); 47 int (*rawmidi_info)(snd_ctl_t *handle, snd_rawmidi_info_t * info); 48 int (*rawmidi_prefer_subdevice)(snd_ctl_t *handle, int subdev); 49 int (*set_power_state)(snd_ctl_t *handle, unsigned int state); 50 int (*get_power_state)(snd_ctl_t *handle, unsigned int *state); 51 int (*read)(snd_ctl_t *handle, snd_ctl_event_t *event); 52 int (*poll_descriptors_count)(snd_ctl_t *handle); 53 int (*poll_descriptors)(snd_ctl_t *handle, struct pollfd *pfds, unsigned int space); 54 int (*poll_revents)(snd_ctl_t *handle, struct pollfd *pfds, unsigned int nfds, unsigned short *revents); 55 } snd_ctl_ops_t; 56 57 58 struct _snd_ctl { 59 void *dl_handle; 60 char *name; 61 snd_ctl_type_t type; 62 const snd_ctl_ops_t *ops; 63 void *private_data; 64 int nonblock; 65 int poll_fd; 66 struct list_head async_handlers; 67 }; 68 69 struct _snd_hctl_elem { 70 snd_ctl_elem_id_t id; /* must be always on top */ 71 struct list_head list; /* links for list of all helems */ 72 int compare_weight; /* compare weight (reversed) */ 73 /* event callback */ 74 snd_hctl_elem_callback_t callback; 75 void *callback_private; 76 /* links */ 77 snd_hctl_t *hctl; /* associated handle */ 78 }; 79 80 struct _snd_hctl { 81 snd_ctl_t *ctl; 82 struct list_head elems; /* list of all controls */ 83 unsigned int alloc; 84 unsigned int count; 85 snd_hctl_elem_t **pelems; 86 snd_hctl_compare_t compare; 87 snd_hctl_callback_t callback; 88 void *callback_private; 89 }; 90 91 92 /* make local functions really local */ 93 #define snd_ctl_new snd1_ctl_new 94 95 int snd_ctl_new(snd_ctl_t **ctlp, snd_ctl_type_t type, const char *name); 96 int _snd_ctl_poll_descriptor(snd_ctl_t *ctl); 97 #define _snd_ctl_async_descriptor _snd_ctl_poll_descriptor 98 int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card, int mode); 99 int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *sockname, const char *sname, int mode); 100 int snd_ctl_async(snd_ctl_t *ctl, int sig, pid_t pid); 101