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