From bb6ee71f08478cc3c82883bcefe1f97368bd7c90 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 14 Mar 2014 23:23:16 +0100 Subject: pcm/PcmFormat: don't use WritableBuffer The previous commit eliminated the need for that. --- src/pcm/PcmFormat.cxx | 48 ++++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) (limited to 'src/pcm') diff --git a/src/pcm/PcmFormat.cxx b/src/pcm/PcmFormat.cxx index 7c6eff790..f2d71a6fb 100644 --- a/src/pcm/PcmFormat.cxx +++ b/src/pcm/PcmFormat.cxx @@ -25,17 +25,9 @@ #include "FloatConvert.hxx" #include "ShiftConvert.hxx" #include "util/ConstBuffer.hxx" -#include "util/WritableBuffer.hxx" #include "PcmDither.cxx" // including the .cxx file to get inlined templates -template -static inline ConstBuffer -ToConst(WritableBuffer b) -{ - return { b.data, b.size }; -} - /** * Wrapper for a class that converts one sample at a time into one * that converts a buffer at a time. @@ -88,7 +80,7 @@ struct FloatToInteger : PerSampleConvert> {}; template -static WritableBuffer +static ConstBuffer AllocateConvert(PcmBuffer &buffer, C convert, ConstBuffer src) { @@ -98,7 +90,7 @@ AllocateConvert(PcmBuffer &buffer, C convert, } template> -static WritableBuffer +static ConstBuffer AllocateFromFloat(PcmBuffer &buffer, ConstBuffer src) { return AllocateConvert(buffer, FloatToInteger(), src); @@ -107,27 +99,27 @@ AllocateFromFloat(PcmBuffer &buffer, ConstBuffer src) static ConstBuffer pcm_allocate_8_to_16(PcmBuffer &buffer, ConstBuffer src) { - return ToConst(AllocateConvert(buffer, Convert8To16(), src)); + return AllocateConvert(buffer, Convert8To16(), src); } static ConstBuffer pcm_allocate_24p32_to_16(PcmBuffer &buffer, PcmDither &dither, ConstBuffer src) { - return ToConst(AllocateConvert(buffer, Convert24To16(dither), src)); + return AllocateConvert(buffer, Convert24To16(dither), src); } static ConstBuffer pcm_allocate_32_to_16(PcmBuffer &buffer, PcmDither &dither, ConstBuffer src) { - return ToConst(AllocateConvert(buffer, Convert32To16(dither), src)); + return AllocateConvert(buffer, Convert32To16(dither), src); } static ConstBuffer pcm_allocate_float_to_16(PcmBuffer &buffer, ConstBuffer src) { - return ToConst(AllocateFromFloat(buffer, src)); + return AllocateFromFloat(buffer, src); } ConstBuffer @@ -173,13 +165,13 @@ struct Convert16To24 static ConstBuffer pcm_allocate_8_to_24(PcmBuffer &buffer, ConstBuffer src) { - return ToConst(AllocateConvert(buffer, Convert8To24(), src)); + return AllocateConvert(buffer, Convert8To24(), src); } static ConstBuffer pcm_allocate_16_to_24(PcmBuffer &buffer, ConstBuffer src) { - return ToConst(AllocateConvert(buffer, Convert16To24(), src)); + return AllocateConvert(buffer, Convert16To24(), src); } struct Convert32To24 @@ -189,10 +181,10 @@ struct Convert32To24 static ConstBuffer pcm_allocate_32_to_24(PcmBuffer &buffer, ConstBuffer src) { - return ToConst(AllocateConvert(buffer, Convert32To24(), src)); + return AllocateConvert(buffer, Convert32To24(), src); } -static WritableBuffer +static ConstBuffer pcm_allocate_float_to_24(PcmBuffer &buffer, ConstBuffer src) { return AllocateFromFloat(buffer, src); @@ -223,8 +215,8 @@ pcm_convert_to_24(PcmBuffer &buffer, ConstBuffer::FromVoid(src)); case SampleFormat::FLOAT: - return ToConst(pcm_allocate_float_to_24(buffer, - ConstBuffer::FromVoid(src))); + return pcm_allocate_float_to_24(buffer, + ConstBuffer::FromVoid(src)); } return nullptr; @@ -245,25 +237,25 @@ struct Convert24To32 static ConstBuffer pcm_allocate_8_to_32(PcmBuffer &buffer, ConstBuffer src) { - return ToConst(AllocateConvert(buffer, Convert8To32(), src)); + return AllocateConvert(buffer, Convert8To32(), src); } static ConstBuffer pcm_allocate_16_to_32(PcmBuffer &buffer, ConstBuffer src) { - return ToConst(AllocateConvert(buffer, Convert16To32(), src)); + return AllocateConvert(buffer, Convert16To32(), src); } static ConstBuffer pcm_allocate_24p32_to_32(PcmBuffer &buffer, ConstBuffer src) { - return ToConst(AllocateConvert(buffer, Convert24To32(), src)); + return AllocateConvert(buffer, Convert24To32(), src); } static ConstBuffer pcm_allocate_float_to_32(PcmBuffer &buffer, ConstBuffer src) { - return ToConst(AllocateFromFloat(buffer, src)); + return AllocateFromFloat(buffer, src); } ConstBuffer @@ -313,25 +305,25 @@ struct Convert32ToFloat static ConstBuffer pcm_allocate_8_to_float(PcmBuffer &buffer, ConstBuffer src) { - return ToConst(AllocateConvert(buffer, Convert8ToFloat(), src)); + return AllocateConvert(buffer, Convert8ToFloat(), src); } static ConstBuffer pcm_allocate_16_to_float(PcmBuffer &buffer, ConstBuffer src) { - return ToConst(AllocateConvert(buffer, Convert16ToFloat(), src)); + return AllocateConvert(buffer, Convert16ToFloat(), src); } static ConstBuffer pcm_allocate_24p32_to_float(PcmBuffer &buffer, ConstBuffer src) { - return ToConst(AllocateConvert(buffer, Convert24ToFloat(), src)); + return AllocateConvert(buffer, Convert24ToFloat(), src); } static ConstBuffer pcm_allocate_32_to_float(PcmBuffer &buffer, ConstBuffer src) { - return ToConst(AllocateConvert(buffer, Convert32ToFloat(), src)); + return AllocateConvert(buffer, Convert32ToFloat(), src); } ConstBuffer -- cgit v1.2.3