aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-08-05 00:27:12 -0700
committerChris Robinson <[email protected]>2020-08-05 00:27:12 -0700
commitf138369808086cbf2bdf1d579e6f21553c657dc5 (patch)
treeb839b85e71d25af98b5c904e17d835fc06c83f8d
parent516de157d889861b73b93d37b80ff77a9b5cbceb (diff)
Add an option to auto-connect JACK ports
-rw-r--r--alc/backends/jack.cpp25
-rw-r--r--alsoftrc.sample6
2 files changed, 20 insertions, 11 deletions
diff --git a/alc/backends/jack.cpp b/alc/backends/jack.cpp
index 78ba6404..6f53b54c 100644
--- a/alc/backends/jack.cpp
+++ b/alc/backends/jack.cpp
@@ -384,15 +384,17 @@ void JackPlayback::start()
if(jack_activate(mClient))
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to activate client"};
- const char **ports{jack_get_ports(mClient, nullptr, nullptr,
- JackPortIsPhysical|JackPortIsInput)};
- if(ports == nullptr)
+ const char *devname{mDevice->DeviceName.c_str()};
+ if(ConfigValueBool(devname, "jack", "connect-ports").value_or(true))
{
- jack_deactivate(mClient);
- throw al::backend_exception{ALC_INVALID_DEVICE, "No physical playback ports found"};
- }
- std::mismatch(mPort.begin(), mPort.end(), ports,
- [this](const jack_port_t *port, const char *pname) -> bool
+ const char **ports{jack_get_ports(mClient, nullptr, nullptr,
+ JackPortIsPhysical|JackPortIsInput)};
+ if(ports == nullptr)
+ {
+ jack_deactivate(mClient);
+ throw al::backend_exception{ALC_INVALID_DEVICE, "No physical playback ports found"};
+ }
+ auto connect_port = [this](const jack_port_t *port, const char *pname) -> bool
{
if(!port) return false;
if(!pname)
@@ -404,8 +406,10 @@ void JackPlayback::start()
ERR("Failed to connect output port \"%s\" to \"%s\"\n", jack_port_name(port),
pname);
return true;
- });
- jack_free(ports);
+ };
+ std::mismatch(mPort.begin(), mPort.end(), ports, connect_port);
+ jack_free(ports);
+ }
/* Reconfigure buffer metrics in case the server changed it since the reset
* (it won't change again after jack_activate), then allocate the ring
@@ -415,7 +419,6 @@ void JackPlayback::start()
mDevice->UpdateSize = jack_get_buffer_size(mClient);
mDevice->BufferSize = mDevice->UpdateSize * 2;
- const char *devname{mDevice->DeviceName.c_str()};
ALuint bufsize{ConfigValueUInt(devname, "jack", "buffer-size").value_or(mDevice->UpdateSize)};
bufsize = maxu(NextPowerOf2(bufsize), mDevice->UpdateSize);
mDevice->BufferSize = bufsize + mDevice->UpdateSize;
diff --git a/alsoftrc.sample b/alsoftrc.sample
index 42ebd7ca..66ceae0b 100644
--- a/alsoftrc.sample
+++ b/alsoftrc.sample
@@ -469,6 +469,12 @@
# backend, opening devices, etc).
#spawn-server = false
+## connect-ports:
+# Attempts to automatically connect the client ports to physical server ports.
+# Client ports that fail to connect will leave the remaining channels
+# unconnected and silent (the device format won't change to accommodate).
+#connect-ports = true
+
## buffer-size:
# Sets the update buffer size, in samples, that the backend will keep buffered
# to handle the server's real-time processing requests. This value must be a