mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
examples: update video-src examples
So that hey use pw_stream_drive() to start the graph.
This commit is contained in:
parent
9831f62927
commit
23d3b10be4
3 changed files with 31 additions and 9 deletions
|
|
@ -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 */
|
/* called when we should push a new buffer in the queue */
|
||||||
static void on_timeout(void *userdata, uint64_t expirations)
|
static void on_process(void *userdata)
|
||||||
{
|
{
|
||||||
struct data *data = userdata;
|
struct data *data = userdata;
|
||||||
struct pw_buffer *b;
|
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_region *mc;
|
||||||
struct spa_meta_cursor *mcs;
|
struct spa_meta_cursor *mcs;
|
||||||
|
|
||||||
pw_log_trace("timeout");
|
|
||||||
|
|
||||||
if ((b = pw_stream_dequeue_buffer(data->stream)) == NULL) {
|
if ((b = pw_stream_dequeue_buffer(data->stream)) == NULL) {
|
||||||
pw_log_warn("out of buffers: %m");
|
pw_log_warn("out of buffers: %m");
|
||||||
return;
|
return;
|
||||||
|
|
@ -178,6 +176,14 @@ static void on_timeout(void *userdata, uint64_t expirations)
|
||||||
pw_stream_queue_buffer(data->stream, b);
|
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
|
/* when the stream is STREAMING, start the timer at 40ms intervals
|
||||||
* to produce and push a frame. In other states we PAUSE the timer. */
|
* 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,
|
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 = {
|
static const struct pw_stream_events stream_events = {
|
||||||
PW_VERSION_STREAM_EVENTS,
|
PW_VERSION_STREAM_EVENTS,
|
||||||
|
.process = on_process,
|
||||||
.state_changed = on_stream_state_changed,
|
.state_changed = on_stream_state_changed,
|
||||||
.param_changed = on_stream_param_changed,
|
.param_changed = on_stream_param_changed,
|
||||||
.add_buffer = on_stream_add_buffer,
|
.add_buffer = on_stream_add_buffer,
|
||||||
|
|
|
||||||
|
|
@ -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 */
|
/* called when we should push a new buffer in the queue */
|
||||||
static void on_timeout(void *userdata, uint64_t expirations)
|
static void on_process(void *userdata)
|
||||||
{
|
{
|
||||||
struct data *data = userdata;
|
struct data *data = userdata;
|
||||||
struct pw_buffer *b;
|
struct pw_buffer *b;
|
||||||
|
|
@ -180,6 +180,14 @@ static void on_timeout(void *userdata, uint64_t expirations)
|
||||||
pw_stream_queue_buffer(data->stream, b);
|
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
|
/* when the stream is STREAMING, start the timer at 40ms intervals
|
||||||
* to produce and push a frame. In other states we PAUSE the timer. */
|
* 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,
|
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 = {
|
static const struct pw_stream_events stream_events = {
|
||||||
PW_VERSION_STREAM_EVENTS,
|
PW_VERSION_STREAM_EVENTS,
|
||||||
|
.process = on_process,
|
||||||
.state_changed = on_stream_state_changed,
|
.state_changed = on_stream_state_changed,
|
||||||
.param_changed = on_stream_param_changed,
|
.param_changed = on_stream_param_changed,
|
||||||
.add_buffer = on_stream_add_buffer,
|
.add_buffer = on_stream_add_buffer,
|
||||||
|
|
|
||||||
|
|
@ -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 data *data = userdata;
|
||||||
struct pw_buffer *b;
|
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_region *mc;
|
||||||
struct spa_meta_cursor *mcs;
|
struct spa_meta_cursor *mcs;
|
||||||
|
|
||||||
pw_log_trace("timeout");
|
|
||||||
|
|
||||||
if ((b = pw_stream_dequeue_buffer(data->stream)) == NULL) {
|
if ((b = pw_stream_dequeue_buffer(data->stream)) == NULL) {
|
||||||
pw_log_warn("out of buffers: %m");
|
pw_log_warn("out of buffers: %m");
|
||||||
return;
|
return;
|
||||||
|
|
@ -176,6 +174,13 @@ static void on_timeout(void *userdata, uint64_t expirations)
|
||||||
pw_stream_queue_buffer(data->stream, b);
|
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,
|
static void on_stream_state_changed(void *_data, enum pw_stream_state old, enum pw_stream_state state,
|
||||||
const char *error)
|
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 = {
|
static const struct pw_stream_events stream_events = {
|
||||||
PW_VERSION_STREAM_EVENTS,
|
PW_VERSION_STREAM_EVENTS,
|
||||||
|
.process = on_process,
|
||||||
.state_changed = on_stream_state_changed,
|
.state_changed = on_stream_state_changed,
|
||||||
.param_changed = on_stream_param_changed,
|
.param_changed = on_stream_param_changed,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue