examples: update video-src examples

So that hey use pw_stream_drive() to start the graph.
This commit is contained in:
Wim Taymans 2021-08-06 13:55:43 +02:00
parent 9831f62927
commit 23d3b10be4
3 changed files with 31 additions and 9 deletions

View file

@ -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,

View file

@ -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,

View file

@ -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,
};