mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
stream: Align with pw_filter
Remove some of the unused states in pw_stream. The app can know the state by following the format and buffer events. Make it possible to be notified of io are updates. This should make it possible to follow the transport etc. Make it possible to be notified of any param changes. Rename finish_format to update_params because that is what it does. Make this work in the same was as the filter: updating the params removes all old params of the types and installs the new ones. Don't get the Props and PropInfo from the node proxy, instead get them directly from the adapter that we have locally. Update the controls directly on the adapter instead of going to the server first.
This commit is contained in:
parent
be53554def
commit
738603fd04
11 changed files with 232 additions and 268 deletions
|
|
@ -220,7 +220,7 @@ static void on_stream_state_changed(void *_data, enum pw_stream_state old,
|
|||
case PW_STREAM_STATE_UNCONNECTED:
|
||||
pw_main_loop_quit(data->loop);
|
||||
break;
|
||||
case PW_STREAM_STATE_CONFIGURE:
|
||||
case PW_STREAM_STATE_PAUSED:
|
||||
/* because we started inactive, activate ourselves now */
|
||||
pw_stream_set_active(data->stream, true);
|
||||
break;
|
||||
|
|
@ -229,7 +229,8 @@ static void on_stream_state_changed(void *_data, enum pw_stream_state old,
|
|||
}
|
||||
}
|
||||
|
||||
/* Be notified when the stream format changes.
|
||||
/* Be notified when the stream param changes. We're only looking at the
|
||||
* format changes.
|
||||
*
|
||||
* We are now supposed to call pw_stream_finish_format() with success or
|
||||
* failure, depending on if we can support the format. Because we gave
|
||||
|
|
@ -240,7 +241,7 @@ static void on_stream_state_changed(void *_data, enum pw_stream_state old,
|
|||
* that we would like on our buffer, the size, alignment, etc.
|
||||
*/
|
||||
static void
|
||||
on_stream_format_changed(void *_data, const struct spa_pod *format)
|
||||
on_stream_param_changed(void *_data, uint32_t id, const struct spa_pod *param)
|
||||
{
|
||||
struct data *data = _data;
|
||||
struct pw_stream *stream = data->stream;
|
||||
|
|
@ -251,16 +252,14 @@ on_stream_format_changed(void *_data, const struct spa_pod *format)
|
|||
void *d;
|
||||
|
||||
/* NULL means to clear the format */
|
||||
if (format == NULL) {
|
||||
pw_stream_finish_format(stream, 0, NULL, 0);
|
||||
if (param == NULL || id != SPA_PARAM_Format)
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stderr, "got format:\n");
|
||||
spa_debug_format(2, NULL, format);
|
||||
spa_debug_format(2, NULL, param);
|
||||
|
||||
/* call a helper function to parse the format for us. */
|
||||
spa_format_video_raw_parse(format, &data->format);
|
||||
spa_format_video_raw_parse(param, &data->format);
|
||||
|
||||
if (data->format.format == SPA_VIDEO_FORMAT_RGBA_F32)
|
||||
sdl_format = SDL_PIXELFORMAT_RGBA32;
|
||||
|
|
@ -268,7 +267,7 @@ on_stream_format_changed(void *_data, const struct spa_pod *format)
|
|||
sdl_format = id_to_sdl_format(data->format.format);
|
||||
|
||||
if (sdl_format == SDL_PIXELFORMAT_UNKNOWN) {
|
||||
pw_stream_finish_format(stream, -EINVAL, NULL, 0);
|
||||
pw_stream_set_error(stream, -EINVAL, "unknown pixel format");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -317,14 +316,14 @@ on_stream_format_changed(void *_data, const struct spa_pod *format)
|
|||
CURSOR_META_SIZE(256,256)));
|
||||
|
||||
/* we are done */
|
||||
pw_stream_finish_format(stream, 0, params, 4);
|
||||
pw_stream_update_params(stream, params, 4);
|
||||
}
|
||||
|
||||
/* these are the stream events we listen for */
|
||||
static const struct pw_stream_events stream_events = {
|
||||
PW_VERSION_STREAM_EVENTS,
|
||||
.state_changed = on_stream_state_changed,
|
||||
.format_changed = on_stream_format_changed,
|
||||
.param_changed = on_stream_param_changed,
|
||||
.process = on_process,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ static void on_stream_state_changed(void *_data, enum pw_stream_state old, enum
|
|||
printf("stream state: \"%s\"\n", pw_stream_state_as_string(state));
|
||||
|
||||
switch (state) {
|
||||
case PW_STREAM_STATE_CONFIGURE:
|
||||
case PW_STREAM_STATE_PAUSED:
|
||||
printf("node id: %d\n", pw_stream_get_node_id(data->stream));
|
||||
break;
|
||||
case PW_STREAM_STATE_STREAMING:
|
||||
|
|
@ -271,18 +271,19 @@ static void on_stream_remove_buffer(void *_data, struct pw_buffer *buffer)
|
|||
close(d[0].fd);
|
||||
}
|
||||
|
||||
/* Be notified when the stream format changes.
|
||||
/* Be notified when the stream param changes. We're only looking at the
|
||||
* format param.
|
||||
*
|
||||
* We are now supposed to call pw_stream_finish_format() with success or
|
||||
* We are now supposed to call pw_stream_update_params() with success or
|
||||
* failure, depending on if we can support the format. Because we gave
|
||||
* a list of supported formats, this should be ok.
|
||||
*
|
||||
* As part of pw_stream_finish_format() we can provide parameters that
|
||||
* As part of pw_stream_update_params() we can provide parameters that
|
||||
* will control the buffer memory allocation. This includes the metadata
|
||||
* that we would like on our buffer, the size, alignment, etc.
|
||||
*/
|
||||
static void
|
||||
on_stream_format_changed(void *_data, const struct spa_pod *format)
|
||||
on_stream_param_changed(void *_data, uint32_t id, const struct spa_pod *param)
|
||||
{
|
||||
struct data *data = _data;
|
||||
struct pw_stream *stream = data->stream;
|
||||
|
|
@ -290,11 +291,10 @@ on_stream_format_changed(void *_data, const struct spa_pod *format)
|
|||
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(params_buffer, sizeof(params_buffer));
|
||||
const struct spa_pod *params[5];
|
||||
|
||||
if (format == NULL) {
|
||||
pw_stream_finish_format(stream, 0, NULL, 0);
|
||||
if (param == NULL || id != SPA_PARAM_Format)
|
||||
return;
|
||||
}
|
||||
spa_format_video_raw_parse(format, &data->format);
|
||||
|
||||
spa_format_video_raw_parse(param, &data->format);
|
||||
|
||||
data->stride = SPA_ROUND_UP_N(data->format.size.width * BPP, 4);
|
||||
|
||||
|
|
@ -330,13 +330,13 @@ on_stream_format_changed(void *_data, const struct spa_pod *format)
|
|||
SPA_PARAM_META_size, SPA_POD_Int(
|
||||
CURSOR_META_SIZE(CURSOR_WIDTH,CURSOR_HEIGHT)));
|
||||
|
||||
pw_stream_finish_format(stream, 0, params, 5);
|
||||
pw_stream_update_params(stream, params, 5);
|
||||
}
|
||||
|
||||
static const struct pw_stream_events stream_events = {
|
||||
PW_VERSION_STREAM_EVENTS,
|
||||
.state_changed = on_stream_state_changed,
|
||||
.format_changed = on_stream_format_changed,
|
||||
.param_changed = on_stream_param_changed,
|
||||
.add_buffer = on_stream_add_buffer,
|
||||
.remove_buffer = on_stream_remove_buffer,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ static void on_stream_state_changed(void *_data, enum pw_stream_state old, enum
|
|||
printf("stream state: \"%s\"\n", pw_stream_state_as_string(state));
|
||||
|
||||
switch (state) {
|
||||
case PW_STREAM_STATE_CONFIGURE:
|
||||
case PW_STREAM_STATE_PAUSED:
|
||||
printf("node id: %d\n", pw_stream_get_node_id(data->stream));
|
||||
break;
|
||||
case PW_STREAM_STATE_STREAMING:
|
||||
|
|
@ -210,7 +210,7 @@ static void on_stream_state_changed(void *_data, enum pw_stream_state old, enum
|
|||
}
|
||||
|
||||
static void
|
||||
on_stream_format_changed(void *_data, const struct spa_pod *format)
|
||||
on_stream_param_changed(void *_data, uint32_t id, const struct spa_pod *param)
|
||||
{
|
||||
struct data *data = _data;
|
||||
struct pw_stream *stream = data->stream;
|
||||
|
|
@ -218,11 +218,10 @@ on_stream_format_changed(void *_data, const struct spa_pod *format)
|
|||
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(params_buffer, sizeof(params_buffer));
|
||||
const struct spa_pod *params[5];
|
||||
|
||||
if (format == NULL) {
|
||||
pw_stream_finish_format(stream, 0, NULL, 0);
|
||||
if (param == NULL || id != SPA_PARAM_Format)
|
||||
return;
|
||||
}
|
||||
spa_format_video_raw_parse(format, &data->format);
|
||||
|
||||
spa_format_video_raw_parse(param, &data->format);
|
||||
|
||||
data->stride = SPA_ROUND_UP_N(data->format.size.width * BPP, 4);
|
||||
|
||||
|
|
@ -258,13 +257,13 @@ on_stream_format_changed(void *_data, const struct spa_pod *format)
|
|||
SPA_PARAM_META_size, SPA_POD_Int(
|
||||
CURSOR_META_SIZE(CURSOR_WIDTH,CURSOR_HEIGHT)));
|
||||
|
||||
pw_stream_finish_format(stream, 0, params, 5);
|
||||
pw_stream_update_params(stream, params, 5);
|
||||
}
|
||||
|
||||
static const struct pw_stream_events stream_events = {
|
||||
PW_VERSION_STREAM_EVENTS,
|
||||
.state_changed = on_stream_state_changed,
|
||||
.format_changed = on_stream_format_changed,
|
||||
.param_changed = on_stream_param_changed,
|
||||
};
|
||||
|
||||
static void on_state_changed(void *_data, enum pw_remote_state old, enum pw_remote_state state, const char *error)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue