aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/decoder/DecoderAPI.cxx9
-rw-r--r--src/filter/plugins/ConvertFilterPlugin.cxx6
-rw-r--r--src/pcm/PcmConvert.cxx10
-rw-r--r--src/pcm/PcmConvert.hxx6
4 files changed, 14 insertions, 17 deletions
diff --git a/src/decoder/DecoderAPI.cxx b/src/decoder/DecoderAPI.cxx
index b214b91a8..ae600260f 100644
--- a/src/decoder/DecoderAPI.cxx
+++ b/src/decoder/DecoderAPI.cxx
@@ -31,6 +31,7 @@
#include "DetachedSong.hxx"
#include "input/InputStream.hxx"
#include "util/Error.hxx"
+#include "util/ConstBuffer.hxx"
#include "Log.hxx"
#include <assert.h>
@@ -472,9 +473,8 @@ decoder_data(Decoder &decoder,
assert(dc.in_audio_format != dc.out_audio_format);
Error error;
- data = decoder.convert->Convert(data, length,
- &length,
- error);
+ auto result = decoder.convert->Convert({data, length},
+ error);
if (data == nullptr) {
/* the PCM conversion has failed - stop
playback, since we have no better way to
@@ -482,6 +482,9 @@ decoder_data(Decoder &decoder,
LogError(error);
return DecoderCommand::STOP;
}
+
+ data = result.data;
+ length = result.size;
} else {
assert(dc.in_audio_format == dc.out_audio_format);
}
diff --git a/src/filter/plugins/ConvertFilterPlugin.cxx b/src/filter/plugins/ConvertFilterPlugin.cxx
index 27e6774f8..535330cfe 100644
--- a/src/filter/plugins/ConvertFilterPlugin.cxx
+++ b/src/filter/plugins/ConvertFilterPlugin.cxx
@@ -24,6 +24,7 @@
#include "filter/FilterRegistry.hxx"
#include "pcm/PcmConvert.hxx"
#include "util/Manual.hxx"
+#include "util/ConstBuffer.hxx"
#include "AudioFormat.hxx"
#include "poison.h"
@@ -130,8 +131,9 @@ ConvertFilter::FilterPCM(const void *src, size_t src_size,
return src;
}
- return state->Convert(src, src_size, dest_size_r,
- error);
+ auto result = state->Convert({src, src_size}, error);
+ *dest_size_r = result.size;
+ return result.data;
}
const struct filter_plugin convert_filter_plugin = {
diff --git a/src/pcm/PcmConvert.cxx b/src/pcm/PcmConvert.cxx
index ad79e60fc..ba9a691fc 100644
--- a/src/pcm/PcmConvert.cxx
+++ b/src/pcm/PcmConvert.cxx
@@ -117,12 +117,9 @@ PcmConvert::Close()
#endif
}
-const void *
-PcmConvert::Convert(const void *src, size_t src_size,
- size_t *dest_size_r,
- Error &error)
+ConstBuffer<void>
+PcmConvert::Convert(ConstBuffer<void> buffer, Error &error)
{
- ConstBuffer<void> buffer(src, src_size);
AudioFormat format = src_format;
if (format.format == SampleFormat::DSD) {
@@ -164,6 +161,5 @@ PcmConvert::Convert(const void *src, size_t src_size,
format.channels = dest_format.channels;
}
- *dest_size_r = buffer.size;
- return buffer.data;
+ return buffer;
}
diff --git a/src/pcm/PcmConvert.hxx b/src/pcm/PcmConvert.hxx
index c65835421..9d63e07c9 100644
--- a/src/pcm/PcmConvert.hxx
+++ b/src/pcm/PcmConvert.hxx
@@ -70,16 +70,12 @@ public:
*
* @param src_format the source audio format
* @param src the source PCM buffer
- * @param src_size the size of #src in bytes
* @param dest_format the requested destination audio format
- * @param dest_size_r returns the number of bytes of the destination buffer
* @param error_r location to store the error occurring, or nullptr to
* ignore errors
* @return the destination buffer, or nullptr on error
*/
- const void *Convert(const void *src, size_t src_size,
- size_t *dest_size_r,
- Error &error);
+ ConstBuffer<void> Convert(ConstBuffer<void> src, Error &error);
};
bool