screencast: fix pipewire default id_node

The default node_id is SPA_ID_INVALID.

We are casting pipewire uint32_t node_id to int for printing since they are
currently staying in the range of low integer numbers. This makes
spotting an uninitialized node_id (casted to -1) much easier. Should be
corrected if that becomes an issue in the future.
This commit is contained in:
columbarius 2021-08-10 11:56:39 +02:00 committed by Simon Ser
parent 6cc3a01741
commit 5f5a29ccfd
2 changed files with 4 additions and 2 deletions

View file

@ -111,7 +111,7 @@ static void pwr_handle_stream_state_changed(void *data,
logprint(INFO, "pipewire: stream state changed to \"%s\"", logprint(INFO, "pipewire: stream state changed to \"%s\"",
pw_stream_state_as_string(state)); pw_stream_state_as_string(state));
logprint(INFO, "pipewire: node id is %d", cast->node_id); logprint(INFO, "pipewire: node id is %d", (int)cast->node_id);
switch (state) { switch (state) {
case PW_STREAM_STATE_STREAMING: case PW_STREAM_STATE_STREAMING:

View file

@ -59,6 +59,7 @@ void xdpw_screencast_instance_init(struct xdpw_screencast_context *ctx,
cast->framerate = cast->max_framerate; cast->framerate = cast->max_framerate;
cast->with_cursor = with_cursor; cast->with_cursor = with_cursor;
cast->refcount = 1; cast->refcount = 1;
cast->node_id = SPA_ID_INVALID;
logprint(INFO, "xdpw: screencast instance %p has %d references", cast, cast->refcount); logprint(INFO, "xdpw: screencast instance %p has %d references", cast, cast->refcount);
wl_list_insert(&ctx->screencast_instances, &cast->link); wl_list_insert(&ctx->screencast_instances, &cast->link);
logprint(INFO, "xdpw: %d active screencast instances", logprint(INFO, "xdpw: %d active screencast instances",
@ -419,7 +420,7 @@ static int method_screencast_start(sd_bus_message *msg, void *data,
start_screencast(cast); start_screencast(cast);
} }
while (cast->node_id == 0) { while (cast->node_id == SPA_ID_INVALID) {
int ret = pw_loop_iterate(state->pw_loop, 0); int ret = pw_loop_iterate(state->pw_loop, 0);
if (ret != 0) { if (ret != 0) {
logprint(ERROR, "pipewire_loop_iterate failed: %s", spa_strerror(ret)); logprint(ERROR, "pipewire_loop_iterate failed: %s", spa_strerror(ret));
@ -432,6 +433,7 @@ static int method_screencast_start(sd_bus_message *msg, void *data,
return ret; return ret;
} }
logprint(DEBUG, "dbus: start: returning node %d", (int)cast->node_id);
ret = sd_bus_message_append(reply, "ua{sv}", PORTAL_RESPONSE_SUCCESS, 1, ret = sd_bus_message_append(reply, "ua{sv}", PORTAL_RESPONSE_SUCCESS, 1,
"streams", "a(ua{sv})", 1, "streams", "a(ua{sv})", 1,
cast->node_id, 2, cast->node_id, 2,