summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-09-04 18:29:09 +0100
committerCarl Hetherington <cth@carlh.net>2015-09-04 20:59:48 +0100
commit5b968bb948b7904cc41c254b7851880e451f6906 (patch)
tree2199b2dcf38f66f18bae79e066c3a61d932891cc /src
parent8cddae8f947c3d4970c32da9e981f95d4036d3ea (diff)
Better error checking in Resampler.
Diffstat (limited to 'src')
-rw-r--r--src/lib/resampler.cc10
1 files changed, 9 insertions, 1 deletions
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 ()