lib/ffmpeg/DetectFilterFormat: return AudioFormat::Undefined() on EAGAIN
This commit is contained in:
@@ -54,6 +54,9 @@ PreparedFfmpegFilter::Open(AudioFormat &in_audio_format)
|
|||||||
Ffmpeg::DetectFilterOutputFormat(in_audio_format, buffer_src,
|
Ffmpeg::DetectFilterOutputFormat(in_audio_format, buffer_src,
|
||||||
buffer_sink);
|
buffer_sink);
|
||||||
|
|
||||||
|
if (!out_audio_format.IsDefined())
|
||||||
|
throw std::runtime_error("Unable to determine FFmpeg filter output format");
|
||||||
|
|
||||||
return std::make_unique<FfmpegFilter>(in_audio_format,
|
return std::make_unique<FfmpegFilter>(in_audio_format,
|
||||||
out_audio_format,
|
out_audio_format,
|
||||||
std::move(graph),
|
std::move(graph),
|
||||||
|
@@ -62,8 +62,14 @@ DetectFilterOutputFormat(const AudioFormat &in_audio_format,
|
|||||||
frame.Unref();
|
frame.Unref();
|
||||||
|
|
||||||
err = av_buffersink_get_frame(&buffer_sink, frame.get());
|
err = av_buffersink_get_frame(&buffer_sink, frame.get());
|
||||||
if (err < 0)
|
if (err < 0) {
|
||||||
|
if (err == AVERROR(EAGAIN))
|
||||||
|
/* one sample was not enough input data for
|
||||||
|
the given filter graph */
|
||||||
|
return AudioFormat::Undefined();
|
||||||
|
|
||||||
throw MakeFfmpegError(err, "av_buffersink_get_frame() failed");
|
throw MakeFfmpegError(err, "av_buffersink_get_frame() failed");
|
||||||
|
}
|
||||||
|
|
||||||
const SampleFormat sample_format = FromFfmpegSampleFormat(AVSampleFormat(frame->format));
|
const SampleFormat sample_format = FromFfmpegSampleFormat(AVSampleFormat(frame->format));
|
||||||
if (sample_format == SampleFormat::UNDEFINED)
|
if (sample_format == SampleFormat::UNDEFINED)
|
||||||
|
@@ -35,6 +35,9 @@ namespace Ffmpeg {
|
|||||||
* between.
|
* between.
|
||||||
*
|
*
|
||||||
* This function can throw if the FFmpeg filter fails.
|
* This function can throw if the FFmpeg filter fails.
|
||||||
|
*
|
||||||
|
* @return the output format or AudioFormat::Undefined() if it was not
|
||||||
|
* possible to determine the format
|
||||||
*/
|
*/
|
||||||
AudioFormat
|
AudioFormat
|
||||||
DetectFilterOutputFormat(const AudioFormat &in_audio_format,
|
DetectFilterOutputFormat(const AudioFormat &in_audio_format,
|
||||||
|
Reference in New Issue
Block a user