aboutsummaryrefslogtreecommitdiffstats
path: root/src/pad_interface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/pad_interface.cpp')
-rw-r--r--src/pad_interface.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/pad_interface.cpp b/src/pad_interface.cpp
index 3db5308..26a04ab 100644
--- a/src/pad_interface.cpp
+++ b/src/pad_interface.cpp
@@ -47,7 +47,17 @@ void PadInterface::open(const std::string &pad_ident)
struct sockaddr_un claddr;
memset(&claddr, 0, sizeof(struct sockaddr_un));
claddr.sun_family = AF_UNIX;
- snprintf(claddr.sun_path, sizeof(claddr.sun_path), "/tmp/%s.padenc", m_pad_ident.c_str());
+
+ size_t last_slash = m_pad_ident.find_last_of('/');
+ if (last_slash != std::string::npos) {
+ // Full path provided, use as-is with .padenc suffix
+ std::string socket_dir = m_pad_ident.substr(0, last_slash);
+ std::string socket_base = m_pad_ident.substr(last_slash + 1);
+ snprintf(claddr.sun_path, sizeof(claddr.sun_path), "%s/%s.padenc", socket_dir.c_str(), socket_base.c_str());
+ } else {
+ // Identifier only, use /tmp/ for backward compatibility
+ snprintf(claddr.sun_path, sizeof(claddr.sun_path), "/tmp/%s.padenc", m_pad_ident.c_str());
+ }
if (unlink(claddr.sun_path) == -1 and errno != ENOENT) {
fprintf(stderr, "Unlinking of socket %s failed: %s\n", claddr.sun_path, strerror(errno));
}
@@ -110,7 +120,17 @@ void PadInterface::send_pad_data(const uint8_t *data, size_t len)
struct sockaddr_un claddr;
memset(&claddr, 0, sizeof(struct sockaddr_un));
claddr.sun_family = AF_UNIX;
- snprintf(claddr.sun_path, sizeof(claddr.sun_path), "/tmp/%s.audioenc", m_pad_ident.c_str());
+
+ size_t last_slash = m_pad_ident.find_last_of('/');
+ if (last_slash != std::string::npos) {
+ // Full path provided, use as-is with .audioenc suffix
+ std::string socket_dir = m_pad_ident.substr(0, last_slash);
+ std::string socket_base = m_pad_ident.substr(last_slash + 1);
+ snprintf(claddr.sun_path, sizeof(claddr.sun_path), "%s/%s.audioenc", socket_dir.c_str(), socket_base.c_str());
+ } else {
+ // Identifier only, use /tmp/ for backward compatibility
+ snprintf(claddr.sun_path, sizeof(claddr.sun_path), "/tmp/%s.audioenc", m_pad_ident.c_str());
+ }
vector<uint8_t> message(len + 1);
message[0] = MESSAGE_PAD_DATA;