summaryrefslogtreecommitdiff
path: root/libs/audiographer/src
diff options
context:
space:
mode:
authorSakari Bergen <sakari.bergen@beatwaves.net>2013-11-23 18:42:14 +0200
committerSakari Bergen <sakari.bergen@beatwaves.net>2013-11-23 18:43:54 +0200
commit52309c0c4fc107cdde9a99f2340fe4d8cf4ff382 (patch)
tree1154d950607b7b7890920459661cb64e22046e2b /libs/audiographer/src
parentaf9ac37b6007a72a07a5027a4c98a563f76d3640 (diff)
Fix invalid assertions in AudioGrapher SampleFormatConverter
This fixes an export crash with e.g. 8-bit export
Diffstat (limited to 'libs/audiographer/src')
-rw-r--r--libs/audiographer/src/general/sample_format_converter.cc25
1 files changed, 13 insertions, 12 deletions
diff --git a/libs/audiographer/src/general/sample_format_converter.cc b/libs/audiographer/src/general/sample_format_converter.cc
index ea70dc6094..5fe9a1185b 100644
--- a/libs/audiographer/src/general/sample_format_converter.cc
+++ b/libs/audiographer/src/general/sample_format_converter.cc
@@ -52,25 +52,24 @@ SampleFormatConverter<float>::init (framecnt_t max_frames, int /* type */, int d
template <>
void
-SampleFormatConverter<int32_t>::init (framecnt_t max_frames, int /*type*/, int data_width)
+SampleFormatConverter<int32_t>::init (framecnt_t max_frames, int type, int data_width)
{
- if(throw_level (ThrowObject) && data_width < 24) {
- throw Exception (*this, "Trying to use SampleFormatConverter<int32_t> for data widths < 24");
+ // 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<int32_t> a data width > 24");
}
-
init_common (max_frames);
-
- // GDither is broken with GDither32bit if the dither depth
- // is bigger than 24, so lets just use that...
- dither = gdither_new (GDitherNone, channels, GDither32bit, 24);
+ dither = gdither_new ((GDitherType) type, channels, GDither32bit, data_width);
}
template <>
void
SampleFormatConverter<int16_t>::init (framecnt_t max_frames, int type, int data_width)
{
- if (throw_level (ThrowObject) && data_width != 16) {
- throw Exception (*this, "Unsupported data width");
+ if (throw_level (ThrowObject) && data_width > 16) {
+ throw Exception (*this, boost::str(boost::format
+ ("Data width (%1) too large for int16_t")
+ % data_width));
}
init_common (max_frames);
dither = gdither_new ((GDitherType) type, channels, GDither16bit, data_width);
@@ -80,8 +79,10 @@ template <>
void
SampleFormatConverter<uint8_t>::init (framecnt_t max_frames, int type, int data_width)
{
- if (throw_level (ThrowObject) && data_width != 8) {
- throw Exception (*this, "Unsupported data width");
+ if (throw_level (ThrowObject) && data_width > 8) {
+ throw Exception (*this, boost::str(boost::format
+ ("Data width (%1) too large for uint8_t")
+ % data_width));
}
init_common (max_frames);
dither = gdither_new ((GDitherType) type, channels, GDither8bit, data_width);