diff --git a/src/examples/video-src-alloc.c b/src/examples/video-src-alloc.c index b43cdd497..c9a5c6c67 100644 --- a/src/examples/video-src-alloc.c +++ b/src/examples/video-src-alloc.c @@ -80,8 +80,8 @@ static void draw_elipse(uint32_t *dst, int width, int height, uint32_t color) } } -/* called on timeout and we should push a new buffer in the queue */ -static void on_timeout(void *userdata, uint64_t expirations) +/* called when we should push a new buffer in the queue */ +static void on_process(void *userdata) { struct data *data = userdata; struct pw_buffer *b; @@ -93,8 +93,6 @@ static void on_timeout(void *userdata, uint64_t expirations) struct spa_meta_region *mc; struct spa_meta_cursor *mcs; - pw_log_trace("timeout"); - if ((b = pw_stream_dequeue_buffer(data->stream)) == NULL) { pw_log_warn("out of buffers: %m"); return; @@ -178,6 +176,14 @@ static void on_timeout(void *userdata, uint64_t expirations) pw_stream_queue_buffer(data->stream, b); } +/* trigger the graph when we are a driver */ +static void on_timeout(void *userdata, uint64_t expirations) +{ + struct data *data = userdata; + pw_log_trace("timeout"); + pw_stream_drive(data->stream); +} + /* when the stream is STREAMING, start the timer at 40ms intervals * to produce and push a frame. In other states we PAUSE the timer. */ static void on_stream_state_changed(void *_data, enum pw_stream_state old, enum pw_stream_state state, @@ -345,6 +351,7 @@ on_stream_param_changed(void *_data, uint32_t id, const struct spa_pod *param) static const struct pw_stream_events stream_events = { PW_VERSION_STREAM_EVENTS, + .process = on_process, .state_changed = on_stream_state_changed, .param_changed = on_stream_param_changed, .add_buffer = on_stream_add_buffer, diff --git a/src/examples/video-src-reneg.c b/src/examples/video-src-reneg.c index 133fc9098..912179263 100644 --- a/src/examples/video-src-reneg.c +++ b/src/examples/video-src-reneg.c @@ -82,8 +82,8 @@ static void draw_elipse(uint32_t *dst, int width, int height, uint32_t color) } } -/* called on timeout and we should push a new buffer in the queue */ -static void on_timeout(void *userdata, uint64_t expirations) +/* called when we should push a new buffer in the queue */ +static void on_process(void *userdata) { struct data *data = userdata; struct pw_buffer *b; @@ -180,6 +180,14 @@ static void on_timeout(void *userdata, uint64_t expirations) pw_stream_queue_buffer(data->stream, b); } +/* called on timeout and we should start the graph */ +static void on_timeout(void *userdata, uint64_t expirations) +{ + struct data *data = userdata; + pw_log_trace("timeout"); + pw_stream_drive(data->stream); +} + /* when the stream is STREAMING, start the timer at 40ms intervals * to produce and push a frame. In other states we PAUSE the timer. */ static void on_stream_state_changed(void *_data, enum pw_stream_state old, enum pw_stream_state state, @@ -358,6 +366,7 @@ on_stream_param_changed(void *_data, uint32_t id, const struct spa_pod *param) static const struct pw_stream_events stream_events = { PW_VERSION_STREAM_EVENTS, + .process = on_process, .state_changed = on_stream_state_changed, .param_changed = on_stream_param_changed, .add_buffer = on_stream_add_buffer, diff --git a/src/examples/video-src.c b/src/examples/video-src.c index 875ae3e21..8b15b33e8 100644 --- a/src/examples/video-src.c +++ b/src/examples/video-src.c @@ -79,7 +79,7 @@ static void draw_elipse(uint32_t *dst, int width, int height, uint32_t color) } } -static void on_timeout(void *userdata, uint64_t expirations) +static void on_process(void *userdata) { struct data *data = userdata; struct pw_buffer *b; @@ -91,8 +91,6 @@ static void on_timeout(void *userdata, uint64_t expirations) struct spa_meta_region *mc; struct spa_meta_cursor *mcs; - pw_log_trace("timeout"); - if ((b = pw_stream_dequeue_buffer(data->stream)) == NULL) { pw_log_warn("out of buffers: %m"); return; @@ -176,6 +174,13 @@ static void on_timeout(void *userdata, uint64_t expirations) pw_stream_queue_buffer(data->stream, b); } +static void on_timeout(void *userdata, uint64_t expirations) +{ + struct data *data = userdata; + pw_log_trace("timeout"); + pw_stream_drive(data->stream); +} + static void on_stream_state_changed(void *_data, enum pw_stream_state old, enum pw_stream_state state, const char *error) { @@ -265,6 +270,7 @@ on_stream_param_changed(void *_data, uint32_t id, const struct spa_pod *param) static const struct pw_stream_events stream_events = { PW_VERSION_STREAM_EVENTS, + .process = on_process, .state_changed = on_stream_state_changed, .param_changed = on_stream_param_changed, };