pipewire/src/modules/module-protocol-pulse/pending-sample.h
Barnabás Pőcze 2ba9881b4d pulse-server: pending-sample: handle client disconnection correctly
Previously, a client disconnecting while a sample was playing could
lead to issues. For example, if a client disconnected before the
"ready" signal of the sample-play arrives, `operation_new_cb()`
would be called and that would try to use the client's pw_manager,
however, that has previously been destroyed in `client_disconnect()`.

If the client disconnected after the "ready" signal but before the reply
has been sent, then `sample_play_ready_reply()` would never be called
since operations are completed via the client's pw_manager which
would already be destroyed at that point.

Fix this by installing a listener on the client, and properly
cancelling the operation and making sure that the pending_sample
is correctly destroyed.
2023-05-10 18:57:20 +00:00

32 lines
766 B
C

/* PipeWire */
/* SPDX-FileCopyrightText: Copyright © 2020 Wim Taymans */
/* SPDX-License-Identifier: MIT */
#ifndef PULSE_SERVER_PENDING_SAMPLE_H
#define PULSE_SERVER_PENDING_SAMPLE_H
#include <stdint.h>
#include <spa/utils/list.h>
#include <spa/utils/hook.h>
struct client;
struct pw_properties;
struct sample;
struct sample_play;
struct pending_sample {
struct spa_list link;
struct client *client;
struct sample_play *play;
struct spa_hook listener;
struct spa_hook client_listener;
uint32_t tag;
unsigned replied:1;
unsigned done:1;
};
int pending_sample_new(struct client *client, struct sample *sample, struct pw_properties *props, uint32_t tag);
void pending_sample_free(struct pending_sample *ps);
#endif /* PULSE_SERVER_PENDING_SAMPLE_H */