aboutsummaryrefslogtreecommitdiffstats
path: root/alc/backends/dsound.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-08-06 18:49:42 -0700
committerChris Robinson <[email protected]>2023-08-06 18:49:42 -0700
commit9296af5566afea4ba4cb78b374ef3ee0bf9bc04b (patch)
treeac71d8896956166aed320ed38ffb32847bc2cba7 /alc/backends/dsound.cpp
parent05d80f9b3283d7686a27e5d3ed0bac6086669368 (diff)
Use a string_view for the backend open method
Diffstat (limited to 'alc/backends/dsound.cpp')
-rw-r--r--alc/backends/dsound.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/alc/backends/dsound.cpp b/alc/backends/dsound.cpp
index 54fac898..b5596f1c 100644
--- a/alc/backends/dsound.cpp
+++ b/alc/backends/dsound.cpp
@@ -178,7 +178,7 @@ struct DSoundPlayback 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;
@@ -301,7 +301,7 @@ FORCE_ALIGN int DSoundPlayback::mixerProc()
return 0;
}
-void DSoundPlayback::open(const char *name)
+void DSoundPlayback::open(std::string_view name)
{
HRESULT hr;
if(PlaybackDevices.empty())
@@ -316,9 +316,9 @@ void DSoundPlayback::open(const char *name)
}
const GUID *guid{nullptr};
- if(!name && !PlaybackDevices.empty())
+ if(name.empty() && !PlaybackDevices.empty())
{
- name = PlaybackDevices[0].name.c_str();
+ name = PlaybackDevices[0].name;
guid = &PlaybackDevices[0].guid;
}
else
@@ -334,7 +334,8 @@ void DSoundPlayback::open(const char *name)
[&id](const DevMap &entry) -> bool { return entry.guid == id; });
if(iter == PlaybackDevices.cend())
throw al::backend_exception{al::backend_error::NoDevice,
- "Device name \"%s\" not found", name};
+ "Device name \"%.*s\" not found", static_cast<int>(name.length()),
+ name.data()};
}
guid = &iter->guid;
}
@@ -549,7 +550,7 @@ struct DSoundCapture final : public BackendBase {
DSoundCapture(DeviceBase *device) noexcept : BackendBase{device} { }
~DSoundCapture() override;
- 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;
@@ -576,7 +577,7 @@ DSoundCapture::~DSoundCapture()
}
-void DSoundCapture::open(const char *name)
+void DSoundCapture::open(std::string_view name)
{
HRESULT hr;
if(CaptureDevices.empty())
@@ -591,9 +592,9 @@ void DSoundCapture::open(const char *name)
}
const GUID *guid{nullptr};
- if(!name && !CaptureDevices.empty())
+ if(name.empty() && !CaptureDevices.empty())
{
- name = CaptureDevices[0].name.c_str();
+ name = CaptureDevices[0].name;
guid = &CaptureDevices[0].guid;
}
else
@@ -609,7 +610,8 @@ void DSoundCapture::open(const char *name)
[&id](const DevMap &entry) -> bool { return entry.guid == id; });
if(iter == CaptureDevices.cend())
throw al::backend_exception{al::backend_error::NoDevice,
- "Device name \"%s\" not found", name};
+ "Device name \"%.*s\" not found", static_cast<int>(name.length()),
+ name.data()};
}
guid = &iter->guid;
}