From 5b968bb948b7904cc41c254b7851880e451f6906 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 4 Sep 2015 18:29:09 +0100 Subject: Better error checking in Resampler. --- src/lib/resampler.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/resampler.cc b/src/lib/resampler.cc index f54f4ec6a..78e1da114 100644 --- a/src/lib/resampler.cc +++ b/src/lib/resampler.cc @@ -39,6 +39,9 @@ Resampler::Resampler (int in, int out, int channels) , _channels (channels) { _swr_context = swr_alloc (); + if (!_swr_context) { + throw StringError (N_("could not allocate resampler contexct")); + } /* Sample formats */ av_opt_set_int (_swr_context, "isf", AV_SAMPLE_FMT_FLTP, 0); @@ -54,7 +57,12 @@ Resampler::Resampler (int in, int out, int channels) av_opt_set (_swr_context, "resampler", "soxr", 0); - swr_init (_swr_context); + int const r = swr_init (_swr_context); + if (r) { + char buf[256]; + av_strerror (r, buf, sizeof(buf)); + throw StringError (String::compose (N_ ("could not initialise sample-rate converter (%1)"), r)); + } } Resampler::~Resampler () -- cgit v1.2.3