File tree Expand file tree Collapse file tree 3 files changed +13
-9
lines changed
Expand file tree Collapse file tree 3 files changed +13
-9
lines changed Original file line number Diff line number Diff line change 11// ------------------------------------------------------------------------------
22//
3- // Copyright 2022 BBC Research and Development
3+ // Copyright 2023 BBC Research and Development
44//
55// Author: Chris Needham
66//
@@ -45,18 +45,19 @@ bool isStdioFilename(const char* filename)
4545
4646// ------------------------------------------------------------------------------
4747
48- bool isStdinFifo () {
48+ bool isStdinSeekable ()
49+ {
4950 struct stat stat_buf;
5051
5152 int result = fstat (fileno (stdin), &stat_buf);
5253
5354 if (result >= 0 ) {
54- if (S_ISFIFO (stat_buf.st_mode )) {
55- return true ;
55+ if (S_ISFIFO (stat_buf.st_mode ) || S_ISSOCK (stat_buf. st_mode ) ) {
56+ return false ;
5657 }
5758 }
5859
59- return false ;
60+ return true ;
6061}
6162
6263// ------------------------------------------------------------------------------
Original file line number Diff line number Diff line change 11// ------------------------------------------------------------------------------
22//
3- // Copyright 2022 BBC Research and Development
3+ // Copyright 2023 BBC Research and Development
44//
55// Author: Chris Needham
66//
2828
2929namespace FileUtil {
3030 bool isStdioFilename (const char * filename);
31- bool isStdinFifo ();
31+ bool isStdinSeekable ();
3232 const char * getInputFilename (const char * filename);
3333 const char * getOutputFilename (const char * filename);
3434}
Original file line number Diff line number Diff line change @@ -388,9 +388,13 @@ bool OptionHandler::renderWaveformImage(
388388 );
389389 }
390390 else {
391+ // Seeking to the start of the audio won't work if reading from a pipe
392+ // or a socket, so we buffer the entire audio data in memory.
393+
391394 if (FileUtil::isStdioFilename (input_filename.string ().c_str ()) &&
392- FileUtil::isStdinFifo () &&
395+ ! FileUtil::isStdinSeekable () &&
393396 calculate_duration) {
397+
394398 std::unique_ptr<AudioFileReader> audio_file_reader (
395399 createAudioFileReader (input_filename, input_format)
396400 );
@@ -420,7 +424,6 @@ bool OptionHandler::renderWaveformImage(
420424 }
421425
422426 output_samples_per_pixel = input_buffer.getSamplesPerPixel ();
423-
424427 }
425428 else {
426429 if (calculate_duration) {
You can’t perform that action at this time.
0 commit comments