diff options
author | Chris Robinson <[email protected]> | 2022-02-16 00:04:11 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2022-02-16 00:04:11 -0800 |
commit | a9974d3aa8ae225610302f221bd0a154c110ccbc (patch) | |
tree | 07171b9ba9db9955c6f7e4ca9e4c40296470d897 | |
parent | aa19223c65d8693dbaa8d8c9fa0c129d77eed4de (diff) |
Trace the actual device form factor in pipewire
-rw-r--r-- | alc/backends/pipewire.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/alc/backends/pipewire.cpp b/alc/backends/pipewire.cpp index 147a6489..a19dcb61 100644 --- a/alc/backends/pipewire.cpp +++ b/alc/backends/pipewire.cpp @@ -818,21 +818,14 @@ void NodeProxy::infoCallback(const pw_node_info *info) return; } - bool isHeadphones{}; - if(const char *form_factor{spa_dict_lookup(info->props, PW_KEY_DEVICE_FORM_FACTOR)}) - { - if(al::strcasecmp(form_factor, "headphones") == 0 - || al::strcasecmp(form_factor, "headset") == 0) - isHeadphones = true; - } - const char *devName{spa_dict_lookup(info->props, PW_KEY_NODE_NAME)}; const char *nodeName{spa_dict_lookup(info->props, PW_KEY_NODE_DESCRIPTION)}; if(!nodeName || !*nodeName) nodeName = spa_dict_lookup(info->props, PW_KEY_NODE_NICK); if(!nodeName || !*nodeName) nodeName = devName; - TRACE("Got %s device \"%s\"%s\n", AsString(ntype), devName ? devName : "(nil)", - isHeadphones ? " (headphones)" : ""); + const char *form_factor{spa_dict_lookup(info->props, PW_KEY_DEVICE_FORM_FACTOR)}; + TRACE("Got %s device \"%s\"%s%s%s\n", AsString(ntype), devName ? devName : "(nil)", + form_factor?" (":"", form_factor?form_factor:"", form_factor?")":""); TRACE(" \"%s\" = ID %u\n", nodeName ? nodeName : "(nil)", info->id); DeviceNode &node = DeviceNode::Add(info->id); @@ -840,7 +833,8 @@ void NodeProxy::infoCallback(const pw_node_info *info) else node.mName = "PipeWire node #"+std::to_string(info->id); node.mDevName = devName ? devName : ""; node.mType = ntype; - node.mIsHeadphones = isHeadphones; + node.mIsHeadphones = form_factor && (al::strcasecmp(form_factor, "headphones") == 0 + || al::strcasecmp(form_factor, "headset") == 0); } } |