filter-chain: manage graph from source only

Only react to the capture stream state change and format changes. The
playback and capture streams change state somewhat concurrently and so
the graph state might not be consistent.

Because only the capture stream will trigger the playback stream and
start the processing, we can safely react to capture stream changes
only.
This commit is contained in:
Wim Taymans 2025-05-21 15:23:00 +02:00
parent ccb7a51c3a
commit 5e81ff8ede

View file

@ -1084,7 +1084,7 @@ static void param_tag_changed(struct impl *impl, const struct spa_pod *param,
pw_stream_update_params(impl->playback, params, 1);
}
static void state_changed(void *data, enum pw_stream_state old,
static void capture_state_changed(void *data, enum pw_stream_state old,
enum pw_stream_state state, const char *error)
{
struct impl *impl = data;
@ -1159,7 +1159,9 @@ static void param_changed(struct impl *impl, uint32_t id, const struct spa_pod *
struct spa_audio_info_raw info;
spa_zero(info);
if (param == NULL) {
spa_filter_graph_deactivate(graph);
pw_log_info("module %p: filter deactivate", impl);
if (direction == SPA_DIRECTION_INPUT)
spa_filter_graph_deactivate(graph);
impl->rate = 0;
} else {
if ((res = spa_format_audio_raw_parse(param, &info)) < 0)
@ -1200,7 +1202,7 @@ static const struct pw_stream_events in_stream_events = {
.destroy = capture_destroy,
.process = capture_process,
.io_changed = io_changed,
.state_changed = state_changed,
.state_changed = capture_state_changed,
.param_changed = capture_param_changed
};
@ -1222,7 +1224,6 @@ static const struct pw_stream_events out_stream_events = {
.destroy = playback_destroy,
.process = playback_process,
.io_changed = io_changed,
.state_changed = state_changed,
.param_changed = playback_param_changed,
};