Alsa head corruption in error handling.

This commit is contained in:
Robin Davies
2024-09-15 06:30:16 -04:00
parent f762d8b396
commit 2a851dbd4b
28 changed files with 744 additions and 140 deletions
+28 -6
View File
@@ -472,6 +472,33 @@ public:
}
};
static std::string StripPortNumber(const std::string &fromAddress)
{
std::string address = fromAddress;
if (address.size() == 0)
return fromAddress;
char lastChar = address[address.size() - 1];
size_t pos = address.find_last_of(':');
// if ipv6, make sure we found an actual port address.
size_t posBracket = address.find_last_of(']');
if (posBracket != std::string::npos && pos != std::string::npos)
{
if (posBracket > pos)
{
pos = std::string::npos;
}
}
if (pos != std::string::npos)
{
address = address.substr(0, pos);
}
return address;
}
/* When hosting a react app, replace /var/config.json with
data that will connect the react app with our socket server.
*/
@@ -491,13 +518,8 @@ public:
}
std::string GetConfig(const std::string &fromAddress)
{
#define LINK_LOCAL_WEB_SOCKET 1
#if LINK_LOCAL_WEB_SOCKET
std::string webSocketAddress = GetLinkLocalAddress(fromAddress);
std::string webSocketAddress = GetNonLinkLocalAddress(StripPortNumber(fromAddress));
Lv2Log::info(SS("Web Socket Address: " << webSocketAddress << ":" << portNumber));
#else
std::string webSocketAddress = "*";
#endif
std::stringstream s;