diff --git a/src/filter/plugins/RouteFilterPlugin.cxx b/src/filter/plugins/RouteFilterPlugin.cxx index d8d98a08b..796af56a4 100644 --- a/src/filter/plugins/RouteFilterPlugin.cxx +++ b/src/filter/plugins/RouteFilterPlugin.cxx @@ -50,7 +50,6 @@ #include "util/StringStrip.hxx" #include "util/RuntimeError.hxx" #include "util/ConstBuffer.hxx" -#include "util/WritableBuffer.hxx" #include #include @@ -237,7 +236,7 @@ RouteFilter::FilterPCM(ConstBuffer src) void *const result = output_buffer.Get(result_size); // A moving pointer that always refers to the currently filled channel of the currently handled frame, in the output - auto *chan_destination = (uint8_t *)result; + auto *chan_destination = (std::byte *)result; // Perform our copy operations, with N input channels and M output channels for (unsigned int s=0; s @@ -42,7 +41,7 @@ DetectFilterOutputFormat(const AudioFormat &in_audio_format, const size_t silence_size = in_audio_format.GetFrameSize(); assert(sizeof(silence) >= silence_size); - PcmSilence(WritableBuffer{&silence, silence_size}, + PcmSilence(std::as_writable_bytes(std::span{silence}), in_audio_format.format); Frame frame; diff --git a/src/pcm/Export.cxx b/src/pcm/Export.cxx index 40a00bdaa..5f5858ae8 100644 --- a/src/pcm/Export.cxx +++ b/src/pcm/Export.cxx @@ -23,7 +23,6 @@ #include "Silence.hxx" #include "util/ByteReverse.hxx" #include "util/ConstBuffer.hxx" -#include "util/WritableBuffer.hxx" #include @@ -94,7 +93,7 @@ PcmExport::Open(SampleFormat sample_format, unsigned _channels, } /* prepare a moment of silence for GetSilence() */ - char buffer[sizeof(silence_buffer)]; + std::byte buffer[sizeof(silence_buffer)]; const size_t buffer_size = GetInputBlockSize(); assert(buffer_size < sizeof(buffer)); PcmSilence({buffer, buffer_size}, src_sample_format); diff --git a/src/pcm/PcmChannels.cxx b/src/pcm/PcmChannels.cxx index b7108f564..91189ab60 100644 --- a/src/pcm/PcmChannels.cxx +++ b/src/pcm/PcmChannels.cxx @@ -23,7 +23,6 @@ #include "Silence.hxx" #include "Traits.hxx" #include "util/ConstBuffer.hxx" -#include "util/WritableBuffer.hxx" #include #include @@ -109,7 +108,7 @@ StereoToN(typename Traits::pointer dest, assert((end - src) % 2 == 0); std::array silence; - PcmSilence({&silence.front(), sizeof(silence)}, F); + PcmSilence(std::as_writable_bytes(std::span{silence}), F); while (src != end) { /* copy left/right to front-left/front-right, which is diff --git a/src/pcm/Silence.cxx b/src/pcm/Silence.cxx index 7c7395bb6..de17f7dd0 100644 --- a/src/pcm/Silence.cxx +++ b/src/pcm/Silence.cxx @@ -20,16 +20,15 @@ #include "Silence.hxx" #include "Traits.hxx" #include "SampleFormat.hxx" -#include "util/WritableBuffer.hxx" -#include +#include void -PcmSilence(WritableBuffer dest, SampleFormat format) noexcept +PcmSilence(std::span dest, SampleFormat format) noexcept { - uint8_t pattern = 0; + std::byte pattern{0}; if (format == SampleFormat::DSD) - pattern = SampleTraits::SILENCE; + pattern = std::byte{SampleTraits::SILENCE}; - memset(dest.data, pattern, dest.size); + std::fill(dest.begin(), dest.end(), pattern); } diff --git a/src/pcm/Silence.hxx b/src/pcm/Silence.hxx index 7e3ef6743..1e9f68bd0 100644 --- a/src/pcm/Silence.hxx +++ b/src/pcm/Silence.hxx @@ -20,15 +20,16 @@ #ifndef MPD_PCM_SILENCE_HXX #define MPD_PCM_SILENCE_HXX +#include #include +#include -template struct WritableBuffer; enum class SampleFormat : uint8_t; /** * Fill the given buffer with the format-specific silence pattern. */ void -PcmSilence(WritableBuffer dest, SampleFormat format) noexcept; +PcmSilence(std::span dest, SampleFormat format) noexcept; #endif diff --git a/src/pcm/Volume.cxx b/src/pcm/Volume.cxx index c0183cdc3..415ac3ec4 100644 --- a/src/pcm/Volume.cxx +++ b/src/pcm/Volume.cxx @@ -21,7 +21,6 @@ #include "Silence.hxx" #include "Traits.hxx" #include "util/ConstBuffer.hxx" -#include "util/WritableBuffer.hxx" #include "util/RuntimeError.hxx" #include "util/TransformN.hxx" @@ -204,7 +203,8 @@ PcmVolume::Apply(ConstBuffer src) noexcept if (volume == 0) { /* optimized special case: 0% volume = memset(0) */ - PcmSilence({data, dest_size}, format); + PcmSilence(std::span{(std::byte *)data, dest_size}, + format); return { data, dest_size }; }