aboutsummaryrefslogtreecommitdiffstats
path: root/alc/backends
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2021-09-12 02:19:38 -0700
committerChris Robinson <[email protected]>2021-09-12 02:19:38 -0700
commitc40e7db82a1c48094756222d33a8aade49616825 (patch)
tree8d645cd50a25fee18d8f6430b15175c40fb4809c /alc/backends
parent2df78e49b1359e7603e3816270737c68cccd5b05 (diff)
Use a constexpr char array for a reused prefix string
Diffstat (limited to 'alc/backends')
-rw-r--r--alc/backends/pipewire.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/alc/backends/pipewire.cpp b/alc/backends/pipewire.cpp
index 361dd18c..e0b66092 100644
--- a/alc/backends/pipewire.cpp
+++ b/alc/backends/pipewire.cpp
@@ -401,6 +401,8 @@ struct DeviceNode {
uint mSampleRate{};
DevFmtChannels mChannels{InvalidChannelConfig};
};
+constexpr char MonitorPrefix[]{"Monitor of "};
+constexpr auto MonitorPrefixLen = al::size(MonitorPrefix) - 1;
std::vector<DeviceNode> DeviceList;
std::string DefaultSinkDev;
std::string DefaultSourceDev;
@@ -1497,7 +1499,7 @@ void PipeWireCapture::open(const char *name)
targetid = match->mId;
if(match->mCapture) devname = match->mName;
- else devname = "Monitor of "+match->mName;
+ else devname = MonitorPrefix+match->mName;
}
else
{
@@ -1507,7 +1509,7 @@ void PipeWireCapture::open(const char *name)
auto match_name = [name](const DeviceNode &n) -> bool
{ return n.mCapture && n.mName == name; };
auto match = std::find_if(DeviceList.cbegin(), DeviceList.cend(), match_name);
- if(match == DeviceList.cend() && std::strncmp(name, "Monitor of ", 11) == 0)
+ if(match == DeviceList.cend() && std::strncmp(name, MonitorPrefix, MonitorPrefixLen) == 0)
{
const char *sinkname{name + 11};
auto match_sinkname = [sinkname](const DeviceNode &n) -> bool
@@ -1691,7 +1693,7 @@ std::string PipeWireBackendFactory::probe(BackendType type)
if(defmatch != DeviceList.cend())
{
if(!defmatch->mCapture)
- outnames.append("Monitor of ");
+ outnames.append(MonitorPrefix);
outnames.append(defmatch->mName.c_str(), defmatch->mName.length()+1);
}
for(auto iter = DeviceList.cbegin();iter != DeviceList.cend();++iter)
@@ -1702,7 +1704,7 @@ std::string PipeWireBackendFactory::probe(BackendType type)
for(auto iter = DeviceList.cbegin();iter != DeviceList.cend();++iter)
{
if(iter != defmatch && !iter->mCapture)
- outnames.append("Monitor of ").append(iter->mName.c_str(), iter->mName.length()+1);
+ outnames.append(MonitorPrefix).append(iter->mName.c_str(), iter->mName.length()+1);
}
break;
}