mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
audiotestsrc: add live mode
Add a live mode to audiotestsrc by using a timerfd to push output. Make a queue helper and use in alsa Add live port flag
This commit is contained in:
parent
fc7b4a9009
commit
1e565a5f65
5 changed files with 235 additions and 59 deletions
|
|
@ -315,7 +315,7 @@ spa_alsa_sink_node_port_set_format (SpaNode *node,
|
|||
SpaALSASink *this;
|
||||
SpaResult res;
|
||||
|
||||
if (node == NULL || node->handle == NULL || format == NULL)
|
||||
if (node == NULL || node->handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = (SpaALSASink *) node->handle;
|
||||
|
|
@ -325,6 +325,7 @@ spa_alsa_sink_node_port_set_format (SpaNode *node,
|
|||
|
||||
if (format == NULL) {
|
||||
this->have_format = false;
|
||||
this->have_buffers = false;
|
||||
update_state (this, SPA_NODE_STATE_CONFIGURE);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -501,6 +502,7 @@ spa_alsa_sink_node_port_alloc_buffers (SpaNode *node,
|
|||
buffers[i] = &b->buffer;
|
||||
}
|
||||
*n_buffers = n_bufs;
|
||||
this->have_buffers = true;
|
||||
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
|
||||
|
|
@ -563,13 +565,12 @@ spa_alsa_sink_node_port_push_input (SpaNode *node,
|
|||
continue;
|
||||
}
|
||||
|
||||
if (this->ready_head != NULL) {
|
||||
if (this->ready.length != 0) {
|
||||
info[i].status = SPA_RESULT_HAVE_ENOUGH_INPUT;
|
||||
have_enough = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
this->ready_head = &this->alloc_buffers[info[i].buffer_id];
|
||||
SPA_QUEUE_PUSH_TAIL (&this->ready, SpaALSABuffer, &this->alloc_buffers[info[i].buffer_id]);
|
||||
}
|
||||
info[i].status = SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -301,13 +301,10 @@ mmap_read (SpaALSAState *state)
|
|||
snd_pcm_status_get_htstamp (status, &htstamp);
|
||||
now = (int64_t)htstamp.tv_sec * 1000000000ll + (int64_t)htstamp.tv_nsec;
|
||||
|
||||
b = state->free_head;
|
||||
if (b == NULL)
|
||||
SPA_QUEUE_POP_HEAD (&state->free, SpaALSABuffer, b);
|
||||
if (b == NULL) {
|
||||
fprintf (stderr, "no more buffers\n");
|
||||
else {
|
||||
state->free_head = b->next;
|
||||
if (state->free_head == NULL)
|
||||
state->free_tail = NULL;
|
||||
} else {
|
||||
b->next = NULL;
|
||||
dest = b->ptr;
|
||||
}
|
||||
|
|
@ -349,12 +346,7 @@ mmap_read (SpaALSAState *state)
|
|||
d = SPA_BUFFER_DATAS (b->outbuf);
|
||||
d[0].mem.size = avail * state->frame_size;
|
||||
|
||||
if (state->ready_tail)
|
||||
state->ready_tail->next = b;
|
||||
state->ready_tail = b;
|
||||
if (state->ready_head == NULL)
|
||||
state->ready_head = b;
|
||||
state->ready_count++;
|
||||
SPA_QUEUE_PUSH_TAIL (&state->ready, SpaALSABuffer, b);
|
||||
|
||||
event.type = SPA_NODE_EVENT_TYPE_HAVE_OUTPUT;
|
||||
event.size = sizeof (ho);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue