Skip to content

Commit

Permalink
Report an error if seek fails when calculating audio duration
Browse files Browse the repository at this point in the history
This happens when piping audio to stdin, with an output that
requires the duration, such as when using the --zoom auto option

See bbc#176
  • Loading branch information
chrisn committed Oct 12, 2022
1 parent de4df58 commit f18a148
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/OptionHandler.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//------------------------------------------------------------------------------
//
// Copyright 2013-2021 BBC Research and Development
// Copyright 2013-2022 BBC Research and Development
//
// Author: Chris Needham
//
Expand Down Expand Up @@ -195,6 +195,8 @@ static std::pair<bool, double> getDuration(

if (FileUtil::isStdioFilename(input_filename.string().c_str())) {
if (fseek(stdin, 0, SEEK_SET) != 0) {
log(Info) << "Failed to seek to start of audio\n";

return std::make_pair(false, 0);
}
}
Expand Down Expand Up @@ -390,7 +392,7 @@ bool OptionHandler::renderWaveformImage(
auto result = getDuration(input_filename, input_format, !options.getQuiet());

if (!result.first) {
// error_stream << "Failed to get audio duration\n";
// log(Error) << "Failed to get audio duration\n";
return false;
}

Expand Down

0 comments on commit f18a148

Please sign in to comment.