From 3bd1797b89ae9bc6664f63b341cf8838b8b5fe03 Mon Sep 17 00:00:00 2001 From: ha7ilm Date: Sun, 1 Nov 2015 21:20:42 +0000 Subject: [PATCH] Added mono2stereo_i16, convert_f_samplerf and environment variable CSDR_PRINT_BUFSIZES. --- csdr.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/csdr.c b/csdr.c index 922dcf7..1f10e26 100644 --- a/csdr.c +++ b/csdr.c @@ -109,6 +109,7 @@ char usage[]= int env_csdr_fixed_bufsize = 1024; int env_csdr_fixed_big_bufsize = 1024*16; int env_csdr_dynamic_bufsize_on = 0; +int env_csdr_print_bufsizes = 0; int bigbufs = 0; //change on on 2015-08-29: we don't yield at all. fread() will do it if it blocks @@ -248,7 +249,7 @@ int initialize_buffers() { if(!(the_bufsize=getbufsize())) return 0; the_bufsize=unitround(the_bufsize); - fprintf(stderr,"%s %s: buffer size set to %d\n",argv_global[0], argv_global[1], the_bufsize); + if(env_csdr_print_bufsizes) fprintf(stderr,"%s %s: buffer size set to %d\n",argv_global[0], argv_global[1], the_bufsize); input_buffer = (float*) malloc(the_bufsize*sizeof(float) * 2); //need the 2× because we might also put complex floats into it output_buffer = (float*) malloc(the_bufsize*sizeof(float) * 2); buffer_u8 = (unsigned char*)malloc(the_bufsize*sizeof(unsigned char)); @@ -262,7 +263,7 @@ int sendbufsize(int size) //The first word is a preamble, "csdr". //If the next csdr process detects it, sets the buffer size according to the second word if(!env_csdr_dynamic_bufsize_on) return env_csdr_fixed_bufsize; - fprintf(stderr,"%s %s: next process proposed input buffer size is %d\n",argv_global[0], argv_global[1], size); + if(env_csdr_print_bufsizes) fprintf(stderr,"%s %s: next process proposed input buffer size is %d\n",argv_global[0], argv_global[1], size); int send_first[2]; memcpy((char*)send_first, SETBUF_PREAMBLE, 4*sizeof(char)); send_first[1] = size; @@ -288,6 +289,11 @@ int parse_env() env_csdr_fixed_bufsize = atoi(envtmp); } } + envtmp=getenv("CSDR_PRINT_BUFSIZES"); + if(envtmp) + { + env_csdr_print_bufsizes = atoi(envtmp); + } } int main(int argc, char *argv[]) @@ -299,7 +305,7 @@ int main(int argc, char *argv[]) fcntl(STDIN_FILENO, F_SETPIPE_SZ, 65536*32); fcntl(STDOUT_FILENO, F_SETPIPE_SZ, 65536*32); - fprintf(stderr, "csdr: F_SETPIPE_SZ\n"); + //fprintf(stderr, "csdr: F_SETPIPE_SZ\n"); if(!strcmp(argv[1],"setbuf")) { @@ -1534,6 +1540,9 @@ int main(int argc, char *argv[]) if(!strcmp(argv[1],"dsb_fc")) { + float q_value = 0; + if(argc>=3) sscanf(argv[2],"%g",&q_value); + if(!sendbufsize(initialize_buffers())) return -2; for(;;) { @@ -1542,13 +1551,38 @@ int main(int argc, char *argv[]) for(int i=0;i