output/*: use std::span instead of ConstBuffer
This commit is contained in:
@@ -35,7 +35,6 @@
|
||||
#include "util/Manual.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "util/ConstBuffer.hxx"
|
||||
#include "event/MultiSocketMonitor.hxx"
|
||||
#include "event/InjectEvent.hxx"
|
||||
#include "event/FineTimerEvent.hxx"
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "output/Features.h"
|
||||
#include "thread/Mutex.hxx"
|
||||
#include "util/ScopeExit.hxx"
|
||||
#include "util/ConstBuffer.hxx"
|
||||
#include "util/IterableSplitString.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
@@ -32,6 +31,7 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
#include <span>
|
||||
|
||||
#include <jack/jack.h>
|
||||
#include <jack/types.h>
|
||||
@@ -287,7 +287,7 @@ JackOutput::GetAvailable() const noexcept
|
||||
* Call jack_ringbuffer_read_advance() on all buffers in the list.
|
||||
*/
|
||||
static void
|
||||
MultiReadAdvance(ConstBuffer<jack_ringbuffer_t *> buffers,
|
||||
MultiReadAdvance(std::span<jack_ringbuffer_t *const> buffers,
|
||||
size_t size)
|
||||
{
|
||||
for (auto *i : buffers)
|
||||
@@ -316,7 +316,7 @@ WriteSilence(jack_port_t &port, jack_nframes_t nframes)
|
||||
* Write a specific amount of "silence" to all ports in the list.
|
||||
*/
|
||||
static void
|
||||
MultiWriteSilence(ConstBuffer<jack_port_t *> ports, jack_nframes_t nframes)
|
||||
MultiWriteSilence(std::span<jack_port_t *const> ports, jack_nframes_t nframes)
|
||||
{
|
||||
for (auto *i : ports)
|
||||
WriteSilence(*i, nframes);
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "util/RuntimeError.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "util/Manual.hxx"
|
||||
#include "util/ConstBuffer.hxx"
|
||||
#include "pcm/Export.hxx"
|
||||
#include "thread/Mutex.hxx"
|
||||
#include "thread/Cond.hxx"
|
||||
@@ -46,6 +45,7 @@
|
||||
#include <boost/lockfree/spsc_queue.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <span>
|
||||
|
||||
static constexpr unsigned MPD_OSX_BUFFER_TIME_MS = 100;
|
||||
|
||||
@@ -96,7 +96,7 @@ struct OSXOutput final : AudioOutput {
|
||||
AudioComponentInstance au;
|
||||
AudioStreamBasicDescription asbd;
|
||||
|
||||
boost::lockfree::spsc_queue<uint8_t> *ring_buffer;
|
||||
boost::lockfree::spsc_queue<std::byte> *ring_buffer;
|
||||
|
||||
OSXOutput(const ConfigBlock &block);
|
||||
|
||||
@@ -620,7 +620,7 @@ osx_render(void *vdata,
|
||||
|
||||
int count = in_number_frames * od->asbd.mBytesPerFrame;
|
||||
buffer_list->mBuffers[0].mDataByteSize =
|
||||
od->ring_buffer->pop((uint8_t *)buffer_list->mBuffers[0].mData,
|
||||
od->ring_buffer->pop((std::byte *)buffer_list->mBuffers[0].mData,
|
||||
count);
|
||||
return noErr;
|
||||
}
|
||||
@@ -764,7 +764,7 @@ OSXOutput::Open(AudioFormat &audio_format)
|
||||
MPD_OSX_BUFFER_TIME_MS * pcm_export->GetOutputFrameSize() * asbd.mSampleRate / 1000);
|
||||
}
|
||||
#endif
|
||||
ring_buffer = new boost::lockfree::spsc_queue<uint8_t>(ring_buffer_size);
|
||||
ring_buffer = new boost::lockfree::spsc_queue<std::byte>(ring_buffer_size);
|
||||
|
||||
pause = false;
|
||||
started = false;
|
||||
@@ -777,17 +777,17 @@ OSXOutput::Play(const void *chunk, size_t size)
|
||||
|
||||
pause = false;
|
||||
|
||||
ConstBuffer<uint8_t> input((const uint8_t *)chunk, size);
|
||||
std::span<const std::byte> input((const std::byte *)chunk, size);
|
||||
|
||||
#ifdef ENABLE_DSD
|
||||
if (dop_enabled) {
|
||||
input = ConstBuffer<uint8_t>::FromVoid(pcm_export->Export(input.ToVoid()));
|
||||
input = pcm_export->Export(input);
|
||||
if (input.empty())
|
||||
return size;
|
||||
}
|
||||
#endif
|
||||
|
||||
size_t bytes_written = ring_buffer->push(input.data, input.size);
|
||||
size_t bytes_written = ring_buffer->push(input.data(), input.size());
|
||||
|
||||
if (!started) {
|
||||
OSStatus status = AudioOutputUnitStart(au);
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "pcm/Export.hxx"
|
||||
#include "io/UniqueFileDescriptor.hxx"
|
||||
#include "system/Error.hxx"
|
||||
#include "util/ConstBuffer.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "util/ByteOrder.hxx"
|
||||
#include "util/Manual.hxx"
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "thread/Name.hxx"
|
||||
#include "thread/Thread.hxx"
|
||||
#include "util/AllocatedString.hxx"
|
||||
#include "util/ConstBuffer.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
#include "util/ScopeExit.hxx"
|
||||
@@ -228,12 +227,12 @@ public:
|
||||
SetStatus(Status::PAUSE);
|
||||
}
|
||||
|
||||
std::size_t Push(ConstBuffer<void> input) noexcept {
|
||||
std::size_t Push(std::span<const std::byte> input) noexcept {
|
||||
empty.store(false);
|
||||
|
||||
std::size_t consumed =
|
||||
spsc_buffer.push(static_cast<const BYTE *>(input.data),
|
||||
input.size);
|
||||
spsc_buffer.push((const BYTE *)input.data(),
|
||||
input.size());
|
||||
|
||||
if (!playing) {
|
||||
playing = true;
|
||||
@@ -717,7 +716,7 @@ WasapiOutput::Play(const void *chunk, size_t size)
|
||||
|
||||
not_interrupted.test_and_set();
|
||||
|
||||
ConstBuffer<void> input(chunk, size);
|
||||
std::span<const std::byte> input{(const std::byte*)chunk, size};
|
||||
if (pcm_export) {
|
||||
input = pcm_export->Export(input);
|
||||
}
|
||||
@@ -725,7 +724,7 @@ WasapiOutput::Play(const void *chunk, size_t size)
|
||||
return size;
|
||||
|
||||
do {
|
||||
const size_t consumed_size = thread->Push({input.data, input.size});
|
||||
const size_t consumed_size = thread->Push(input);
|
||||
|
||||
if (consumed_size == 0) {
|
||||
thread->Wait();
|
||||
|
||||
Reference in New Issue
Block a user