diff options
Diffstat (limited to 'alc/backends/sndio.cpp')
-rw-r--r-- | alc/backends/sndio.cpp | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/alc/backends/sndio.cpp b/alc/backends/sndio.cpp index 077e77f2..d54c337b 100644 --- a/alc/backends/sndio.cpp +++ b/alc/backends/sndio.cpp @@ -22,21 +22,21 @@ #include "sndio.h" +#include <cinttypes> #include <functional> -#include <inttypes.h> #include <poll.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <thread> +#include <vector> #include "alnumeric.h" +#include "althrd_setname.h" #include "core/device.h" #include "core/helpers.h" #include "core/logging.h" #include "ringbuffer.h" -#include "threads.h" -#include "vector.h" #include <sndio.h> @@ -57,7 +57,7 @@ struct SndioPlayback final : public BackendBase { int mixerProc(); - void open(const char *name) override; + void open(std::string_view name) override; bool reset() override; void start() override; void stop() override; @@ -65,7 +65,7 @@ struct SndioPlayback final : public BackendBase { sio_hdl *mSndHandle{nullptr}; uint mFrameStep{}; - al::vector<al::byte> mBuffer; + std::vector<std::byte> mBuffer; std::atomic<bool> mKillNow{true}; std::thread mThread; @@ -91,7 +91,7 @@ int SndioPlayback::mixerProc() while(!mKillNow.load(std::memory_order_acquire) && mDevice->Connected.load(std::memory_order_acquire)) { - al::span<al::byte> buffer{mBuffer}; + al::span<std::byte> buffer{mBuffer}; mDevice->renderSamples(buffer.data(), static_cast<uint>(buffer.size() / frameSize), frameStep); @@ -112,13 +112,13 @@ int SndioPlayback::mixerProc() } -void SndioPlayback::open(const char *name) +void SndioPlayback::open(std::string_view name) { - if(!name) + if(name.empty()) name = sndio_device; - else if(strcmp(name, sndio_device) != 0) - throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%s\" not found", - name}; + else if(name != sndio_device) + throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%.*s\" not found", + static_cast<int>(name.length()), name.data()}; sio_hdl *sndHandle{sio_open(nullptr, SIO_PLAY, 0)}; if(!sndHandle) @@ -231,9 +231,9 @@ retry_params: mBuffer.resize(mDevice->UpdateSize * par.pchan*par.bps); if(par.sig == 1) - std::fill(mBuffer.begin(), mBuffer.end(), al::byte{}); + std::fill(mBuffer.begin(), mBuffer.end(), std::byte{}); else if(par.bits == 8) - std::fill_n(mBuffer.data(), mBuffer.size(), al::byte(0x80)); + std::fill_n(mBuffer.data(), mBuffer.size(), std::byte(0x80)); else if(par.bits == 16) std::fill_n(reinterpret_cast<uint16_t*>(mBuffer.data()), mBuffer.size()/2, 0x8000); else if(par.bits == 32) @@ -280,10 +280,10 @@ struct SndioCapture final : public BackendBase { int recordProc(); - void open(const char *name) override; + void open(std::string_view name) override; void start() override; void stop() override; - void captureSamples(al::byte *buffer, uint samples) override; + void captureSamples(std::byte *buffer, uint samples) override; uint availableSamples() override; sio_hdl *mSndHandle{nullptr}; @@ -349,7 +349,7 @@ int SndioCapture::recordProc() continue; auto data = mRing->getWriteVector(); - al::span<al::byte> buffer{data.first.buf, data.first.len*frameSize}; + al::span<std::byte> buffer{data.first.buf, data.first.len*frameSize}; while(!buffer.empty()) { size_t got{sio_read(mSndHandle, buffer.data(), buffer.size())}; @@ -382,13 +382,13 @@ int SndioCapture::recordProc() } -void SndioCapture::open(const char *name) +void SndioCapture::open(std::string_view name) { - if(!name) + if(name.empty()) name = sndio_device; - else if(strcmp(name, sndio_device) != 0) - throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%s\" not found", - name}; + else if(name != sndio_device) + throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%.*s\" not found", + static_cast<int>(name.length()), name.data()}; mSndHandle = sio_open(nullptr, SIO_REC, true); if(mSndHandle == nullptr) @@ -436,7 +436,7 @@ void SndioCapture::open(const char *name) if(!sio_setpar(mSndHandle, &par) || !sio_getpar(mSndHandle, &par)) throw al::backend_exception{al::backend_error::DeviceError, - "Failed to set device praameters"}; + "Failed to set device parameters"}; if(par.bps > 1 && par.le != SIO_LE_NATIVE) throw al::backend_exception{al::backend_error::DeviceError, @@ -496,7 +496,7 @@ void SndioCapture::stop() ERR("Error stopping device\n"); } -void SndioCapture::captureSamples(al::byte *buffer, uint samples) +void SndioCapture::captureSamples(std::byte *buffer, uint samples) { mRing->read(buffer, samples); } uint SndioCapture::availableSamples() |