From c66e4f5bd447d2bb1a38446510bff87ada00fb9f Mon Sep 17 00:00:00 2001
From: Chris Robinson <chris.kcat@gmail.com>
Date: Sun, 19 Sep 2021 17:02:10 -0700
Subject: Use a constexpr char array instead of duplicating strings

---
 alc/backends/pipewire.cpp | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

(limited to 'alc/backends/pipewire.cpp')

diff --git a/alc/backends/pipewire.cpp b/alc/backends/pipewire.cpp
index e25559d7..5c09a289 100644
--- a/alc/backends/pipewire.cpp
+++ b/alc/backends/pipewire.cpp
@@ -386,7 +386,6 @@ const pw_core_events EventManager::sCoreEvents{EventManager::CreateCoreEvents()}
 const pw_registry_events EventManager::sRegistryEvents{EventManager::CreateRegistryEvents()};
 EventManager gEventHandler;
 
-
 /* Enumerated devices. This is updated asynchronously as the app runs, and the
  * gEventHandler thread loop must be locked when accessing the list.
  */
@@ -404,6 +403,8 @@ struct DeviceNode {
 };
 constexpr char MonitorPrefix[]{"Monitor of "};
 constexpr auto MonitorPrefixLen = al::size(MonitorPrefix) - 1;
+constexpr char AudioSinkClass[]{"Audio/Sink"};
+constexpr char AudioSourceClass[]{"Audio/Source"};
 std::vector<DeviceNode> DeviceList;
 std::string DefaultSinkDev;
 std::string DefaultSourceDev;
@@ -507,9 +508,9 @@ void NodeProxy::infoCallback(const pw_node_info *info)
         if UNLIKELY(!media_class) return;
 
         bool isCapture{};
-        if(al::strcasecmp(media_class, "Audio/Sink") == 0)
+        if(al::strcasecmp(media_class, AudioSinkClass) == 0)
             isCapture = false;
-        else if(al::strcasecmp(media_class, "Audio/Source") == 0)
+        else if(al::strcasecmp(media_class, AudioSourceClass) == 0)
             isCapture = true;
         else
         {
@@ -852,8 +853,8 @@ void EventManager::addCallback(uint32_t id, uint32_t, const char *type, uint32_t
         if(!media_class) return;
 
         /* Specifically, audio sinks and sources. */
-        const bool isGood{al::strcasecmp(media_class, "Audio/Sink") == 0
-            || al::strcasecmp(media_class, "Audio/Source") == 0};
+        const bool isGood{al::strcasecmp(media_class, AudioSinkClass) == 0
+            || al::strcasecmp(media_class, AudioSourceClass) == 0};
         if(!isGood)
         {
             TRACE("Skipping node type \"%s\"\n", media_class);
-- 
cgit v1.2.3