From f7e97ab157538e111e2e454c6c8c21bde19f0467 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 4 Nov 2024 17:09:59 +0100 Subject: [PATCH] examples: update the examples with new lazy scheduling flags The src can listen to RequestProcess commands and so gets the node.supports-request = 1 property. The play-pull example can both be a driver that listens to RequestProcess or a lazy driver so set this in properties as well. We can now remove the priority.driver property because automatic priority selection will make us a driver or not. With this change, video-src to video-play-pull will use lazy scheduling with play-pull as the driver. video-play-pull to v4l2src will use normal scheduling and video-src to video-play will also use normal scheduling. --- src/examples/video-play-pull.c | 15 +++++++++------ src/examples/video-src.c | 10 ++++++++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/examples/video-play-pull.c b/src/examples/video-play-pull.c index 2e685d06a..f9492edea 100644 --- a/src/examples/video-play-pull.c +++ b/src/examples/video-play-pull.c @@ -259,7 +259,11 @@ static void on_stream_state_changed(void *_data, enum pw_stream_state old, enable_timeouts(data, false); break; case PW_STREAM_STATE_STREAMING: - enable_timeouts(data, true); + printf("driving:%d lazy:%d\n", + pw_stream_is_driving(data->stream), + pw_stream_is_lazy(data->stream)); + if (pw_stream_is_driving(data->stream) != pw_stream_is_lazy(data->stream)) + enable_timeouts(data, true); break; default: break; @@ -288,8 +292,7 @@ on_trigger_done(void *_data) static void on_timeout(void *userdata, uint64_t expirations) { struct data *data = userdata; - if (!data->have_request_process) - pw_stream_trigger_process(data->stream); + pw_stream_trigger_process(data->stream); } static void @@ -298,8 +301,7 @@ on_command(void *_data, const struct spa_command *command) struct data *data = _data; switch (SPA_NODE_COMMAND_ID(command)) { case SPA_NODE_COMMAND_RequestProcess: - data->have_request_process = true; - enable_timeouts(data, false); + pw_log_trace("%p trigger", data); pw_stream_trigger_process(data->stream); break; default: @@ -507,7 +509,8 @@ int main(int argc, char *argv[]) props = pw_properties_new(PW_KEY_MEDIA_TYPE, "Video", PW_KEY_MEDIA_CATEGORY, "Capture", PW_KEY_MEDIA_ROLE, "Camera", - PW_KEY_PRIORITY_DRIVER, "10000", + PW_KEY_NODE_SUPPORTS_LAZY, "1", + PW_KEY_NODE_SUPPORTS_REQUEST, "1", NULL), data.path = argc > 1 ? argv[1] : NULL; if (data.path) diff --git a/src/examples/video-src.c b/src/examples/video-src.c index 777ea7979..f439f168e 100644 --- a/src/examples/video-src.c +++ b/src/examples/video-src.c @@ -194,8 +194,13 @@ static void on_stream_state_changed(void *_data, enum pw_stream_state old, enum interval.tv_sec = 0; interval.tv_nsec = 40 * SPA_NSEC_PER_MSEC; - pw_loop_update_timer(pw_main_loop_get_loop(data->loop), - data->timer, &timeout, &interval, false); + printf("driving:%d lazy:%d\n", + pw_stream_is_driving(data->stream), + pw_stream_is_lazy(data->stream)); + + if (pw_stream_is_driving(data->stream) != pw_stream_is_lazy(data->stream)) + pw_loop_update_timer(pw_main_loop_get_loop(data->loop), + data->timer, &timeout, &interval, false); break; } default: @@ -305,6 +310,7 @@ int main(int argc, char *argv[]) data.stream = pw_stream_new(data.core, "video-src", pw_properties_new( PW_KEY_MEDIA_CLASS, "Video/Source", + PW_KEY_NODE_SUPPORTS_REQUEST, "1", NULL)); params[0] = spa_pod_builder_add_object(&b,