aboutsummaryrefslogtreecommitdiffstats
path: root/alc/backends/portaudio.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'alc/backends/portaudio.cpp')
-rw-r--r--alc/backends/portaudio.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/alc/backends/portaudio.cpp b/alc/backends/portaudio.cpp
index 9c94587d..979a54d6 100644
--- a/alc/backends/portaudio.cpp
+++ b/alc/backends/portaudio.cpp
@@ -26,6 +26,7 @@
#include <cstdlib>
#include <cstring>
+#include "albit.h"
#include "alc/alconfig.h"
#include "alnumeric.h"
#include "core/device.h"
@@ -85,7 +86,7 @@ struct PortPlayback final : public BackendBase {
framesPerBuffer, timeInfo, statusFlags);
}
- void open(const char *name) override;
+ void open(std::string_view name) override;
bool reset() override;
void start() override;
void stop() override;
@@ -115,13 +116,13 @@ int PortPlayback::writeCallback(const void*, void *outputBuffer, unsigned long f
}
-void PortPlayback::open(const char *name)
+void PortPlayback::open(std::string_view name)
{
- if(!name)
+ if(name.empty())
name = pa_device;
- else if(strcmp(name, pa_device) != 0)
- throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%s\" not found",
- name};
+ else if(name != pa_device)
+ throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%.*s\" not found",
+ static_cast<int>(name.length()), name.data()};
PaStreamParameters params{};
auto devidopt = ConfigValueInt(nullptr, "port", "device");
@@ -244,10 +245,10 @@ struct PortCapture final : public BackendBase {
framesPerBuffer, timeInfo, statusFlags);
}
- 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;
PaStream *mStream{nullptr};
@@ -275,13 +276,13 @@ int PortCapture::readCallback(const void *inputBuffer, void*, unsigned long fram
}
-void PortCapture::open(const char *name)
+void PortCapture::open(std::string_view name)
{
- if(!name)
+ if(name.empty())
name = pa_device;
- else if(strcmp(name, pa_device) != 0)
- throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%s\" not found",
- name};
+ else if(name != pa_device)
+ throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%.*s\" not found",
+ static_cast<int>(name.length()), name.data()};
uint samples{mDevice->BufferSize};
samples = maxu(samples, 100 * mDevice->Frequency / 1000);
@@ -348,7 +349,7 @@ void PortCapture::stop()
uint PortCapture::availableSamples()
{ return static_cast<uint>(mRing->readSpace()); }
-void PortCapture::captureSamples(al::byte *buffer, uint samples)
+void PortCapture::captureSamples(std::byte *buffer, uint samples)
{ mRing->read(buffer, samples); }
} // namespace
@@ -376,7 +377,7 @@ bool PortBackendFactory::init()
return false;
#define LOAD_FUNC(f) do { \
- p##f = reinterpret_cast<decltype(p##f)>(GetSymbol(pa_handle, #f)); \
+ p##f = al::bit_cast<decltype(p##f)>(GetSymbol(pa_handle, #f)); \
if(p##f == nullptr) \
{ \
CloseLib(pa_handle); \