pulse-server: pending-sample: move reference counting

Move the reference counting from `pending_sample_free()`
into `on_sample_done()` so that the client's references
are managed in a single place.

The reason why `pending_sample_free()` cannot simply call
`client_unref()` is that `client_free()` may be called from
`manager_disconnect()` regardless of the reference count,
and, in turn, `pending_sample_free()` may be called,
which could then lead to a recursive call to `client_free()`.
This commit is contained in:
Barnabás Pőcze 2022-01-31 14:53:42 +01:00 committed by Wim Taymans
parent 29a288ebae
commit bc2914b3e9
2 changed files with 2 additions and 4 deletions

View file

@ -41,7 +41,5 @@ void pending_sample_free(struct pending_sample *ps)
spa_hook_remove(&ps->listener);
pw_work_queue_cancel(impl->work_queue, ps, SPA_ID_INVALID);
client->ref--;
sample_play_destroy(ps->play);
}

View file

@ -2344,9 +2344,9 @@ static void on_sample_done(void *obj, void *data, int res, uint32_t id)
{
struct pending_sample *ps = obj;
struct client *client = ps->client;
pending_sample_free(ps);
if (client->ref <= 0)
client_free(client);
client_unref(client);
}
static void sample_play_done(void *data, int res)