1 /* snd_utils.h 2 ** Copyright (c) 2019, The Linux Foundation. 3 ** 4 ** Redistribution and use in source and binary forms, with or without 5 ** modification, are permitted provided that the following conditions are 6 ** met: 7 ** * Redistributions of source code must retain the above copyright 8 ** notice, this list of conditions and the following disclaimer. 9 ** * Redistributions in binary form must reproduce the above 10 ** copyright notice, this list of conditions and the following 11 ** disclaimer in the documentation and/or other materials provided 12 ** with the distribution. 13 ** * Neither the name of The Linux Foundation nor the names of its 14 ** contributors may be used to endorse or promote products derived 15 ** from this software without specific prior written permission. 16 ** 17 ** THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 18 ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 20 ** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 21 ** BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 ** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24 ** BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 26 ** OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27 ** IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 **/ 29 30 #ifndef TINYALSA_SRC_SND_CARD_UTILS_H 31 #define TINYALSA_SRC_SND_CARD_UTILS_H 32 33 #include <tinyalsa/plugin.h> 34 35 #include <dlfcn.h> 36 37 /** Encapsulates the pcm device definition from 38 * the sound card definition configuration file. 39 */ 40 struct snd_node { 41 /** Pointer the card definition */ 42 void *card_node; 43 /** Pointer to device definition, either PCM or MIXER device */ 44 void *dev_node; 45 /** Pointer to the sound card parser library */ 46 void *dl_hdl; 47 /** A pointer to the operations structure. */ 48 const struct snd_node_ops* ops; 49 }; 50 51 enum snd_node_type { 52 SND_NODE_TYPE_HW = 0, 53 SND_NODE_TYPE_PLUGIN, 54 SND_NODE_TYPE_INVALID, 55 }; 56 57 enum { 58 NODE_PCM, 59 NODE_MIXER 60 }; 61 62 struct snd_node *snd_utils_open_pcm(unsigned int card, unsigned int device); 63 64 struct snd_node *snd_utils_open_mixer(unsigned int card); 65 66 void snd_utils_close_dev_node(struct snd_node *node); 67 68 enum snd_node_type snd_utils_get_node_type(struct snd_node *node); 69 70 int snd_utils_get_int(struct snd_node *node, const char *prop, int *val); 71 72 int snd_utils_get_str(struct snd_node *node, const char *prop, char **val); 73 74 #endif /* end of TINYALSA_SRC_SND_CARD_UTILS_H */ 75