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