Feature request: multiple device startup support
martinsolberg opened this issue · comments
Would it be possible to add a "--all-devices" or "-d all" flag, which would fork a jclient for any supported device found on the system? That would make service control via systemd a little bit more convenient.
I like your idea and I'm gonna implement it but there are a few things that I'd like to discuss before.
- I'd like to add a small UI in the future. The idea is to have a CLI and a GUI interface with different builds in the same project. CLI will be exactly what it is now with your feature. GUI could probably do this as well.
- The idea is to spawn as several threads (not processes) as devices because this is the way the GUI will work. I guess this won't be a problem for
systemd
. Can you confirm this? - I'd like you to try the
print_init_error
branch as there a few improvements and fixes there. If all goes well, I'll add this request on top of it and version 0.2 will be completed.
The idea is to spawn as several threads (not processes) as devices because this is the way the GUI will work. I guess this won't be a problem for systemd. Can you confirm this?
I don't see how this would be a problem. If anyone needs some independent control over each device/thread when Overwitch is running, they could use the GUI for this. Systemd would simply start the process, and then send SIGTERM to that process on "systemctl stop overwitch".
I'd like you to try the print_init_error branch as there a few improvements and fixes there. If all goes well, I'll add this request on top of it and version 0.2 will be completed.
I'll give it a spin. Thanks for the response and continued work on this.
I've just pushed 220b567, which implements this. It's in the print_init_error
branch.
You don't need to pass any parameter at all. In this case, it behaves similarly for any amount of devices.
I can test it and looks like it's working well but I can only test it with one device.
Let me know your thoughts on this.
After f079194, Overwitch no longer recognizes my Digitone:
$ overwitch -l
0: Bus 001 Device 089: ID 1935:000c Digitakt
1: Bus 001 Device 090: ID 1935:0014 Digitone
$ overwitch -d Digitone
ERROR:jclient.c:664:(jclient_run): USB error: can't find a matching device
$ overwitch
Device: Digitakt (outputs: 12, inputs: 2)
ERROR:jclient.c:664:(jclient_run): USB error: can't find a matching device
JACK sample rate: 48000
double free or corruption (out)
Aborted
$ overwitch -d Digitakt
Device: Digitakt (outputs: 12, inputs: 2)
JACK sample rate: 48000
JACK buffer size: 128
Could you try exactly that while keeping the Digitakt unplugged?
I suspect the issue wont happen if the device is the first one.
Crashes if I don't specify -d for some reason:
$ overwitch -l
0: Bus 001 Device 091: ID 1935:0014 Digitone
$ overwitch
Device: Digitone (outputs: 12, inputs: 2)
JACK sample rate: 48000
Segmentation fault
$ overwitch -d Digitone
Device: Digitone (outputs: 12, inputs: 2)
JACK sample rate: 48000
JACK buffer size: 128
^Co2j latency: 3.4 ms, max. 6.2 ms; j2o latency: 0.0 ms, max. 0.0 ms
$ overwitch
Device: Digitone (outputs: 12, inputs: 2)
JACK sample rate: 48000
Segmentation fault
Could you run the failed executions with -vv
? I've just taken an overall look and didn't find anything.
$ overwitch -vv
DEBUG:overbridge.c:600:(overbridge_init): Checking for Digitakt...
DEBUG:overbridge.c:600:(overbridge_init): Checking for Digitone...
Device: Digitone (outputs: 12, inputs: 2)
DEBUG:utils.c:109:(dll_init): Target delay: 44205.6 ms (1647094344 frames)
JACK sample rate: 48000
DEBUG:jclient.c:732:(jclient_run): Using RT priority 5...
DEBUG:overbridge.c:912:(overbridge_activate): Starting j2o MIDI thread...
DEBUG:overbridge.c:920:(overbridge_activate): Starting audio and o2j MIDI thread...
munmap_chunk(): invalid pointer
Aborted
This was after turning off the Digitakt. It probably still "remebers" it?
This was after turning off the Digitakt. It probably still "remebers" it?
No, as no device is provided is gonna compare all the USB devices with all the Overbridge devices.
Probably those errors were coming from this.
DEBUG:utils.c:109:(dll_init): Target delay: 44205.6 ms (1647094344 frames)
This is definitely wrong and it could happen depending on the moment some callbacks are invoked. I think I have addressed this in ad4c32e.
This commit and every branch have been merged into master
, BTW.
Is this solving your issues?
Negative:
$ overwitch
Device: Digitakt (outputs: 12, inputs: 2)
ERROR:jclient.c:687:(jclient_run): USB error: can't find a matching device
JACK sample rate: 48000
JACK buffer size: 128
double free or corruption (out)
Aborted
$ overwitch -d Digitone
ERROR:jclient.c:687:(jclient_run): USB error: can't find a matching device
Unplugging Digitakt:
$ overwitch -vv
DEBUG:overbridge.c:600:(overbridge_init): Checking for Digitakt...
DEBUG:overbridge.c:600:(overbridge_init): Checking for Digitone...
Device: Digitone (outputs: 12, inputs: 2)
JACK sample rate: 48000
DEBUG:jclient.c:108:(jclient_reset_dll): Initializing dll...
DEBUG:utils.c:109:(dll_init): Target delay: 7.0 ms (336 frames)
DEBUG:jclient.c:755:(jclient_run): Using RT priority 5...
DEBUG:overbridge.c:912:(overbridge_activate): Starting j2o MIDI thread...
DEBUG:overbridge.c:920:(overbridge_activate): Starting audio and o2j MIDI thread...
JACK buffer size: 128
Segmentation fault
On commit ad4c32e on master.
$ overwitch -d Digitone
ERROR:jclient.c:687:(jclient_run): USB error: can't find a matching device
Yeah, this is something else. We'll take a look at it later.
$ overwitch -vv
DEBUG:overbridge.c:600:(overbridge_init): Checking for Digitakt...
DEBUG:overbridge.c:600:(overbridge_init): Checking for Digitone...
Device: Digitone (outputs: 12, inputs: 2)
JACK sample rate: 48000
DEBUG:jclient.c:108:(jclient_reset_dll): Initializing dll...
DEBUG:utils.c:109:(dll_init): Target delay: 7.0 ms (336 frames)
[...]
It still crashes but the target delay is calculated properly.
For now, can you try to run the Digitone with the option -n
? The option -d
is limited to device names so it is not possible to run more than one device of any type.
Also I think that the segmentation fault problem is here.
Line 64 in ad4c32e
Could you add this to line jclient.c:821?
jclient->j2o_buf_in = NULL;
I don't like relaying on this code but I'll change the code later.
If this doesn't work, could you try running it with gdb
and print the backtrace when it crashes?
I've found the bug that prevented using other devices than the first one.
Fixed in 9918d87.
I think I may have solved your issue in a147009.
Just check that, no need to add anything to the code.
works for me with Digitone and Digitakt. Very nice addition!
Seems to be working smoothly here as well.