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.
This commit is contained in:
Wim Taymans 2024-11-04 17:09:59 +01:00
parent 61f15734e1
commit ff984da67c
2 changed files with 17 additions and 8 deletions

View file

@ -259,7 +259,11 @@ static void on_stream_state_changed(void *_data, enum pw_stream_state old,
enable_timeouts(data, false); enable_timeouts(data, false);
break; break;
case PW_STREAM_STATE_STREAMING: 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; break;
default: default:
break; break;
@ -288,8 +292,7 @@ on_trigger_done(void *_data)
static void on_timeout(void *userdata, uint64_t expirations) static void on_timeout(void *userdata, uint64_t expirations)
{ {
struct data *data = userdata; struct data *data = userdata;
if (!data->have_request_process) pw_stream_trigger_process(data->stream);
pw_stream_trigger_process(data->stream);
} }
static void static void
@ -298,8 +301,7 @@ on_command(void *_data, const struct spa_command *command)
struct data *data = _data; struct data *data = _data;
switch (SPA_NODE_COMMAND_ID(command)) { switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_RequestProcess: case SPA_NODE_COMMAND_RequestProcess:
data->have_request_process = true; pw_log_trace("%p trigger", data);
enable_timeouts(data, false);
pw_stream_trigger_process(data->stream); pw_stream_trigger_process(data->stream);
break; break;
default: default:
@ -507,7 +509,8 @@ int main(int argc, char *argv[])
props = pw_properties_new(PW_KEY_MEDIA_TYPE, "Video", props = pw_properties_new(PW_KEY_MEDIA_TYPE, "Video",
PW_KEY_MEDIA_CATEGORY, "Capture", PW_KEY_MEDIA_CATEGORY, "Capture",
PW_KEY_MEDIA_ROLE, "Camera", PW_KEY_MEDIA_ROLE, "Camera",
PW_KEY_PRIORITY_DRIVER, "10000", PW_KEY_NODE_SUPPORTS_LAZY, "1",
PW_KEY_NODE_SUPPORTS_REQUEST, "1",
NULL), NULL),
data.path = argc > 1 ? argv[1] : NULL; data.path = argc > 1 ? argv[1] : NULL;
if (data.path) if (data.path)

View file

@ -194,8 +194,13 @@ static void on_stream_state_changed(void *_data, enum pw_stream_state old, enum
interval.tv_sec = 0; interval.tv_sec = 0;
interval.tv_nsec = 40 * SPA_NSEC_PER_MSEC; interval.tv_nsec = 40 * SPA_NSEC_PER_MSEC;
pw_loop_update_timer(pw_main_loop_get_loop(data->loop), printf("driving:%d lazy:%d\n",
data->timer, &timeout, &interval, false); 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; break;
} }
default: default:
@ -305,6 +310,7 @@ int main(int argc, char *argv[])
data.stream = pw_stream_new(data.core, "video-src", data.stream = pw_stream_new(data.core, "video-src",
pw_properties_new( pw_properties_new(
PW_KEY_MEDIA_CLASS, "Video/Source", PW_KEY_MEDIA_CLASS, "Video/Source",
PW_KEY_NODE_SUPPORTS_REQUEST, "1",
NULL)); NULL));
params[0] = spa_pod_builder_add_object(&b, params[0] = spa_pod_builder_add_object(&b,