jack: only open as many channels as requested, option to not autoconnect to default device
Current behavior:
My default device has 8 channels. If I request 2 channels it creates a jack device with 8 outputs and auto-connect them all.
Desired behavior:
- Request 2 channels, get 2 channels
- Request 32 channels, get 32 (regardless if the default device has less)
- Ability to enable or disable autoconnecting to the default device
Details
With this config
ma_device_config deviceConfig = ma_device_config_init(ma_device_type_playback);
deviceConfig.playback.format = ma_format_f32;
deviceConfig.playback.channels = 2;
deviceConfig.sampleRate = 48000.0f;
The result is:
Proposed solution
Number of channels
- Since in device config the
.playback.channelsis ignored for jack, then I suggest if it is default 0 to use the number of channels in the default device. - If
.playback.channelsis non-zero, then inma_device_init__jack()simply create as many channels with(ma_jack_port_register_proc)()instead of basing it off the default device specs.
Autoconnect
- in the context config add a
.jack.autoconnectsetting - in
ma_device_start__jack()don't do calls to(ma_jack_connect_proc)()if.jack.autoconnectis false
Thanks. I don't have a whole lot of experience with jack, but everything you mentioned here makes sense. I'm actually surprised it's not already doing the channel count thing. Just on the autoconnect thing, if jack.autoconnect is false, I wouldn't do any jack_connect() at all? Does that not need to be called at some point in order for audio to actually work?
@mackron correct, I have it working without calling jack_connect() at all. See #852
Sorry for leaving this one hanging. I finally got around to doing another pass on the JACK backend. I've pushed some changes to the dev-0.12 branch which should address all of the issues you pointed out. Unfortunately this branch has breaking API changes and is not quite ready for general use so I don't recommend you immediately switch over just yet, but I thought I'd drop a message here to let you know that these changes will be making it in eventually.
I decided to make the noAutoConnect thing part of the device config rather than the context config.
I will go ahead and close your PR.
Cool. Any idea, when can we expect this to land in a release?
With 0.12, probably sometime next year.