diff options
Diffstat (limited to 'alc/backends/portaudio.cpp')
-rw-r--r-- | alc/backends/portaudio.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/alc/backends/portaudio.cpp b/alc/backends/portaudio.cpp index 2551f448..979a54d6 100644 --- a/alc/backends/portaudio.cpp +++ b/alc/backends/portaudio.cpp @@ -86,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; @@ -116,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"); @@ -245,7 +245,7 @@ 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(std::byte *buffer, uint samples) override; @@ -276,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); |