mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-16 08:56:45 -05:00
Remove port
Remove the port object. We don't use it as a dbus object and we don't need it, we can use the link and node object directy. Move poll code and event handler to the node.
This commit is contained in:
parent
463954a299
commit
7d3e46e7f9
22 changed files with 689 additions and 1848 deletions
|
|
@ -958,6 +958,10 @@ write_format (void *p, const SpaFormat *format)
|
|||
tf = p;
|
||||
tf->media_type = format->media_type;
|
||||
tf->media_subtype = format->media_subtype;
|
||||
tf->mem.mem.pool_id = SPA_ID_INVALID;
|
||||
tf->mem.mem.id = SPA_ID_INVALID;
|
||||
tf->mem.offset = 0;
|
||||
tf->mem.size = 0;
|
||||
|
||||
p = SPA_MEMBER (tf, offsetof (SpaFormat, props), void);
|
||||
return write_props (p, &format->props, sizeof (SpaFormat));
|
||||
|
|
@ -971,6 +975,9 @@ write_port_info (void *p, const SpaPortInfo *info)
|
|||
int i;
|
||||
size_t len;
|
||||
|
||||
if (info == NULL)
|
||||
return 0;
|
||||
|
||||
tp = p;
|
||||
memcpy (tp, info, sizeof (SpaPortInfo));
|
||||
|
||||
|
|
@ -1086,8 +1093,11 @@ builder_add_set_format (struct stack_builder *sb, SpaControlCmdSetFormat *sf)
|
|||
sf = p;
|
||||
|
||||
p = SPA_MEMBER (sf, sizeof (SpaControlCmdSetFormat), void);
|
||||
len = write_format (p, sf->format);
|
||||
sf->format = SPA_INT_TO_PTR (SPA_PTRDIFF (p, sf));
|
||||
if (sf->format) {
|
||||
len = write_format (p, sf->format);
|
||||
sf->format = SPA_INT_TO_PTR (SPA_PTRDIFF (p, sf));
|
||||
} else
|
||||
sf->format = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -159,6 +159,8 @@ spa_debug_dump_mem (const void *mem, size_t size)
|
|||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
if (i % 16 == 0)
|
||||
printf ("%p: ", &t[i]);
|
||||
printf ("%02x ", t[i]);
|
||||
if (i % 16 == 15 || i == size - 1)
|
||||
printf ("\n");
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@ do_update_port (SpaProxy *this,
|
|||
}
|
||||
|
||||
if (!port->valid) {
|
||||
fprintf (stderr, "%p: adding port %d\n", this, pu->port_id);
|
||||
fprintf (stderr, "proxy %p: adding port %d\n", this, pu->port_id);
|
||||
port->format = NULL;
|
||||
port->valid = true;
|
||||
|
||||
|
|
@ -381,7 +381,7 @@ do_uninit_port (SpaProxy *this,
|
|||
SpaProxyPort *port;
|
||||
SpaEventPortRemoved pr;
|
||||
|
||||
fprintf (stderr, "%p: removing port %d\n", this, port_id);
|
||||
fprintf (stderr, "proxy %p: removing port %d\n", this, port_id);
|
||||
port = &this->ports[port_id];
|
||||
|
||||
if (port_id < MAX_INPUTS)
|
||||
|
|
@ -784,6 +784,7 @@ spa_proxy_node_port_push_input (SpaNode *node,
|
|||
|
||||
for (i = 0; i < n_info; i++) {
|
||||
if (!CHECK_PORT_ID_IN (this, info[i].port_id)) {
|
||||
printf ("invalid port %d\n", info[i].port_id);
|
||||
info[i].status = SPA_RESULT_INVALID_PORT;
|
||||
have_error = true;
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ struct _V4l2Format {
|
|||
typedef struct {
|
||||
bool export_buf;
|
||||
bool have_buffers;
|
||||
bool started;
|
||||
|
||||
bool next_fmtdesc;
|
||||
struct v4l2_fmtdesc fmtdesc;
|
||||
|
|
@ -381,8 +382,6 @@ spa_v4l2_source_node_port_enum_formats (SpaNode *node,
|
|||
|
||||
this = (SpaV4l2Source *) node->handle;
|
||||
|
||||
fprintf (stderr, "%d\n", port_id);
|
||||
|
||||
if (port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
|
|
@ -414,6 +413,7 @@ spa_v4l2_source_node_port_set_format (SpaNode *node,
|
|||
state = &this->state[port_id];
|
||||
|
||||
if (format == NULL) {
|
||||
spa_v4l2_pause (this);
|
||||
spa_v4l2_clear_buffers (this);
|
||||
spa_v4l2_close (this);
|
||||
state->current_format = NULL;
|
||||
|
|
|
|||
|
|
@ -402,6 +402,7 @@ again:
|
|||
fmt->fmt.props.prop_info = fmt->infos;
|
||||
fmt->fmt.props.n_prop_info = pi = 0;
|
||||
fmt->fmt.props.unset_mask = 0;
|
||||
fmt->fmt.mem.mem.pool_id = SPA_ID_INVALID;
|
||||
|
||||
if (info->media_subtype == SPA_MEDIA_SUBTYPE_RAW) {
|
||||
spa_prop_info_fill_video (&fmt->infos[pi],
|
||||
|
|
@ -850,6 +851,9 @@ spa_v4l2_start (SpaV4l2Source *this)
|
|||
enum v4l2_buf_type type;
|
||||
SpaEvent event;
|
||||
|
||||
if (state->started)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
if (xioctl (state->fd, VIDIOC_STREAMON, &type) < 0) {
|
||||
perror ("VIDIOC_STREAMON");
|
||||
|
|
@ -873,6 +877,8 @@ spa_v4l2_start (SpaV4l2Source *this)
|
|||
state->poll.user_data = this;
|
||||
this->event_cb (&this->node, &event, this->user_data);
|
||||
|
||||
state->started = true;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -883,11 +889,16 @@ spa_v4l2_pause (SpaV4l2Source *this)
|
|||
enum v4l2_buf_type type;
|
||||
SpaEvent event;
|
||||
|
||||
if (!state->started)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_REMOVE_POLL;
|
||||
event.data = &state->poll;
|
||||
event.size = sizeof (state->poll);
|
||||
this->event_cb (&this->node, &event, this->user_data);
|
||||
|
||||
state->started = false;
|
||||
|
||||
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
if (xioctl (state->fd, VIDIOC_STREAMOFF, &type) < 0) {
|
||||
perror ("VIDIOC_STREAMOFF");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue