[169] | 1 | //codecfilter.c: |
---|
| 2 | |
---|
[668] | 3 | /* |
---|
| 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008 |
---|
| 5 | * |
---|
| 6 | * This file is part of roard a part of RoarAudio, |
---|
| 7 | * a cross-platform sound system for both, home and professional use. |
---|
| 8 | * See README for details. |
---|
| 9 | * |
---|
| 10 | * This file is free software; you can redistribute it and/or modify |
---|
| 11 | * it under the terms of the GNU General Public License version 3 |
---|
| 12 | * as published by the Free Software Foundation. |
---|
| 13 | * |
---|
| 14 | * RoarAudio is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this software; see the file COPYING. If not, write to |
---|
| 21 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
| 22 | * |
---|
| 23 | */ |
---|
| 24 | |
---|
[1185] | 25 | #define ROAR_REQUIRE_LIBVORBISFILE |
---|
| 26 | |
---|
[169] | 27 | #include "roard.h" |
---|
| 28 | |
---|
[1481] | 29 | #ifndef ROAR_WITHOUT_CF_CMD |
---|
| 30 | #if !defined(ROAR_HAVE_UNIX) || !defined(ROAR_HAVE_BSDSOCKETS) || !defined(ROAR_HAVE_IO_POSIX) |
---|
| 31 | #define ROAR_WITHOUT_CF_CMD |
---|
| 32 | #endif |
---|
| 33 | #endif |
---|
| 34 | |
---|
[2832] | 35 | #define _DUMMY_FILTER(codec,name,desc,flags,subsystem) {(codec),(name),(desc),NULL,NULL,(flags),(subsystem), \ |
---|
| 36 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } |
---|
| 37 | |
---|
[2833] | 38 | #define _PCM_FILTER(codec) _DUMMY_FILTER(codec, "PCM", "Native PCM Support", \ |
---|
| 39 | ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU_NN, \ |
---|
| 40 | ROAR_SUBSYS_WAVEFORM) |
---|
| 41 | |
---|
[173] | 42 | struct roar_codecfilter g_codecfilter[] = { |
---|
[2832] | 43 | _DUMMY_FILTER(-1, "null", "null codec filter", ROAR_CODECFILTER_NONE, ROAR_SUBSYS_NONE), |
---|
[2834] | 44 | _PCM_FILTER(ROAR_CODEC_PCM_S_LE), |
---|
| 45 | _PCM_FILTER(ROAR_CODEC_PCM_S_BE), |
---|
| 46 | _PCM_FILTER(ROAR_CODEC_PCM_S_PDP), |
---|
| 47 | _PCM_FILTER(ROAR_CODEC_PCM_U_LE), |
---|
| 48 | _PCM_FILTER(ROAR_CODEC_PCM_U_BE), |
---|
| 49 | _PCM_FILTER(ROAR_CODEC_PCM_U_PDP), |
---|
[2832] | 50 | _DUMMY_FILTER(ROAR_CODEC_MIDI, "MIDI", "Native MIDI Support", |
---|
| 51 | ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU_NN, ROAR_SUBSYS_MIDI), |
---|
[2816] | 52 | {ROAR_CODEC_DMX512, "DMX512", "Native DMX512 Support", NULL, NULL, |
---|
| 53 | ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU_NN, ROAR_SUBSYS_LIGHT, |
---|
| 54 | NULL, NULL, NULL, NULL, NULL, NULL, cf_alaw_delay, NULL}, |
---|
[201] | 55 | |
---|
[1012] | 56 | /* |
---|
[851] | 57 | #ifdef ROAR_HAVE_LIBSNDFILE |
---|
[1012] | 58 | {ROAR_CODEC_RIFF_WAVE, "sndfile", "libsndfile codec filter", NULL, ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE, |
---|
| 59 | cf_sndfile_open, cf_sndfile_close, NULL, cf_sndfile_write, cf_sndfile_read, NULL}, |
---|
[851] | 60 | #else |
---|
[1012] | 61 | */ |
---|
[2505] | 62 | #ifndef ROAR_WITHOUT_CF_WAVE |
---|
[2679] | 63 | {ROAR_CODEC_RIFF_WAVE, "RIFF/WAVE", "RIFF/WAVE", NULL, NULL, |
---|
[2816] | 64 | ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU, ROAR_SUBSYS_WAVEFORM, |
---|
[2604] | 65 | cf_wave_open, cf_wave_close, NULL, cf_wave_write, cf_wave_read, NULL, NULL, cf_wave_ctl}, |
---|
[2505] | 66 | #endif |
---|
[1012] | 67 | //#endif |
---|
[561] | 68 | |
---|
[2686] | 69 | #ifdef ROAR_HAVE_LIBRAUM |
---|
[2690] | 70 | {ROAR_CODEC_RAUM, "RAUM", "RAUM Container Format", NULL, cf_raum_setup, ROAR_CODECFILTER_WRITE, |
---|
[2686] | 71 | ROAR_SUBSYS_WAVEFORM|ROAR_SUBSYS_MIDI|ROAR_SUBSYS_LIGHT|ROAR_SUBSYS_RAW|ROAR_SUBSYS_COMPLEX, |
---|
[2701] | 72 | cont_fw_cf_open, cont_fw_cf_close, NULL, cont_fw_cf_write, cont_fw_cf_read, cont_fw_cf_flush, NULL, cont_fw_cf_ctl}, |
---|
[2686] | 73 | #endif |
---|
| 74 | |
---|
[2816] | 75 | #ifdef ROAR_HAVE_LIBOGG |
---|
| 76 | {ROAR_CODEC_OGG, "Ogg", "Ogg Container Format", NULL, NULL, ROAR_CODECFILTER_NONE, |
---|
| 77 | ROAR_SUBSYS_WAVEFORM|ROAR_SUBSYS_MIDI, |
---|
| 78 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, |
---|
| 79 | #endif |
---|
| 80 | |
---|
[1065] | 81 | #ifdef ROAR_SUPPORT_ALAW |
---|
[2679] | 82 | {ROAR_CODEC_ALAW, "alaw", "A-Law", NULL, NULL, |
---|
[1065] | 83 | #ifdef ROAR_SUPPORT_ALAW_RW |
---|
[2816] | 84 | ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU_NN, |
---|
[1065] | 85 | #else |
---|
[2816] | 86 | ROAR_CODECFILTER_READ|ROAR_CODECFILTER_PRETHRU_NN, |
---|
[1065] | 87 | #endif |
---|
[2679] | 88 | ROAR_SUBSYS_WAVEFORM, |
---|
[1065] | 89 | cf_alaw_open, cf_alaw_close, NULL, |
---|
| 90 | #ifdef ROAR_SUPPORT_ALAW_RW |
---|
| 91 | cf_alaw_write, |
---|
| 92 | #else |
---|
| 93 | NULL, |
---|
| 94 | #endif |
---|
[1223] | 95 | cf_alaw_read, NULL, cf_alaw_delay, NULL}, |
---|
[1065] | 96 | #endif |
---|
[736] | 97 | |
---|
[1065] | 98 | #ifdef ROAR_SUPPORT_MULAW |
---|
[2679] | 99 | {ROAR_CODEC_MULAW, "mulaw", "mu-Law", NULL, NULL, |
---|
[1065] | 100 | #ifdef ROAR_SUPPORT_MULAW_RW |
---|
[2816] | 101 | ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU_NN, |
---|
[1065] | 102 | #else |
---|
[2816] | 103 | ROAR_CODECFILTER_READ|ROAR_CODECFILTER_PRETHRU_NN, |
---|
[1065] | 104 | #endif |
---|
[2679] | 105 | ROAR_SUBSYS_WAVEFORM, |
---|
[1065] | 106 | cf_mulaw_open, cf_mulaw_close, NULL, |
---|
| 107 | #ifdef ROAR_SUPPORT_MULAW_RW |
---|
| 108 | cf_mulaw_write, |
---|
| 109 | #else |
---|
| 110 | NULL, |
---|
| 111 | #endif |
---|
[1223] | 112 | cf_mulaw_read, NULL, cf_alaw_delay, NULL}, |
---|
[1065] | 113 | #endif |
---|
[922] | 114 | |
---|
[1199] | 115 | #ifndef ROAR_WITHOUT_CF_CMD |
---|
[749] | 116 | #ifdef ROAR_HAVE_BIN_OGG123 |
---|
[201] | 117 | {ROAR_CODEC_OGG_GENERAL, "cmd", "ogg123", |
---|
[2679] | 118 | ROAR_HAVE_BIN_OGG123 " -q -d raw -f - -", NULL, ROAR_CODECFILTER_READ, ROAR_SUBSYS_WAVEFORM, |
---|
[1223] | 119 | cf_cmd_open, NULL, NULL, NULL, NULL, NULL, codecfilter_delay_fulldyn, NULL}, |
---|
[749] | 120 | #endif |
---|
[1199] | 121 | #endif |
---|
[201] | 122 | |
---|
[362] | 123 | #ifdef ROAR_HAVE_LIBVORBISFILE |
---|
[2679] | 124 | {ROAR_CODEC_OGG_VORBIS, "oggvorbis", "Ogg Vorbis decoder", NULL, NULL, |
---|
[612] | 125 | #ifdef ROAR_HAVE_LIBVORBISENC |
---|
[2816] | 126 | ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU, |
---|
[612] | 127 | #else |
---|
| 128 | ROAR_CODECFILTER_READ, |
---|
| 129 | #endif |
---|
[2679] | 130 | ROAR_SUBSYS_WAVEFORM, |
---|
[1238] | 131 | cf_vorbis_open, cf_vorbis_close, NULL, cf_vorbis_write, cf_vorbis_read, NULL, codecfilter_delay_fulldyn, cf_vorbis_ctl}, |
---|
[976] | 132 | #else |
---|
[1199] | 133 | #ifndef ROAR_WITHOUT_CF_CMD |
---|
[976] | 134 | #ifdef ROAR_HAVE_BIN_OGG123 |
---|
| 135 | {ROAR_CODEC_OGG_VORBIS, "cmd", "ogg123", |
---|
[2679] | 136 | ROAR_HAVE_BIN_OGG123 " -q -d raw -f - -", NULL, ROAR_CODECFILTER_READ, ROAR_SUBSYS_WAVEFORM, |
---|
[1223] | 137 | cf_cmd_open, NULL, NULL, NULL, NULL, NULL, codecfilter_delay_fulldyn, NULL}, |
---|
[976] | 138 | #endif |
---|
[362] | 139 | #endif |
---|
[1199] | 140 | #endif |
---|
[205] | 141 | |
---|
[994] | 142 | #ifdef ROAR_HAVE_LIBFISHSOUND |
---|
[998] | 143 | {ROAR_CODEC_OGG_SPEEX, "fishsound", "libfishsound Xiph Codec library", |
---|
[2679] | 144 | NULL, NULL, ROAR_CODECFILTER_READ, ROAR_SUBSYS_WAVEFORM, |
---|
[1223] | 145 | cf_fishsound_open, cf_fishsound_close, NULL, NULL, cf_fishsound_read, NULL, codecfilter_delay_fulldyn, NULL}, |
---|
[995] | 146 | |
---|
[998] | 147 | {ROAR_CODEC_OGG_FLAC, "fishsound", "libfishsound Xiph Codec library", |
---|
[2679] | 148 | NULL, NULL, ROAR_CODECFILTER_READ, ROAR_SUBSYS_WAVEFORM, |
---|
[1223] | 149 | cf_fishsound_open, cf_fishsound_close, NULL, NULL, cf_fishsound_read, NULL, codecfilter_delay_fulldyn, NULL}, |
---|
[994] | 150 | #endif |
---|
| 151 | |
---|
[1199] | 152 | #ifndef ROAR_WITHOUT_CF_CMD |
---|
[749] | 153 | #ifdef ROAR_HAVE_BIN_TIMIDITY |
---|
[221] | 154 | {ROAR_CODEC_MIDI_FILE, "MIDIFILE", "timidity MIDI synth", |
---|
[2679] | 155 | ROAR_HAVE_BIN_TIMIDITY " -Or1sl -s %R -o - -", NULL, ROAR_CODECFILTER_READ, ROAR_SUBSYS_WAVEFORM, |
---|
[1223] | 156 | cf_cmd_open, NULL, NULL, NULL, NULL, NULL, codecfilter_delay_fulldyn, NULL}, |
---|
[749] | 157 | #endif |
---|
[1199] | 158 | #endif |
---|
[221] | 159 | |
---|
[361] | 160 | #ifdef ROAR_HAVE_LIBCELT |
---|
[2816] | 161 | {ROAR_CODEC_ROAR_CELT, "RoarCELT", "RoarAudio CELT", NULL, NULL, |
---|
| 162 | ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU, |
---|
[2679] | 163 | ROAR_SUBSYS_WAVEFORM, |
---|
[1223] | 164 | cf_celt_open, cf_celt_close, NULL, cf_celt_write, cf_celt_read, NULL, cf_celt_delay, NULL}, |
---|
[361] | 165 | #endif |
---|
[330] | 166 | |
---|
[373] | 167 | #ifdef ROAR_HAVE_LIBSPEEX |
---|
[2816] | 168 | {ROAR_CODEC_ROAR_SPEEX, "RoarSpeex", "RoarAudio Speex", NULL, NULL, |
---|
| 169 | ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU, |
---|
[2679] | 170 | ROAR_SUBSYS_WAVEFORM, |
---|
[1223] | 171 | cf_speex_open, cf_speex_close, NULL, cf_speex_write, cf_speex_read, NULL, NULL, NULL}, |
---|
[373] | 172 | #endif |
---|
| 173 | |
---|
[1199] | 174 | #ifndef ROAR_WITHOUT_CF_CMD |
---|
[749] | 175 | #ifdef ROAR_HAVE_BIN_FLAC |
---|
[612] | 176 | {ROAR_CODEC_FLAC, "cmd", "flac", |
---|
[201] | 177 | #if BYTE_ORDER == BIG_ENDIAN |
---|
[749] | 178 | ROAR_HAVE_BIN_FLAC " --silent --force-raw-format --sign=signed --endian=big -d - -o -", |
---|
[201] | 179 | #elif BYTE_ORDER == LITTLE_ENDIAN |
---|
[749] | 180 | ROAR_HAVE_BIN_FLAC " --silent --force-raw-format --sign=signed --endian=little -d - -o -", |
---|
[201] | 181 | #else |
---|
| 182 | "false", |
---|
| 183 | #endif |
---|
[2679] | 184 | NULL, ROAR_CODECFILTER_READ, ROAR_SUBSYS_WAVEFORM, |
---|
[1223] | 185 | cf_cmd_open, NULL, NULL, NULL, NULL, NULL, codecfilter_delay_fulldyn, NULL}, |
---|
[749] | 186 | #endif |
---|
[1199] | 187 | #endif |
---|
[179] | 188 | |
---|
[2832] | 189 | _DUMMY_FILTER(ROAR_CODEC_ROARDMX, "RoarDMX", "Native RoarDMX Support", |
---|
| 190 | ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU_NN, ROAR_SUBSYS_LIGHT), |
---|
[2816] | 191 | |
---|
[2679] | 192 | {-1, NULL, NULL, NULL, NULL, ROAR_CODECFILTER_NONE, ROAR_SUBSYS_NONE, |
---|
| 193 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL} // end of list |
---|
[173] | 194 | }; |
---|
| 195 | |
---|
[175] | 196 | void print_codecfilterlist (void) { |
---|
| 197 | int i; |
---|
[613] | 198 | int flags; |
---|
| 199 | char mode[5]; |
---|
[1144] | 200 | char delay[6]; |
---|
[2680] | 201 | char subsys[7] = " "; |
---|
[1144] | 202 | uint_least32_t d; |
---|
[613] | 203 | |
---|
[2680] | 204 | printf(" Codec Filtername Mode Subsys Delay - Description\n"); |
---|
| 205 | printf("-------------------------------------------------------------\n"); |
---|
[175] | 206 | |
---|
| 207 | for (i = 0; g_codecfilter[i].name != NULL; i++) { |
---|
[2680] | 208 | strncpy(subsys, " ", 6); |
---|
| 209 | |
---|
| 210 | if ( g_codecfilter[i].subsystems & ROAR_SUBSYS_WAVEFORM ) |
---|
| 211 | subsys[0] = 'W'; |
---|
| 212 | if ( g_codecfilter[i].subsystems & ROAR_SUBSYS_MIDI ) |
---|
| 213 | subsys[1] = 'M'; |
---|
| 214 | if ( g_codecfilter[i].subsystems & ROAR_SUBSYS_CB ) |
---|
| 215 | subsys[2] = 'C'; |
---|
| 216 | if ( g_codecfilter[i].subsystems & ROAR_SUBSYS_LIGHT ) |
---|
| 217 | subsys[3] = 'L'; |
---|
| 218 | if ( g_codecfilter[i].subsystems & ROAR_SUBSYS_RAW ) |
---|
| 219 | subsys[4] = 'R'; |
---|
[2681] | 220 | if ( g_codecfilter[i].subsystems & ROAR_SUBSYS_COMPLEX ) |
---|
| 221 | subsys[5] = 'X'; |
---|
[2680] | 222 | |
---|
[613] | 223 | flags = g_codecfilter[i].flags; |
---|
| 224 | |
---|
| 225 | if ( flags == ROAR_CODECFILTER_NONE ) { |
---|
| 226 | strcpy(mode, "none"); |
---|
| 227 | } else { |
---|
| 228 | strcpy(mode, " "); |
---|
| 229 | if ( flags & ROAR_CODECFILTER_READ ) |
---|
| 230 | mode[0] = 'r'; |
---|
| 231 | if ( flags & ROAR_CODECFILTER_WRITE ) |
---|
| 232 | mode[1] = 'w'; |
---|
[2816] | 233 | if ( flags & ROAR_CODECFILTER_PRETHRU ) |
---|
| 234 | mode[2] = 'P'; |
---|
| 235 | if ( flags & ROAR_CODECFILTER_PRETHRU_NN ) |
---|
| 236 | mode[2] = 'p'; |
---|
[613] | 237 | } |
---|
[1144] | 238 | |
---|
| 239 | *delay = 0; |
---|
| 240 | if ( g_codecfilter[i].codec == -1 ) { // null codec filter |
---|
| 241 | strcpy(delay, "0ms"); |
---|
| 242 | } else if ( g_codecfilter[i].delay == NULL ) { |
---|
| 243 | strcpy(delay, "?"); |
---|
| 244 | } else { |
---|
| 245 | if ( codecfilter_delay(NULL, i, &d) == -1 ) { |
---|
| 246 | strcpy(delay, "dyn"); |
---|
| 247 | } else { |
---|
| 248 | snprintf(delay, 5, "%ims", d/1000); |
---|
| 249 | } |
---|
| 250 | } |
---|
[613] | 251 | |
---|
[2680] | 252 | printf(" %-12s %-12s %-4s %6s %-5s - %s\n", |
---|
[178] | 253 | roar_codec2str(g_codecfilter[i].codec), |
---|
| 254 | g_codecfilter[i].name, |
---|
[613] | 255 | mode, |
---|
[2680] | 256 | subsys, |
---|
[1144] | 257 | delay, |
---|
[552] | 258 | g_codecfilter[i].desc |
---|
| 259 | ); |
---|
[175] | 260 | } |
---|
| 261 | } |
---|
| 262 | |
---|
[194] | 263 | int codecfilter_open (CODECFILTER_USERDATA_T * inst, |
---|
| 264 | int * codecfilter_id, char * codecfilter /* NOTE: this is not part of struct roar_codecfilter's def! */, |
---|
| 265 | int codec, struct roar_stream_server * info) { |
---|
| 266 | int i; |
---|
| 267 | struct roar_codecfilter * filter = NULL; |
---|
| 268 | |
---|
| 269 | *codecfilter_id = -1; |
---|
| 270 | |
---|
[486] | 271 | ROAR_DBG("codecfilter_open(*): codecfilter='%s', info->id=%i", codecfilter, ROAR_STREAM(info)->id); |
---|
| 272 | |
---|
[194] | 273 | for (i = 0; g_codecfilter[i].name != NULL; i++) { |
---|
[2693] | 274 | ROAR_DBG("codecfilter_open(*): g_codecfilter[i].codec <-> codec => %i <-> %i", g_codecfilter[i].codec, codec); |
---|
[194] | 275 | if ( g_codecfilter[i].codec == codec ) { |
---|
| 276 | if ( !codecfilter || strcmp(codecfilter, g_codecfilter[i].name) == 0 ) { |
---|
| 277 | *codecfilter_id = i; |
---|
| 278 | filter = &g_codecfilter[i]; |
---|
| 279 | break; |
---|
| 280 | } |
---|
| 281 | } |
---|
| 282 | } |
---|
| 283 | |
---|
[196] | 284 | info->codecfilter = *codecfilter_id; |
---|
[194] | 285 | |
---|
| 286 | if (*codecfilter_id != -1) { |
---|
[2836] | 287 | if ( filter->open != NULL ) { |
---|
[571] | 288 | if ( (i = filter->open(inst, codec, info, filter)) == -1 ) { |
---|
| 289 | info->codecfilter = *codecfilter_id = -1; |
---|
| 290 | } |
---|
| 291 | return i; |
---|
[2836] | 292 | } else { |
---|
| 293 | // in case we can not open the filter we will not use it |
---|
| 294 | *codecfilter_id = -1; |
---|
| 295 | info->codecfilter = -1; |
---|
[571] | 296 | } |
---|
[194] | 297 | return 0; |
---|
| 298 | } |
---|
| 299 | |
---|
[2837] | 300 | return -1; // we found no filter -> ok |
---|
[194] | 301 | } |
---|
| 302 | |
---|
[180] | 303 | int codecfilter_close(CODECFILTER_USERDATA_T inst, int codecfilter) { |
---|
| 304 | ROAR_DBG("codecfilter_close(inst=%p, codecfilter=%i) = ?", inst, codecfilter); |
---|
| 305 | |
---|
| 306 | if ( codecfilter == -1 ) |
---|
| 307 | return -1; |
---|
| 308 | |
---|
| 309 | if ( g_codecfilter[codecfilter].close ) |
---|
| 310 | return g_codecfilter[codecfilter].close(inst); |
---|
| 311 | |
---|
| 312 | return 0; |
---|
| 313 | } |
---|
| 314 | |
---|
| 315 | int codecfilter_pause(CODECFILTER_USERDATA_T inst, int codecfilter, int newstate) { |
---|
| 316 | if ( codecfilter == -1 ) |
---|
| 317 | return -1; |
---|
| 318 | |
---|
| 319 | if ( g_codecfilter[codecfilter].pause ) |
---|
| 320 | return g_codecfilter[codecfilter].pause(inst, newstate); |
---|
| 321 | |
---|
| 322 | return 0; |
---|
| 323 | } |
---|
| 324 | |
---|
| 325 | int codecfilter_write(CODECFILTER_USERDATA_T inst, int codecfilter, char * buf, int len) { |
---|
| 326 | if ( codecfilter == -1 ) |
---|
| 327 | return -1; |
---|
| 328 | |
---|
| 329 | if ( g_codecfilter[codecfilter].write ) |
---|
| 330 | return g_codecfilter[codecfilter].write(inst, buf, len); |
---|
| 331 | |
---|
| 332 | return 0; |
---|
| 333 | } |
---|
| 334 | |
---|
| 335 | int codecfilter_read (CODECFILTER_USERDATA_T inst, int codecfilter, char * buf, int len) { |
---|
| 336 | if ( codecfilter == -1 ) |
---|
| 337 | return -1; |
---|
| 338 | |
---|
[541] | 339 | errno = 0; |
---|
| 340 | |
---|
[180] | 341 | if ( g_codecfilter[codecfilter].read ) |
---|
| 342 | return g_codecfilter[codecfilter].read(inst, buf, len); |
---|
| 343 | |
---|
| 344 | return 0; |
---|
| 345 | } |
---|
| 346 | |
---|
| 347 | int codecfilter_flush(CODECFILTER_USERDATA_T inst, int codecfilter) { |
---|
| 348 | if ( codecfilter == -1 ) |
---|
| 349 | return -1; |
---|
| 350 | |
---|
| 351 | if ( g_codecfilter[codecfilter].flush ) |
---|
| 352 | return g_codecfilter[codecfilter].flush(inst); |
---|
| 353 | |
---|
| 354 | return 0; |
---|
| 355 | } |
---|
| 356 | |
---|
[1144] | 357 | int codecfilter_delay(CODECFILTER_USERDATA_T inst, int codecfilter, uint_least32_t * delay) { |
---|
| 358 | ROAR_DBG("codecfilter_delay(inst=%p, codecfilter=%i, *delay=?) = ?", inst, codecfilter); |
---|
| 359 | |
---|
| 360 | if ( codecfilter == -1 ) |
---|
| 361 | return -1; |
---|
| 362 | |
---|
| 363 | if ( g_codecfilter[codecfilter].delay ) |
---|
| 364 | return g_codecfilter[codecfilter].delay(inst, delay); |
---|
| 365 | |
---|
| 366 | return -1; |
---|
| 367 | } |
---|
| 368 | |
---|
[1224] | 369 | int codecfilter_ctl (CODECFILTER_USERDATA_T inst, int codecfilter, int_least32_t cmd, void * data) { |
---|
[2086] | 370 | ROAR_DBG("codecfilter_ctl(inst=%p, codecfilter=%i, cmd=0x%.8x, data=%p) = ?", inst, codecfilter, cmd, data); |
---|
[1224] | 371 | if ( codecfilter == -1 ) |
---|
| 372 | return -1; |
---|
| 373 | |
---|
| 374 | if ( g_codecfilter[codecfilter].ctl ) |
---|
| 375 | return g_codecfilter[codecfilter].ctl(inst, cmd, data); |
---|
| 376 | |
---|
| 377 | return -1; |
---|
| 378 | } |
---|
| 379 | |
---|
| 380 | |
---|
[1144] | 381 | int codecfilter_delay_fulldyn(CODECFILTER_USERDATA_T inst, uint_least32_t * delay) { |
---|
| 382 | *delay = 0; // just to be sure |
---|
| 383 | return -1; |
---|
| 384 | } |
---|
| 385 | |
---|
[169] | 386 | //ll |
---|