Skip to content

Commit

Permalink
add lock to rc_client_get_rich_presence_message
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiras committed Oct 23, 2023
1 parent 6c2e98f commit ce1c16a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/rc_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -4038,8 +4038,12 @@ static void rc_client_ping(rc_client_scheduled_callback_data_t* callback_data, r

if (!client->callbacks.rich_presence_override ||
!client->callbacks.rich_presence_override(client, buffer, sizeof(buffer))) {
rc_mutex_lock(&client->state.mutex);

rc_runtime_get_richpresence(&client->game->runtime, buffer, sizeof(buffer),
client->state.legacy_peek, client, NULL);

rc_mutex_unlock(&client->state.mutex);
}

memset(&api_params, 0, sizeof(api_params));
Expand Down Expand Up @@ -4078,9 +4082,13 @@ size_t rc_client_get_rich_presence_message(rc_client_t* client, char buffer[], s
if (!client || !client->game || !buffer)
return 0;

rc_mutex_lock(&client->state.mutex);

result = rc_runtime_get_richpresence(&client->game->runtime, buffer, (unsigned)buffer_size,
client->state.legacy_peek, client, NULL);

rc_mutex_unlock(&client->state.mutex);

if (result == 0)
result = snprintf(buffer, buffer_size, "Playing %s", client->game->public_.title);

Expand Down

0 comments on commit ce1c16a

Please sign in to comment.