aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md4
-rw-r--r--src/odr-padenc.cpp4
-rw-r--r--src/pad_interface.cpp24
-rw-r--r--src/pad_interface.h6
4 files changed, 33 insertions, 5 deletions
diff --git a/README.md b/README.md
index d1212a6..b2bc16f 100644
--- a/README.md
+++ b/README.md
@@ -104,6 +104,10 @@ variable.
odr-padenc -o $IDENTIFIER -t dls.txt -d ./slides
```
+The `-o` parameter accepts either:
+- An identifier (e.g., `station1`): Creates sockets at `/tmp/station1.padenc` and `/tmp/station1.audioenc`
+- A full path (e.g., `/var/run/radio/station1`): Creates sockets at `/var/run/radio/station1.padenc` and `/var/run/radio/station1.audioenc`
+
If you generate slides on-the-fly (e.g. content-related slides with album covers), set the `--erase` flag to ensure a
slide is only transmitted once, and set `--sleep=0` to start slide transmission as soon as the file is created.
diff --git a/src/odr-padenc.cpp b/src/odr-padenc.cpp
index 3d610bd..7c2017e 100644
--- a/src/odr-padenc.cpp
+++ b/src/odr-padenc.cpp
@@ -61,7 +61,9 @@ static void usage(const char* name) {
" -s, --sleep=DUR Wait DUR seconds between each slide. If set to 0, the next slide is inserted just after the previous one\n"
" has been transmitted. This is useful e.g. for stations that transmit just a logo slide.\n"
" Default: %d\n"
- " -o, --output=IDENTIFIER Socket to communicate with audio encoder\n"
+ " -o, --output=IDENTIFIER Socket to communicate with audio encoder.
+ If IDENTIFIER contains '/', it's used as a full path.
+ Otherwise, /tmp/ is prepended for backward compatibility\n"
" --dump-current-slide=F1 Write the slide currently being transmitted to the file F1\n"
" --dump-completed-slide=F2 Once the slide is transmitted, move the file from F1 to F2\n"
" -t, --dls=FILENAME FIFO or file to read DLS text from.\n"
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;
diff --git a/src/pad_interface.h b/src/pad_interface.h
index f0307bd..2803b5e 100644
--- a/src/pad_interface.h
+++ b/src/pad_interface.h
@@ -33,8 +33,10 @@
class PadInterface {
public:
- /*! Create a new PAD data interface that binds to /tmp/pad_ident.padenc and
- * communicates with ODR-AudioEnc at /tmp/pad_ident.audioenc
+ /*! Create a new PAD data interface that binds to a socket and
+ * communicates with ODR-AudioEnc. If pad_ident contains '/', it's used as a full path.
+ * Otherwise, /tmp/ is prepended for backward compatibility.
+ * Sockets: pad_ident.padenc (this) and pad_ident.audioenc (ODR-AudioEnc)
*/
void open(const std::string &pad_ident);