Skip to content

Conversation

@tleb
Copy link

@tleb tleb commented Jun 24, 2024

Previously, using the JACK backend meant that for each port:

  • We call jack_port_register() to create the port,
  • And call jack_connect() to create a connection between the newly created port and a target (the PaStreamParameters.device argument).

In the JACK world, it is common for processes to spawn a node with ports and let somebody else do the routing. We therefore allow creating a stream that targets as input and/or output paNoDevice.

See the commit message for additional details.

I do have questions regarding this:

  • Would you be willing to take such a patch?
  • What should the public-facing API look like?
    I'm not familiar with PortAudio's API so there might be something better to do. Maybe something that is generic across APIs? Wanting to create a stream without connecting to anything might not be specific to JACK.

Previously, using the JACK backend meant that for each port:
 - We call jack_port_register() to create the port,
 - And call jack_connect() to create a connection between the newly
   created port and a target (the parameters->device argument).

In the JACK world, it is common for processes to spawn a node with ports
and let somebody else do the routing. We therefore allow creating a
stream that targets as input and/or output paNoDevice.

This cannot be done directly using:

     PaStreamParameters outputParams = {
          .device = paNoDevice,
          // ...
     };

As with this, PortAudio cannot use the right API backend.
Instead, we do this:

     PaJackStreamInfo streamInfo;
     PaJack_InitializeNoDeviceStreamInfo(&streamInfo);

     PaStreamParameters outputParams = {
          .device = paUseHostApiSpecificDeviceSpecification,
          .hostApiSpecificStreamInfo = &streamInfo,
          // ...
     };

streamInfo contains the standard API-specific header plus a
PaDeviceIndex device field that _must_ contain paNoDevice.

Some more details of changeset in pa_jack.c:

 - Move parameter validation into an helper called from both
   IsFormatSupported() and OpenStream().

 - If API-specific info is provided and its device field is paNoDevice,
   we create ports without calling jack_connect().

 - We do not allocate stream->remote_*_ports in this case. That allows
   us to detect throughout the driver without storing additional
   state.

Signed-off-by: Théo Lebrun <[email protected]>
@RossBencina RossBencina marked this pull request as draft June 28, 2024 23:03
@RossBencina
Copy link
Collaborator

I think this is worthy of discussion, especially with people who are using JACK.

@RossBencina RossBencina added the src-jack JACK Audio Connection Kit Host API /src/hostapi/jack label Jul 12, 2024
@RossBencina RossBencina added the P4 Priority: Low label Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P4 Priority: Low src-jack JACK Audio Connection Kit Host API /src/hostapi/jack

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants