From e056c97d9df3e6069f1f60e16c0eca6c43c712af Mon Sep 17 00:00:00 2001 From: lwvmobile Date: Wed, 22 Mar 2023 20:07:02 -0400 Subject: [PATCH] Issue #105 - Make Work with Named Pipe (FIFO) --- src/dsd_audio.c | 21 ++++++++++++++++++++- src/dsd_main.c | 2 +- src/dsd_ncurses.c | 4 ++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/dsd_audio.c b/src/dsd_audio.c index 8e2eaea..bc48d3b 100644 --- a/src/dsd_audio.c +++ b/src/dsd_audio.c @@ -546,7 +546,7 @@ openAudioInDevice (dsd_opts * opts) extension = strrchr(opts->audio_in_dev, ch); //return extension if this is a .wav or .bin file //if no extension set, give default of .wav -- bugfix for github issue #105 - if (extension == NULL) extension = ".wav"; + // if (extension == NULL) extension = ".wav"; // get info of device/file if (strncmp(opts->audio_in_dev, "-", 1) == 0) @@ -610,6 +610,25 @@ openAudioInDevice (dsd_opts * opts) { opts->audio_in_type = 5; } + + //if no extension set, treat as named pipe or extensionless wav file -- bugfix for github issue #105 + else if (extension == NULL) + { + opts->audio_in_type = 2; + opts->audio_in_file_info = calloc(1, sizeof(SF_INFO)); + opts->audio_in_file_info->samplerate = opts->wav_sample_rate; + opts->audio_in_file_info->channels = 1; + opts->audio_in_file_info->seekable = 0; + opts->audio_in_file_info->format = SF_FORMAT_RAW | SF_FORMAT_PCM_16 | SF_ENDIAN_LITTLE; + opts->audio_in_file = sf_open(opts->audio_in_dev, SFM_READ, opts->audio_in_file_info); + + if (opts->audio_in_file == NULL) + { + fprintf(stderr, "Error, couldn't open file/pipe with libsndfile: %s\n", sf_strerror(NULL)); + exit(1); + } + } + else if (strncmp(extension, ".bin", 3) == 0) { struct stat stat_buf; diff --git a/src/dsd_main.c b/src/dsd_main.c index 53ee6c8..080313c 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -52,7 +52,7 @@ char * FM_banner[9] = { " ██║ ██║ ╚═══██╗██║ ██║   ██╔══╝ ██║╚██╔╝██║██╔══╝ ", " ██████╔╝██████╔╝██████╔╝   ██║ ██║ ╚═╝ ██║███████╗", " ╚═════╝ ╚═════╝ ╚═════╝    ╚═╝ ╚═╝ ╚═╝╚══════╝", - " 'Aero' Edition v2.0.0-68-g85eea59 Windows 32-bit RC5b " + " 'Aero' Edition v2.0.0-70-gf3c0199 Windows 32-bit RC5b " }; int comp (const void *a, const void *b) diff --git a/src/dsd_ncurses.c b/src/dsd_ncurses.c index 1f2c813..5683db3 100644 --- a/src/dsd_ncurses.c +++ b/src/dsd_ncurses.c @@ -2061,7 +2061,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) if (opts->ncurses_compact == 1) { printw ("------------------------------------------------------------------------------\n"); - printw ("| Digital Speech Decoder: Florida Man Edition - Aero %s \n", "v2.0.0-68-g85eea59 RC5b"); + printw ("| Digital Speech Decoder: Florida Man Edition - Aero %s \n", "v2.0.0-70-gf3c0199 RC5b"); } if (opts->ncurses_compact == 0) { @@ -2073,7 +2073,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) if (i == 2) printw (" 'q' to Quit "); if (i == 4) printw (" MBElib %s", versionstr); if (i == 5) printw (" %s ", "Aero RC5b"); //printw (" %s \n", GIT_TAG); - if (i == 6) printw (" %s \n", "v2.0.0-68-g85eea59"); //printw (" %s \n", GIT_TAG); + if (i == 6) printw (" %s \n", "v2.0.0-70-gf3c0199"); //printw (" %s \n", GIT_TAG); else printw ("\n"); } attroff(COLOR_PAIR(6)); //6