From 8af4aca43ad1939c578f24e998d2d2ff58e7cc2c Mon Sep 17 00:00:00 2001 From: Sergio Date: Mon, 16 Jun 2014 15:48:00 +0200 Subject: fifo silence bug fix --- src/FileInput.cpp | 8 ++++++++ src/FileInput.h | 1 + src/dabplus-enc.cpp | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/FileInput.cpp b/src/FileInput.cpp index 9ec988b..b116e80 100644 --- a/src/FileInput.cpp +++ b/src/FileInput.cpp @@ -96,6 +96,14 @@ ssize_t FileInput::read(uint8_t* buf, size_t length) return pcmread; } +int FileInput::eof() +{ + int eof=feof(m_in_fh); + clearerr(m_in_fh); + return eof; +} + + FileInput::~FileInput() { if (m_raw_input && m_in_fh) { diff --git a/src/FileInput.h b/src/FileInput.h index 9330577..4f6f75e 100644 --- a/src/FileInput.h +++ b/src/FileInput.h @@ -45,6 +45,7 @@ class FileInput * Returns the number of bytes read. */ ssize_t read(uint8_t* buf, size_t length); + int eof(); protected: const char* m_filename; diff --git a/src/dabplus-enc.cpp b/src/dabplus-enc.cpp index f186dbe..9cb9333 100644 --- a/src/dabplus-enc.cpp +++ b/src/dabplus-enc.cpp @@ -597,9 +597,10 @@ int main(int argc, char *argv[]) break; } else if (read != input_size) { - if (inFifoSilence && ((errno==EAGAIN)||(errno==0))) { + if (inFifoSilence && file_in.eof()) { memset(input_buf, 0, input_size); read = input_size; + usleep((long int)input_size*1000000/(bytes_per_sample*channels*sample_rate)); } else { fprintf(stderr, "Short file read !\n"); break; -- cgit v1.2.3