alsa: fix capture

This commit is contained in:
Wim Taymans 2018-04-26 17:22:17 +02:00
parent 7f6ac1162d
commit 60d74d442f
2 changed files with 19 additions and 6 deletions

View file

@ -598,6 +598,7 @@ static int impl_node_process(struct spa_node *node)
{
struct state *this;
struct spa_io_buffers *io;
struct buffer *b;
spa_return_val_if_fail(node != NULL, -EINVAL);
@ -612,11 +613,24 @@ static int impl_node_process(struct spa_node *node)
recycle_buffer(this, io->buffer_id);
io->buffer_id = SPA_ID_INVALID;
}
return 0;
if (spa_list_is_empty(&this->ready))
return -EPIPE;
b = spa_list_first(&this->ready, struct buffer, link);
spa_list_remove(&b->link);
spa_log_trace(this->log, NAME " %p: dequeue buffer %d", node, b->outbuf->id);
io->buffer_id = b->outbuf->id;
io->status = SPA_STATUS_HAVE_BUFFER;
return SPA_STATUS_HAVE_BUFFER;
}
static const struct spa_dict_item node_info_items[] = {
{ "media.class", "Audio/Source" },
{ "node.driver", "true" },
};
static const struct spa_dict node_info = {

View file

@ -470,7 +470,6 @@ push_frames(struct state *state,
snd_pcm_uframes_t frames)
{
snd_pcm_uframes_t total_frames = 0;
struct spa_io_buffers *io = state->io;
if (spa_list_is_empty(&state->free)) {
spa_log_trace(state->log, "no more buffers");
@ -503,17 +502,17 @@ push_frames(struct state *state,
l0 = SPA_MIN(n_bytes, d[0].maxsize - offs);
l1 = n_bytes - l0;
memcpy(src, d[0].data + offs, l0);
memcpy(d[0].data + offs, src, l0);
if (l1 > 0)
memcpy(src + l0, d[0].data, l1);
memcpy(d[0].data, src + l0, l1);
d[0].chunk->offset = index;
d[0].chunk->size = n_bytes;
d[0].chunk->stride = state->frame_size;
SPA_FLAG_SET(b->flags, BUFFER_FLAG_OUT);
io->buffer_id = b->outbuf->id;
io->status = SPA_STATUS_HAVE_BUFFER;
spa_list_append(&state->ready, &b->link);
state->callbacks->process(state->callbacks_data, SPA_STATUS_HAVE_BUFFER);
}
return total_frames;