From 054ead24cc25945199d0d6dcb986e807ac12911d Mon Sep 17 00:00:00 2001 From: Sakari Bergen Date: Wed, 8 Jan 2014 20:33:17 +0200 Subject: Fix dither data width assertions and related tests Fixes 32-bit export This was broken from the start, and was broken in a new way in 52309c0c4fc107cdde9a99f2340fe4d8cf4ff382 --- libs/audiographer/src/general/sample_format_converter.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'libs/audiographer/src') diff --git a/libs/audiographer/src/general/sample_format_converter.cc b/libs/audiographer/src/general/sample_format_converter.cc index 5fe9a1185b..aaeda09477 100644 --- a/libs/audiographer/src/general/sample_format_converter.cc +++ b/libs/audiographer/src/general/sample_format_converter.cc @@ -54,10 +54,14 @@ template <> void SampleFormatConverter::init (framecnt_t max_frames, int type, int data_width) { - // GDither is broken with GDither32bit if the dither depth is bigger than 24 - if(throw_level (ThrowObject) && data_width > 24) { - throw Exception (*this, "Trying to use SampleFormatConverter a data width > 24"); + if(throw_level (ThrowObject) && data_width > 32) { + throw Exception (*this, "Trying to use SampleFormatConverter with a data width > 32"); } + + // GDither is broken with GDither32bit if the dither depth is bigger than 24. + // And since floats only have 24 bits of data, we are fine with this. + data_width = std::min(data_width, 24); + init_common (max_frames); dither = gdither_new ((GDitherType) type, channels, GDither32bit, data_width); } @@ -68,7 +72,7 @@ SampleFormatConverter::init (framecnt_t max_frames, int type, int data_ { if (throw_level (ThrowObject) && data_width > 16) { throw Exception (*this, boost::str(boost::format - ("Data width (%1) too large for int16_t") + ("Data width (%1%) too large for int16_t") % data_width)); } init_common (max_frames); @@ -81,7 +85,7 @@ SampleFormatConverter::init (framecnt_t max_frames, int type, int data_ { if (throw_level (ThrowObject) && data_width > 8) { throw Exception (*this, boost::str(boost::format - ("Data width (%1) too large for uint8_t") + ("Data width (%1%) too large for uint8_t") % data_width)); } init_common (max_frames); -- cgit v1.2.3