1 /** 2 * \file include/rawmidi.h 3 * \brief Application interface library for the ALSA driver 4 * \author Jaroslav Kysela <perex@perex.cz> 5 * \author Abramo Bagnara <abramo@alsa-project.org> 6 * \author Takashi Iwai <tiwai@suse.de> 7 * \date 1998-2001 8 * 9 * Application interface library for the ALSA driver 10 */ 11 /* 12 * This library is free software; you can redistribute it and/or modify 13 * it under the terms of the GNU Lesser General Public License as 14 * published by the Free Software Foundation; either version 2.1 of 15 * the License, or (at your option) any later version. 16 * 17 * This program is distributed in the hope that it will be useful, 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * GNU Lesser General Public License for more details. 21 * 22 * You should have received a copy of the GNU Lesser General Public 23 * License along with this library; if not, write to the Free Software 24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 25 * 26 */ 27 28 #ifndef __ALSA_RAWMIDI_H 29 #define __ALSA_RAWMIDI_H 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 /** 36 * \defgroup RawMidi RawMidi Interface 37 * The RawMidi Interface. See \ref rawmidi page for more details. 38 * \{ 39 */ 40 41 /** dlsym version for interface entry callback */ 42 #define SND_RAWMIDI_DLSYM_VERSION _dlsym_rawmidi_001 43 44 /** RawMidi information container */ 45 typedef struct _snd_rawmidi_info snd_rawmidi_info_t; 46 /** RawMidi settings container */ 47 typedef struct _snd_rawmidi_params snd_rawmidi_params_t; 48 /** RawMidi status container */ 49 typedef struct _snd_rawmidi_status snd_rawmidi_status_t; 50 51 /** RawMidi stream (direction) */ 52 typedef enum _snd_rawmidi_stream { 53 /** Output stream */ 54 SND_RAWMIDI_STREAM_OUTPUT = 0, 55 /** Input stream */ 56 SND_RAWMIDI_STREAM_INPUT, 57 SND_RAWMIDI_STREAM_LAST = SND_RAWMIDI_STREAM_INPUT 58 } snd_rawmidi_stream_t; 59 60 /** Append (flag to open mode) \hideinitializer */ 61 #define SND_RAWMIDI_APPEND 0x0001 62 /** Non blocking mode (flag to open mode) \hideinitializer */ 63 #define SND_RAWMIDI_NONBLOCK 0x0002 64 /** Write sync mode (Flag to open mode) \hideinitializer */ 65 #define SND_RAWMIDI_SYNC 0x0004 66 67 /** RawMidi handle */ 68 typedef struct _snd_rawmidi snd_rawmidi_t; 69 70 /** RawMidi type */ 71 typedef enum _snd_rawmidi_type { 72 /** Kernel level RawMidi */ 73 SND_RAWMIDI_TYPE_HW, 74 /** Shared memory client RawMidi (not yet implemented) */ 75 SND_RAWMIDI_TYPE_SHM, 76 /** INET client RawMidi (not yet implemented) */ 77 SND_RAWMIDI_TYPE_INET, 78 /** Virtual (sequencer) RawMidi */ 79 SND_RAWMIDI_TYPE_VIRTUAL 80 } snd_rawmidi_type_t; 81 82 /** Type of clock used with rawmidi timestamp */ 83 typedef enum _snd_rawmidi_clock { 84 SND_RAWMIDI_CLOCK_NONE = 0, 85 SND_RAWMIDI_CLOCK_REALTIME = 1, 86 SND_RAWMIDI_CLOCK_MONOTONIC = 2, 87 SND_RAWMIDI_CLOCK_MONOTONIC_RAW = 3, 88 } snd_rawmidi_clock_t; 89 90 /** Select the read mode (standard or with timestamps) */ 91 typedef enum _snd_rawmidi_read_mode { 92 SND_RAWMIDI_READ_STANDARD = 0, 93 SND_RAWMIDI_READ_TSTAMP = 1, 94 } snd_rawmidi_read_mode_t; 95 96 int snd_rawmidi_open(snd_rawmidi_t **in_rmidi, snd_rawmidi_t **out_rmidi, 97 const char *name, int mode); 98 int snd_rawmidi_open_lconf(snd_rawmidi_t **in_rmidi, snd_rawmidi_t **out_rmidi, 99 const char *name, int mode, snd_config_t *lconf); 100 int snd_rawmidi_close(snd_rawmidi_t *rmidi); 101 int snd_rawmidi_poll_descriptors_count(snd_rawmidi_t *rmidi); 102 int snd_rawmidi_poll_descriptors(snd_rawmidi_t *rmidi, struct pollfd *pfds, unsigned int space); 103 int snd_rawmidi_poll_descriptors_revents(snd_rawmidi_t *rawmidi, struct pollfd *pfds, unsigned int nfds, unsigned short *revent); 104 int snd_rawmidi_nonblock(snd_rawmidi_t *rmidi, int nonblock); 105 size_t snd_rawmidi_info_sizeof(void); 106 /** \hideinitializer 107 * \brief allocate an invalid #snd_rawmidi_info_t using standard alloca 108 * \param ptr returned pointer 109 */ 110 #define snd_rawmidi_info_alloca(ptr) __snd_alloca(ptr, snd_rawmidi_info) 111 int snd_rawmidi_info_malloc(snd_rawmidi_info_t **ptr); 112 void snd_rawmidi_info_free(snd_rawmidi_info_t *obj); 113 void snd_rawmidi_info_copy(snd_rawmidi_info_t *dst, const snd_rawmidi_info_t *src); 114 unsigned int snd_rawmidi_info_get_device(const snd_rawmidi_info_t *obj); 115 unsigned int snd_rawmidi_info_get_subdevice(const snd_rawmidi_info_t *obj); 116 snd_rawmidi_stream_t snd_rawmidi_info_get_stream(const snd_rawmidi_info_t *obj); 117 int snd_rawmidi_info_get_card(const snd_rawmidi_info_t *obj); 118 unsigned int snd_rawmidi_info_get_flags(const snd_rawmidi_info_t *obj); 119 const char *snd_rawmidi_info_get_id(const snd_rawmidi_info_t *obj); 120 const char *snd_rawmidi_info_get_name(const snd_rawmidi_info_t *obj); 121 const char *snd_rawmidi_info_get_subdevice_name(const snd_rawmidi_info_t *obj); 122 unsigned int snd_rawmidi_info_get_subdevices_count(const snd_rawmidi_info_t *obj); 123 unsigned int snd_rawmidi_info_get_subdevices_avail(const snd_rawmidi_info_t *obj); 124 void snd_rawmidi_info_set_device(snd_rawmidi_info_t *obj, unsigned int val); 125 void snd_rawmidi_info_set_subdevice(snd_rawmidi_info_t *obj, unsigned int val); 126 void snd_rawmidi_info_set_stream(snd_rawmidi_info_t *obj, snd_rawmidi_stream_t val); 127 int snd_rawmidi_info(snd_rawmidi_t *rmidi, snd_rawmidi_info_t * info); 128 size_t snd_rawmidi_params_sizeof(void); 129 /** \hideinitializer 130 * \brief allocate an invalid #snd_rawmidi_params_t using standard alloca 131 * \param ptr returned pointer 132 */ 133 #define snd_rawmidi_params_alloca(ptr) __snd_alloca(ptr, snd_rawmidi_params) 134 int snd_rawmidi_params_malloc(snd_rawmidi_params_t **ptr); 135 void snd_rawmidi_params_free(snd_rawmidi_params_t *obj); 136 void snd_rawmidi_params_copy(snd_rawmidi_params_t *dst, const snd_rawmidi_params_t *src); 137 int snd_rawmidi_params_set_buffer_size(snd_rawmidi_t *rmidi, snd_rawmidi_params_t *params, size_t val); 138 size_t snd_rawmidi_params_get_buffer_size(const snd_rawmidi_params_t *params); 139 int snd_rawmidi_params_set_avail_min(snd_rawmidi_t *rmidi, snd_rawmidi_params_t *params, size_t val); 140 size_t snd_rawmidi_params_get_avail_min(const snd_rawmidi_params_t *params); 141 int snd_rawmidi_params_set_no_active_sensing(snd_rawmidi_t *rmidi, snd_rawmidi_params_t *params, int val); 142 int snd_rawmidi_params_get_no_active_sensing(const snd_rawmidi_params_t *params); 143 int snd_rawmidi_params_set_read_mode(const snd_rawmidi_t *rawmidi, snd_rawmidi_params_t *params, snd_rawmidi_read_mode_t val); 144 snd_rawmidi_read_mode_t snd_rawmidi_params_get_read_mode(const snd_rawmidi_params_t *params); 145 int snd_rawmidi_params_set_clock_type(const snd_rawmidi_t *rawmidi, snd_rawmidi_params_t *params, snd_rawmidi_clock_t val); 146 snd_rawmidi_clock_t snd_rawmidi_params_get_clock_type(const snd_rawmidi_params_t *params); 147 148 int snd_rawmidi_params(snd_rawmidi_t *rmidi, snd_rawmidi_params_t * params); 149 int snd_rawmidi_params_current(snd_rawmidi_t *rmidi, snd_rawmidi_params_t *params); 150 size_t snd_rawmidi_status_sizeof(void); 151 /** \hideinitializer 152 * \brief allocate an invalid #snd_rawmidi_status_t using standard alloca 153 * \param ptr returned pointer 154 */ 155 #define snd_rawmidi_status_alloca(ptr) __snd_alloca(ptr, snd_rawmidi_status) 156 int snd_rawmidi_status_malloc(snd_rawmidi_status_t **ptr); 157 void snd_rawmidi_status_free(snd_rawmidi_status_t *obj); 158 void snd_rawmidi_status_copy(snd_rawmidi_status_t *dst, const snd_rawmidi_status_t *src); 159 void snd_rawmidi_status_get_tstamp(const snd_rawmidi_status_t *obj, snd_htimestamp_t *ptr); 160 size_t snd_rawmidi_status_get_avail(const snd_rawmidi_status_t *obj); 161 size_t snd_rawmidi_status_get_xruns(const snd_rawmidi_status_t *obj); 162 int snd_rawmidi_status(snd_rawmidi_t *rmidi, snd_rawmidi_status_t * status); 163 int snd_rawmidi_drain(snd_rawmidi_t *rmidi); 164 int snd_rawmidi_drop(snd_rawmidi_t *rmidi); 165 ssize_t snd_rawmidi_write(snd_rawmidi_t *rmidi, const void *buffer, size_t size); 166 ssize_t snd_rawmidi_read(snd_rawmidi_t *rmidi, void *buffer, size_t size); 167 ssize_t snd_rawmidi_tread(snd_rawmidi_t *rmidi, struct timespec *tstamp, void *buffer, size_t size); 168 const char *snd_rawmidi_name(snd_rawmidi_t *rmidi); 169 snd_rawmidi_type_t snd_rawmidi_type(snd_rawmidi_t *rmidi); 170 snd_rawmidi_stream_t snd_rawmidi_stream(snd_rawmidi_t *rawmidi); 171 172 /** \} */ 173 174 #ifdef __cplusplus 175 } 176 #endif 177 178 #endif /* __RAWMIDI_H */ 179 180