mirror of
https://github.com/Ryujinx/libsoundio.git
synced 2025-02-02 02:51:09 +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:
|
/// to an error code. Possible error codes are:
|
||||||
/// * #SoundIoErrorIncompatibleDevice
|
/// * #SoundIoErrorIncompatibleDevice
|
||||||
enum SoundIoError layout_error;
|
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.
|
/// 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
|
/// If setting the channel layout fails for some reason, this field is set
|
||||||
/// to an error code. Possible error codes are: #SoundIoErrorIncompatibleDevice
|
/// to an error code. Possible error codes are: #SoundIoErrorIncompatibleDevice
|
||||||
enum SoundIoError layout_error;
|
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
|
/// 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)))
|
if ((err = jack_activate(osj->client)))
|
||||||
return SoundIoErrorStreaming;
|
return SoundIoErrorStreaming;
|
||||||
|
|
||||||
for (int ch = 0; ch < outstream->layout.channel_count; ch += 1) {
|
if (!outstream->unconnected) {
|
||||||
struct SoundIoOutStreamJackPort *osjp = &osj->ports[ch];
|
for (int ch = 0; ch < outstream->layout.channel_count; ch += 1) {
|
||||||
const char *dest_port_name = osjp->dest_port_name;
|
struct SoundIoOutStreamJackPort *osjp = &osj->ports[ch];
|
||||||
// allow unconnected ports
|
const char *dest_port_name = osjp->dest_port_name;
|
||||||
if (!dest_port_name)
|
// allow unconnected ports
|
||||||
continue;
|
if (!dest_port_name)
|
||||||
const char *source_port_name = jack_port_name(osjp->source_port);
|
continue;
|
||||||
if ((err = jack_connect(osj->client, source_port_name, dest_port_name)))
|
const char *source_port_name = jack_port_name(osjp->source_port);
|
||||||
return SoundIoErrorStreaming;
|
if ((err = jack_connect(osj->client, source_port_name, dest_port_name)))
|
||||||
|
return SoundIoErrorStreaming;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -762,15 +764,17 @@ static enum SoundIoError instream_start_jack(struct SoundIoPrivate *si, struct S
|
||||||
if ((err = jack_activate(isj->client)))
|
if ((err = jack_activate(isj->client)))
|
||||||
return SoundIoErrorStreaming;
|
return SoundIoErrorStreaming;
|
||||||
|
|
||||||
for (int ch = 0; ch < instream->layout.channel_count; ch += 1) {
|
if (!instream->unconnected) {
|
||||||
struct SoundIoInStreamJackPort *isjp = &isj->ports[ch];
|
for (int ch = 0; ch < instream->layout.channel_count; ch += 1) {
|
||||||
const char *source_port_name = isjp->source_port_name;
|
struct SoundIoInStreamJackPort *isjp = &isj->ports[ch];
|
||||||
// allow unconnected ports
|
const char *source_port_name = isjp->source_port_name;
|
||||||
if (!source_port_name)
|
// allow unconnected ports
|
||||||
continue;
|
if (!source_port_name)
|
||||||
const char *dest_port_name = jack_port_name(isjp->dest_port);
|
continue;
|
||||||
if ((err = jack_connect(isj->client, source_port_name, dest_port_name)))
|
const char *dest_port_name = jack_port_name(isjp->dest_port);
|
||||||
return SoundIoErrorStreaming;
|
if ((err = jack_connect(isj->client, source_port_name, dest_port_name)))
|
||||||
|
return SoundIoErrorStreaming;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue