1 #ifndef ECORE_AUDIO_H 2 #define ECORE_AUDIO_H 3 4 #include <Eina.h> 5 #include <Eo.h> 6 7 #ifdef EAPI 8 #undef EAPI 9 #endif 10 11 #ifdef _WIN32 12 # ifdef EFL_BUILD 13 # ifdef DLL_EXPORT 14 # define EAPI __declspec(dllexport) 15 # else 16 # define EAPI 17 # endif 18 # else 19 # define EAPI __declspec(dllimport) 20 # endif 21 #else 22 # ifdef __GNUC__ 23 # if __GNUC__ >= 4 24 # define EAPI __attribute__ ((visibility("default"))) 25 # else 26 # define EAPI 27 # endif 28 # else 29 # define EAPI 30 # endif 31 #endif 32 33 /** 34 * @file Ecore_Audio.h 35 * @brief Audio utility functions. 36 */ 37 38 #ifdef __cplusplus 39 extern "C" 40 { 41 #endif 42 43 /** 44 * @defgroup Ecore_Audio_Group Ecore_Audio - Convenience audio API 45 * @ingroup Ecore 46 47 * @since 1.8 48 * 49 * @{ 50 */ 51 52 /** @since 1.8 53 */ 54 enum _Ecore_Audio_Type { 55 ECORE_AUDIO_TYPE_PULSE, /**< Use Pulseaudio module */ 56 ECORE_AUDIO_TYPE_ALSA, /**< Use ALSA module*/ 57 ECORE_AUDIO_TYPE_SNDFILE, /**< Use libsndfile module */ 58 ECORE_AUDIO_TYPE_TONE, /**< Use tone module */ 59 ECORE_AUDIO_TYPE_CORE_AUDIO, /**< Use Core Audio module (Apple) - DEPRECATED */ 60 ECORE_AUDIO_TYPE_CUSTOM, /**< Use custom module */ 61 ECORE_AUDIO_TYPE_WASAPI, /**< Use Wasapi module @since 1.21*/ 62 ECORE_AUDIO_MODULE_LAST, /**< Sentinel */ 63 }; 64 65 /** 66 * @since 1.8 67 */ 68 typedef enum _Ecore_Audio_Type Ecore_Audio_Type; 69 70 /** @since 1.8 71 */ 72 typedef struct _Ecore_Audio_Module Ecore_Audio_Module; 73 /**< The audio module */ 74 75 /** @since 1.8 76 */ 77 typedef struct _Ecore_Audio_Object Ecore_Audio_Object; /**< The audio object */ 78 79 /* 80 * @brief Structure to hold the callbacks needed to implement virtual file IO 81 * @since 1.8 82 */ 83 struct _Ecore_Audio_Vio { 84 /** 85 * @brief Gets the length of the file. 86 * 87 * @param data User data from the ecore_audio_obj_set_vio call 88 * @param eo_obj The Ecore_Audio object this operates on 89 * 90 * @return The length of the virtual file in bytes 91 * 92 * @since 1.8 93 */ 94 int (*get_length)(void *data, Eo *eo_obj); 95 96 /** 97 * @brief Seeks to a position within the file. 98 * 99 * @param data User data from the ecore_audio_obj_set_vio call 100 * @param eo_obj The Ecore_Audio object this operates on 101 * @param offset The number of bytes to move (can be negative) 102 * @param whence Accepts the same values as fseek(), which are: 103 * SEEK_SET: offset is absolute 104 * SEEK_CUR: offset is relative to the current position 105 * SEEK_END: offset is relative to the end 106 * 107 * @return The resulting position from the start of the file (in bytes) 108 * or -1 if an error occurred (i.e. out of bounds) 109 * 110 * @since 1.8 111 */ 112 int (*seek)(void *data, Eo *eo_obj, int offset, int whence); 113 114 /** 115 * @brief Gets the current position within the file. 116 * 117 * @param data User data from the ecore_audio_obj_set_vio call 118 * @param eo_obj The Ecore_Audio object this operates on 119 * 120 * @return The resulting position from the start of the file (in bytes) 121 * 122 * This is equivalent to calling seek() with offset 0 and whence SEEK_CUR. 123 * 124 * @since 1.8 125 */ 126 int (*tell)(void *data, Eo *eo_obj); 127 128 /** 129 * @brief Reads some data from the file. 130 * 131 * @param data User data from the ecore_audio_obj_set_vio call 132 * @param eo_obj The Ecore_Audio object this operates on 133 * @param[out] buffer the buffer to write the data to 134 * @param length The number of bytes to read 135 * 136 * @return The number of bytes read from the file. May be less than length 137 * 138 * @since 1.8 139 */ 140 int (*read)(void *data, Eo *eo_obj, void *buffer, int length); 141 142 /** 143 * @brief Writes some data to the file. 144 * 145 * @param data User data from the ecore_audio_obj_set_vio call 146 * @param eo_obj The Ecore_Audio object this operates on 147 * @param buffer Write data from here to the file 148 * @param length The number of bytes to write 149 * 150 * @return The number of bytes written to the file. May be less than length 151 * 152 * @since 1.8 153 */ 154 int (*write)(void *data, Eo *eo_obj, const void *buffer, int length); 155 }; 156 157 /** 158 * @brief Holds the callback functions to implement virtual file IO. 159 * @since 1.8 160 */ 161 typedef struct _Ecore_Audio_Vio Ecore_Audio_Vio; 162 163 /* Audio operations */ 164 165 /** 166 * @brief Initializes the Ecore_Audio library. 167 * 168 * @return @c 1 or greater on success, @c 0 on error. 169 * 170 * @since 1.8 171 * 172 * This function sets up Ecore_Audio and initializes the modules that 173 * provide the in- and outputs to use. It returns 0 on failure, otherwise 174 * it returns the number of times it has already been called. 175 * 176 * When Ecore_Audio is not used anymore, call ecore_audio_shutdown() 177 * to shut down the Ecore_Audio library. 178 */ 179 EAPI int ecore_audio_init(void); 180 181 /** 182 * @brief Shuts down the Ecore_Audio library. 183 * 184 * @return @c 0 when the library is completely shut down, @c 1 or 185 * greater otherwise. 186 * 187 * @since 1.8 188 * 189 * This function shuts down the Ecore_Audio library. It returns 0 when it has 190 * been called the same number of times than ecore_audio_init(). In that case 191 * it shuts down all the services it uses. 192 */ 193 EAPI int ecore_audio_shutdown(void); 194 195 //Legacy compatibility code 196 197 /** 198 * @brief Get the name of the object 199 * 200 * @since 1.8 201 * 202 */ 203 EAPI const char* ecore_audio_obj_name_get(const Efl_Object* obj); 204 /** 205 * @brief Name of the object 206 * 207 * @since 1.8 208 * 209 */ 210 EAPI void ecore_audio_obj_name_set(Efl_Object* obj, const char *name); 211 212 #include <ecore_audio_obj.h> 213 #include <ecore_audio_obj_in.h> 214 #include <ecore_audio_obj_out.h> 215 216 #include <ecore_audio_obj_in_sndfile.h> 217 #include <ecore_audio_obj_out_sndfile.h> 218 219 #include <ecore_audio_obj_in_tone.h> 220 221 #include <ecore_audio_obj_out_pulse.h> 222 223 #include <ecore_audio_obj_out_wasapi.h> 224 225 /** 226 * @} 227 */ 228 229 #ifdef __cplusplus 230 } 231 #endif 232 233 #undef EAPI 234 #define EAPI 235 236 #endif 237