diff --git a/src/modules/module-protocol-pulse/operation.h b/src/modules/module-protocol-pulse/operation.h index 05091f11a..775a4e632 100644 --- a/src/modules/module-protocol-pulse/operation.h +++ b/src/modules/module-protocol-pulse/operation.h @@ -27,4 +27,11 @@ struct operation *operation_find(struct client *client, uint32_t tag); void operation_free(struct operation *o); void operation_complete(struct operation *o); +static inline void operation_free_by_tag(struct client *client, uint32_t tag) +{ + struct operation *o = operation_find(client, tag); + if (o) + operation_free(o); +} + #endif /* PULSER_SERVER_OPERATION_H */ diff --git a/src/modules/module-protocol-pulse/pending-sample.c b/src/modules/module-protocol-pulse/pending-sample.c index 7e673a811..43e20cb6f 100644 --- a/src/modules/module-protocol-pulse/pending-sample.c +++ b/src/modules/module-protocol-pulse/pending-sample.c @@ -110,14 +110,12 @@ void pending_sample_free(struct pending_sample *ps) { struct client * const client = ps->client; struct impl * const impl = client->impl; - struct operation *o; spa_list_remove(&ps->link); spa_hook_remove(&ps->listener); pw_work_queue_cancel(impl->work_queue, ps, SPA_ID_INVALID); - if ((o = operation_find(client, ps->tag)) != NULL) - operation_free(o); + operation_free_by_tag(client, ps->tag); sample_play_destroy(ps->play); }