Add audiotestsrc

Work on idle poll
Move node state to the node interface so that we can actually get it in
the sync case.
Add enabled field to the poll event
Work on audiotestsrc
This commit is contained in:
Wim Taymans 2016-09-05 16:23:40 +02:00
parent 52e45cf2a1
commit 7aa79a2a0d
24 changed files with 721 additions and 100 deletions

View file

@ -120,7 +120,6 @@ typedef struct {
struct _SpaV4l2Source {
SpaHandle handle;
SpaNode node;
SpaNodeState node_state;
SpaV4l2SourceProps props[2];
@ -208,10 +207,10 @@ update_state (SpaV4l2Source *this, SpaNodeState state)
SpaEvent event;
SpaEventStateChange sc;
if (this->node_state == state)
if (this->node.state == state)
return;
this->node_state = state;
this->node.state = state;
event.type = SPA_EVENT_TYPE_STATE_CHANGE;
event.data = ≻
@ -329,7 +328,7 @@ spa_v4l2_source_node_get_port_ids (SpaNode *node,
if (node == NULL || node->handle == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
if (n_output_ports > 0)
if (n_output_ports > 0 && output_ids != NULL)
output_ids[0] = 0;
return SPA_RESULT_OK;
@ -718,6 +717,7 @@ spa_v4l2_source_node_port_push_event (SpaNode *node,
static const SpaNode v4l2source_node = {
NULL,
sizeof (SpaNode),
SPA_NODE_STATE_INIT,
spa_v4l2_source_node_get_props,
spa_v4l2_source_node_set_props,
spa_v4l2_source_node_send_command,
@ -793,8 +793,6 @@ v4l2_source_init (const SpaHandleFactory *factory,
this->state[0].export_buf = true;
this->node_state = SPA_NODE_STATE_INIT;
return SPA_RESULT_OK;
}

View file

@ -625,9 +625,9 @@ spa_v4l2_use_buffers (SpaV4l2Source *this, SpaBuffer **buffers, uint32_t n_buffe
if (state->alloc_mem)
spa_memory_unref (&state->alloc_mem->mem);
state->alloc_mem = spa_memory_alloc_with_fd (SPA_MEMORY_POOL_SHARED,
NULL,
sizeof (V4l2Buffer) * reqbuf.count);
state->alloc_mem = spa_memory_alloc_size (SPA_MEMORY_POOL_LOCAL,
NULL,
sizeof (V4l2Buffer) * reqbuf.count);
state->alloc_buffers = spa_memory_ensure_ptr (state->alloc_mem);
for (i = 0; i < reqbuf.count; i++) {
@ -646,7 +646,7 @@ spa_v4l2_use_buffers (SpaV4l2Source *this, SpaBuffer **buffers, uint32_t n_buffe
fprintf (stderr, "import buffer %p\n", buffers[i]);
mem_ref = &SPA_BUFFER_DATAS (buffers[i])[0].mem.mem;
mem_ref = &d[0].mem.mem;
if (!(mem = spa_memory_find (mem_ref))) {
fprintf (stderr, "invalid memory on buffer %p\n", buffers[i]);
continue;
@ -656,7 +656,7 @@ spa_v4l2_use_buffers (SpaV4l2Source *this, SpaBuffer **buffers, uint32_t n_buffe
b->v4l2_buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
b->v4l2_buffer.memory = state->memtype;
b->v4l2_buffer.index = i;
b->v4l2_buffer.m.userptr = (unsigned long) ((uint8_t*)mem->ptr + d[0].mem.offset);
b->v4l2_buffer.m.userptr = (unsigned long) SPA_MEMBER (mem->ptr, d[0].mem.offset, void *);
b->v4l2_buffer.length = d[0].mem.size;
spa_v4l2_buffer_recycle (this, buffers[i]->id);
@ -869,6 +869,7 @@ spa_v4l2_start (SpaV4l2Source *this)
state->fds[0].revents = 0;
state->poll.id = 0;
state->poll.enabled = true;
state->poll.fds = state->fds;
state->poll.n_fds = 1;
state->poll.idle_cb = NULL;