LADI
/
spa
1
Fork 0

module-combine-stream: fix race when destroying streams

Use separate flag for indicating if pw_stream_destroy is needed.

Don't set s->stream = NULL to indicate that, it will race with data
loop. Setting to null separately is not needed, removing from the stream
list is enough.
This commit is contained in:
Pauli Virtanen 2023-05-05 21:11:32 +03:00 committed by Wim Taymans
parent 12b6adb10c
commit 2a0f1597ab
1 changed files with 8 additions and 4 deletions

View File

@ -613,13 +613,13 @@ static int do_remove_stream(struct spa_loop *loop, bool async, uint32_t seq,
return 0;
}
static void destroy_stream(struct stream *s)
static void remove_stream(struct stream *s, bool destroy)
{
pw_log_debug("destroy stream %d", s->id);
pw_data_loop_invoke(s->impl->data_loop, do_remove_stream, 0, NULL, 0, true, s);
if (s->stream) {
if (destroy && s->stream) {
spa_hook_remove(&s->stream_listener);
pw_stream_destroy(s->stream);
}
@ -628,12 +628,16 @@ static void destroy_stream(struct stream *s)
free(s);
}
static void destroy_stream(struct stream *s)
{
remove_stream(s, true);
}
static void stream_destroy(void *d)
{
struct stream *s = d;
spa_hook_remove(&s->stream_listener);
s->stream = NULL;
destroy_stream(s);
remove_stream(s, false);
}
static void stream_input_process(void *d)