Skip to content

Commit

Permalink
Include source name in node properties
Browse files Browse the repository at this point in the history
To help distinguish which node corresponds to which source in graph
viewers etc.

Fixes #73
  • Loading branch information
dimtpap committed Sep 10, 2024
1 parent e27ff0e commit 7bb1289
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
9 changes: 5 additions & 4 deletions src/pipewire-audio-capture-app.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,11 @@ static bool make_capture_sink(struct obs_pw_audio_capture_app *pwac, uint32_t ch
* and because of https://gitlab.freedesktop.org/pipewire/pipewire/-/merge_requests/1564#note_1861698, which works the same for
* deciding what nodes need an audio adapter.
*/
struct pw_properties *sink_props =
pw_properties_new(PW_KEY_NODE_NAME, "OBS", PW_KEY_NODE_DESCRIPTION, "OBS App Audio Capture Sink",
PW_KEY_FACTORY_NAME, "support.null-audio-sink", PW_KEY_MEDIA_CLASS, "Audio/Sink/Internal",
PW_KEY_NODE_VIRTUAL, "true", SPA_KEY_AUDIO_POSITION, position, NULL);
struct pw_properties *sink_props = pw_properties_new(PW_KEY_FACTORY_NAME, "support.null-audio-sink",
PW_KEY_MEDIA_CLASS, "Audio/Sink/Internal", PW_KEY_NODE_VIRTUAL,
"true", SPA_KEY_AUDIO_POSITION, position, NULL);

pw_properties_setf(sink_props, PW_KEY_NODE_NAME, "OBS: %s", obs_source_get_name(pwac->source));

pw_properties_setf(sink_props, PW_KEY_AUDIO_CHANNELS, "%u", channels);

Expand Down
14 changes: 8 additions & 6 deletions src/pipewire-audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,15 @@ bool obs_pw_audio_instance_init(struct obs_pw_audio_instance *pw, const struct p
}
pw_registry_add_listener(pw->registry, &pw->registry_listener, registry_events, registry_cb_data);

struct pw_properties *stream_props = pw_properties_new(
PW_KEY_MEDIA_NAME, obs_source_get_name(stream_output), PW_KEY_MEDIA_TYPE, "Audio", PW_KEY_MEDIA_CATEGORY,
"Capture", PW_KEY_MEDIA_ROLE, "Production", PW_KEY_NODE_WANT_DRIVER, stream_want_driver ? "true" : "false",
PW_KEY_STREAM_CAPTURE_SINK, stream_capture_sink ? "true" : "false", NULL);

pw_properties_setf(stream_props, PW_KEY_NODE_NAME, "OBS: %s", obs_source_get_name(stream_output));

pw->audio.output = stream_output;
pw->audio.stream =
pw_stream_new(pw->core, "OBS",
pw_properties_new(PW_KEY_NODE_NAME, "OBS", PW_KEY_NODE_DESCRIPTION, "OBS Audio Capture",
PW_KEY_MEDIA_TYPE, "Audio", PW_KEY_MEDIA_CATEGORY, "Capture", PW_KEY_MEDIA_ROLE,
"Production", PW_KEY_NODE_WANT_DRIVER, stream_want_driver ? "true" : "false",
PW_KEY_STREAM_CAPTURE_SINK, stream_capture_sink ? "true" : "false", NULL));
pw->audio.stream = pw_stream_new(pw->core, obs_source_get_name(stream_output), stream_props);

if (!pw->audio.stream) {
blog(LOG_WARNING, "[pipewire] Failed to create stream");
Expand Down

0 comments on commit 7bb1289

Please sign in to comment.