diff --git a/src/pipewire-audio-capture-app.c b/src/pipewire-audio-capture-app.c index f7059c1..746ebb4 100644 --- a/src/pipewire-audio-capture-app.c +++ b/src/pipewire-audio-capture-app.c @@ -525,7 +525,7 @@ static bool make_capture_sink(struct obs_pw_audio_capture_app *pwac, uint32_t ch pwac->sink.autoconnect_targets = true; - if (obs_pw_audio_stream_connect(&pwac->pw.audio, pwac->sink.serial, channels) < 0) { + if (obs_pw_audio_stream_connect(&pwac->pw.audio, pwac->sink.id, pwac->sink.serial, channels) < 0) { blog(LOG_WARNING, "[pipewire] Error connecting stream %p to app capture sink %u", pwac->pw.audio.stream, pwac->sink.id); } diff --git a/src/pipewire-audio-capture-device.c b/src/pipewire-audio-capture-device.c index c8fe248..fdef176 100644 --- a/src/pipewire-audio-capture-device.c +++ b/src/pipewire-audio-capture-device.c @@ -28,6 +28,7 @@ struct target_node { const char *friendly_name; const char *name; uint32_t serial; + uint32_t id; uint32_t channels; struct spa_hook node_listener; @@ -78,7 +79,7 @@ static void start_streaming(struct obs_pw_audio_capture_device *pwac, struct tar return; } - if (obs_pw_audio_stream_connect(&pwac->pw.audio, node->serial, node->channels) == 0) { + if (obs_pw_audio_stream_connect(&pwac->pw.audio, node->id, node->serial, node->channels) == 0) { pwac->connected_serial = node->serial; blog(LOG_INFO, "[pipewire] %p streaming from %u", pwac->pw.audio.stream, node->serial); } else { @@ -186,6 +187,7 @@ static void register_target_node(struct obs_pw_audio_capture_device *pwac, const struct target_node *n = pw_proxy_get_user_data(node_proxy); n->friendly_name = bstrdup(friendly_name); n->name = bstrdup(name); + n->id = global_id; n->serial = object_serial; n->channels = 0; n->pwac = pwac; diff --git a/src/pipewire-audio.c b/src/pipewire-audio.c index d7ff63b..95ee923 100644 --- a/src/pipewire-audio.c +++ b/src/pipewire-audio.c @@ -264,7 +264,8 @@ static const struct pw_stream_events stream_events = { .io_changed = on_io_changed_cb, }; -int obs_pw_audio_stream_connect(struct obs_pw_audio_stream *s, uint32_t target_serial, uint32_t audio_channels) +int obs_pw_audio_stream_connect(struct obs_pw_audio_stream *s, uint32_t target_id, uint32_t target_serial, + uint32_t audio_channels) { enum spa_audio_channel pos[8]; obs_channels_to_spa_audio_position(pos, audio_channels); @@ -287,7 +288,7 @@ int obs_pw_audio_stream_connect(struct obs_pw_audio_stream *s, uint32_t target_s pw_stream_update_properties(s->stream, &stream_props->dict); pw_properties_free(stream_props); - return pw_stream_connect(s->stream, PW_DIRECTION_INPUT, PW_ID_ANY, + return pw_stream_connect(s->stream, PW_DIRECTION_INPUT, target_id, PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_MAP_BUFFERS | PW_STREAM_FLAG_DONT_RECONNECT, params, 1); } diff --git a/src/pipewire-audio.h b/src/pipewire-audio.h index 56031d3..422b484 100644 --- a/src/pipewire-audio.h +++ b/src/pipewire-audio.h @@ -55,7 +55,8 @@ struct obs_pw_audio_stream { * Connect a stream with the default params * @return 0 on success, < 0 on error */ -int obs_pw_audio_stream_connect(struct obs_pw_audio_stream *s, uint32_t target_serial, uint32_t channels); +int obs_pw_audio_stream_connect(struct obs_pw_audio_stream *s, uint32_t target_id, uint32_t target_serial, + uint32_t channels); /* ------------------------------------------------- */ /**