mirror of
https://github.com/Ryujinx/libsoundio.git
synced 2025-02-02 00:21:16 +00:00
add Jack option to leave ports unconnected
This commit is contained in:
parent
eef66c5d34
commit
662ef7983b
|
@ -608,6 +608,12 @@ struct SoundIoOutStream {
|
|||
/// to an error code. Possible error codes are:
|
||||
/// * #SoundIoErrorIncompatibleDevice
|
||||
enum SoundIoError layout_error;
|
||||
|
||||
/// Optional: Whether to leave the software outputs unconnected.
|
||||
/// If this is set to `true`, JACK will not immediately connect the output
|
||||
/// of this stream to the output ports of the sound card.
|
||||
/// Defaults to `false`.
|
||||
bool unconnected;
|
||||
};
|
||||
|
||||
/// The size of this struct is not part of the API or ABI.
|
||||
|
@ -690,6 +696,12 @@ struct SoundIoInStream {
|
|||
/// If setting the channel layout fails for some reason, this field is set
|
||||
/// to an error code. Possible error codes are: #SoundIoErrorIncompatibleDevice
|
||||
enum SoundIoError layout_error;
|
||||
|
||||
/// Optional: Whether to leave the software inputs unconnected.
|
||||
/// If this is set to `true`, JACK will not immediately connect the input
|
||||
/// of this stream to the input ports of the sound card.
|
||||
/// Defaults to `false`.
|
||||
bool unconnected;
|
||||
};
|
||||
|
||||
/// See also ::soundio_version_major, ::soundio_version_minor, ::soundio_version_patch
|
||||
|
|
40
src/jack.c
40
src/jack.c
|
@ -542,15 +542,17 @@ static enum SoundIoError outstream_start_jack(struct SoundIoPrivate *si, struct
|
|||
if ((err = jack_activate(osj->client)))
|
||||
return SoundIoErrorStreaming;
|
||||
|
||||
for (int ch = 0; ch < outstream->layout.channel_count; ch += 1) {
|
||||
struct SoundIoOutStreamJackPort *osjp = &osj->ports[ch];
|
||||
const char *dest_port_name = osjp->dest_port_name;
|
||||
// allow unconnected ports
|
||||
if (!dest_port_name)
|
||||
continue;
|
||||
const char *source_port_name = jack_port_name(osjp->source_port);
|
||||
if ((err = jack_connect(osj->client, source_port_name, dest_port_name)))
|
||||
return SoundIoErrorStreaming;
|
||||
if (!outstream->unconnected) {
|
||||
for (int ch = 0; ch < outstream->layout.channel_count; ch += 1) {
|
||||
struct SoundIoOutStreamJackPort *osjp = &osj->ports[ch];
|
||||
const char *dest_port_name = osjp->dest_port_name;
|
||||
// allow unconnected ports
|
||||
if (!dest_port_name)
|
||||
continue;
|
||||
const char *source_port_name = jack_port_name(osjp->source_port);
|
||||
if ((err = jack_connect(osj->client, source_port_name, dest_port_name)))
|
||||
return SoundIoErrorStreaming;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -762,15 +764,17 @@ static enum SoundIoError instream_start_jack(struct SoundIoPrivate *si, struct S
|
|||
if ((err = jack_activate(isj->client)))
|
||||
return SoundIoErrorStreaming;
|
||||
|
||||
for (int ch = 0; ch < instream->layout.channel_count; ch += 1) {
|
||||
struct SoundIoInStreamJackPort *isjp = &isj->ports[ch];
|
||||
const char *source_port_name = isjp->source_port_name;
|
||||
// allow unconnected ports
|
||||
if (!source_port_name)
|
||||
continue;
|
||||
const char *dest_port_name = jack_port_name(isjp->dest_port);
|
||||
if ((err = jack_connect(isj->client, source_port_name, dest_port_name)))
|
||||
return SoundIoErrorStreaming;
|
||||
if (!instream->unconnected) {
|
||||
for (int ch = 0; ch < instream->layout.channel_count; ch += 1) {
|
||||
struct SoundIoInStreamJackPort *isjp = &isj->ports[ch];
|
||||
const char *source_port_name = isjp->source_port_name;
|
||||
// allow unconnected ports
|
||||
if (!source_port_name)
|
||||
continue;
|
||||
const char *dest_port_name = jack_port_name(isjp->dest_port);
|
||||
if ((err = jack_connect(isj->client, source_port_name, dest_port_name)))
|
||||
return SoundIoErrorStreaming;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue