Improve upload

Only send a buffer when we have received a NEED_DATA message.
Add a signal to pulla buffer from the sink. Restructure the sink to use
a queue like the source and only push a buffer when we can.
Improve SpaData. Offset and size should be between 0 and maxsize, make
sure we clamp correctly when needed.
node_process_output completes the processing of the output after
receiving HAVE_OUTPUT for async elements. It instructs the node that
it now can produce more output.
This commit is contained in:
Wim Taymans 2016-12-20 16:51:57 +01:00
parent 8ce3f949e2
commit 5b0b9c43d0
18 changed files with 201 additions and 112 deletions

View file

@ -173,13 +173,19 @@ clock_disabled:
}
}
static void
clear_queue (GstPinosSrc *pinossrc)
{
g_queue_foreach (&pinossrc->queue, (GFunc) gst_mini_object_unref, NULL);
g_queue_clear (&pinossrc->queue);
}
static void
gst_pinos_src_finalize (GObject * object)
{
GstPinosSrc *pinossrc = GST_PINOS_SRC (object);
g_queue_foreach (&pinossrc->queue, (GFunc) gst_mini_object_unref, NULL);
g_queue_clear (&pinossrc->queue);
clear_queue (pinossrc);
pinos_thread_main_loop_destroy (pinossrc->main_loop);
pinossrc->main_loop = NULL;
@ -340,6 +346,7 @@ typedef struct {
SpaBuffer *buf;
SpaMetaHeader *header;
guint flags;
goffset offset;
} ProcessMemData;
static void
@ -417,13 +424,15 @@ on_add_buffer (PinosListener *listener,
case SPA_DATA_TYPE_DMABUF:
{
gmem = gst_fd_allocator_alloc (pinossrc->fd_allocator, dup (d->fd),
d->size, GST_FD_MEMORY_FLAG_NONE);
gst_memory_resize (gmem, d->chunk->offset, d->chunk->size);
d->maxsize, GST_FD_MEMORY_FLAG_NONE);
gst_memory_resize (gmem, d->chunk->offset + d->mapoffset, d->chunk->size);
data.offset = d->mapoffset;
break;
}
case SPA_DATA_TYPE_MEMPTR:
gmem = gst_memory_new_wrapped (0, d->data, d->size, d->chunk->offset,
gmem = gst_memory_new_wrapped (0, d->data, d->maxsize, d->chunk->offset + d->mapoffset,
d->chunk->size, NULL, NULL);
data.offset = 0;
default:
break;
}
@ -488,7 +497,7 @@ on_new_buffer (PinosListener *listener,
for (i = 0; i < data->buf->n_datas; i++) {
SpaData *d = &data->buf->datas[i];
GstMemory *mem = gst_buffer_peek_memory (buf, i);
mem->offset = d->chunk->offset;
mem->offset = d->chunk->offset + data->offset;
mem->size = d->chunk->size;
}
g_queue_push_tail (&pinossrc->queue, buf);
@ -937,13 +946,6 @@ gst_pinos_src_start (GstBaseSrc * basesrc)
return TRUE;
}
static void
clear_queue (GstPinosSrc *pinossrc)
{
g_queue_foreach (&pinossrc->queue, (GFunc) gst_mini_object_unref, NULL);
g_queue_clear (&pinossrc->queue);
}
static gboolean
gst_pinos_src_stop (GstBaseSrc * basesrc)
{