mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
Remove SpaQueue, use SpaList instead
This commit is contained in:
parent
89bc235924
commit
d0f95fc323
20 changed files with 153 additions and 237 deletions
85
spa/include/spa/list.h
Normal file
85
spa/include/spa/list.h
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/* Simple Plugin API
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __SPA_LIST_H__
|
||||
#define __SPA_LIST_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _SpaList SpaList;
|
||||
|
||||
#include <spa/defs.h>
|
||||
|
||||
struct _SpaList {
|
||||
SpaList *next;
|
||||
SpaList *prev;
|
||||
};
|
||||
|
||||
static inline void
|
||||
spa_list_init (SpaList *list)
|
||||
{
|
||||
list->next = list;
|
||||
list->prev = list;
|
||||
}
|
||||
|
||||
static inline void
|
||||
spa_list_insert (SpaList *list,
|
||||
SpaList *elem)
|
||||
{
|
||||
elem->prev = list;
|
||||
elem->next = list->next;
|
||||
list->next = elem;
|
||||
elem->next->prev = elem;
|
||||
}
|
||||
|
||||
static inline void
|
||||
spa_list_remove (SpaList *elem)
|
||||
{
|
||||
elem->prev->next = elem->next;
|
||||
elem->next->prev = elem->prev;
|
||||
}
|
||||
|
||||
#define spa_list_is_empty(l) ((l)->next == (l))
|
||||
|
||||
#define spa_list_first(head, type, member) \
|
||||
SPA_CONTAINER_OF((head)->next, type, member)
|
||||
|
||||
#define spa_list_last(item, type, member) \
|
||||
SPA_CONTAINER_OF((head)->prev, type, member)
|
||||
|
||||
#define spa_list_for_each(pos, head, member) \
|
||||
for (pos = SPA_CONTAINER_OF((head)->next, __typeof__(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
pos = SPA_CONTAINER_OF(pos->member.next, __typeof__(*pos), member))
|
||||
|
||||
#define spa_list_for_each_safe(pos, tmp, head, member) \
|
||||
for (pos = SPA_CONTAINER_OF((head)->next, __typeof__(*pos), member), \
|
||||
tmp = SPA_CONTAINER_OF((pos)->member.next, __typeof__(*tmp), member); \
|
||||
&pos->member != (head); \
|
||||
pos = tmp, \
|
||||
tmp = SPA_CONTAINER_OF(pos->member.next, __typeof__(*tmp), member))
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* __SPA_LIST_H__ */
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
/* Simple Plugin API
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __SPA_QUEUE_H__
|
||||
#define __SPA_QUEUE_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _SpaQueue SpaQueue;
|
||||
|
||||
#define SPA_QUEUE_URI "http://spaplug.in/ns/queue"
|
||||
#define SPA_QUEUE_PREFIX SPA_QUEUE_URI "#"
|
||||
|
||||
#include <spa/defs.h>
|
||||
|
||||
struct _SpaQueue {
|
||||
void *head, *tail;
|
||||
unsigned int length;
|
||||
};
|
||||
|
||||
#define SPA_QUEUE_INIT(q) \
|
||||
do { \
|
||||
(q)->head = (q)->tail = NULL; \
|
||||
(q)->length = 0; \
|
||||
} while (0);
|
||||
|
||||
#define SPA_QUEUE_PUSH_TAIL(q,t,next,i) \
|
||||
do { \
|
||||
if ((q)->tail) \
|
||||
((t*)(q)->tail)->next = (i); \
|
||||
(q)->tail = (i); \
|
||||
if ((q)->head == NULL) \
|
||||
(q)->head = (i); \
|
||||
(q)->length++; \
|
||||
} while (0);
|
||||
|
||||
#define SPA_QUEUE_PEEK_HEAD(q,t,i) \
|
||||
((i) = (t*)((q)->head));
|
||||
|
||||
#define SPA_QUEUE_POP_HEAD(q,t,next,i) \
|
||||
do { \
|
||||
if (((i) = (t*)((q)->head)) == NULL) \
|
||||
break; \
|
||||
(q)->head = (i)->next; \
|
||||
if ((q)->head == NULL) \
|
||||
(q)->tail = NULL; \
|
||||
(q)->length--; \
|
||||
} while (0);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* __SPA_QUEUE_H__ */
|
||||
|
|
@ -23,19 +23,6 @@
|
|||
#include <string.h>
|
||||
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/buffer.h>
|
||||
#include <spa/clock.h>
|
||||
#include <spa/format.h>
|
||||
#include <spa/monitor.h>
|
||||
#include <spa/node.h>
|
||||
#include <spa/node-command.h>
|
||||
#include <spa/node-event.h>
|
||||
#include <spa/poll.h>
|
||||
#include <spa/port.h>
|
||||
#include <spa/props.h>
|
||||
#include <spa/queue.h>
|
||||
#include <spa/ringbuffer.h>
|
||||
|
||||
#include <lib/debug.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ typedef struct _SpaALSAState SpaALSASink;
|
|||
|
||||
static const char default_device[] = "default";
|
||||
static const uint32_t default_buffer_time = 4000;
|
||||
static const uint32_t default_period_time = 1000;
|
||||
static const uint32_t default_period_time = 500;
|
||||
static const bool default_period_event = 0;
|
||||
|
||||
static void
|
||||
|
|
@ -366,7 +366,7 @@ static SpaResult
|
|||
spa_alsa_clear_buffers (SpaALSASink *this)
|
||||
{
|
||||
if (this->n_buffers > 0) {
|
||||
SPA_QUEUE_INIT (&this->ready);
|
||||
spa_list_init (&this->ready);
|
||||
this->n_buffers = 0;
|
||||
this->ringbuffer = NULL;
|
||||
}
|
||||
|
|
@ -698,8 +698,7 @@ spa_alsa_sink_node_process_input (SpaNode *node)
|
|||
this->ringbuffer->outstanding = true;
|
||||
this->ringbuffer = b;
|
||||
} else {
|
||||
b->next = NULL;
|
||||
SPA_QUEUE_PUSH_TAIL (&this->ready, SpaALSABuffer, next, b);
|
||||
spa_list_insert (this->ready.prev, &b->list);
|
||||
}
|
||||
b->outstanding = false;
|
||||
input->status = SPA_RESULT_OK;
|
||||
|
|
@ -808,6 +807,8 @@ alsa_sink_init (const SpaHandleFactory *factory,
|
|||
this->stream = SND_PCM_STREAM_PLAYBACK;
|
||||
reset_alsa_sink_props (&this->props[1]);
|
||||
|
||||
spa_list_init (&this->ready);
|
||||
|
||||
for (i = 0; info && i < info->n_items; i++) {
|
||||
if (!strcmp (info->items[i].key, "alsa.card")) {
|
||||
snprintf (this->props[1].device, 63, "hw:%s", info->items[i].value);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#include <asoundlib.h>
|
||||
|
||||
#include <spa/node.h>
|
||||
#include <spa/queue.h>
|
||||
#include <spa/list.h>
|
||||
#include <spa/audio/format.h>
|
||||
#include <lib/props.h>
|
||||
|
||||
|
|
@ -408,16 +408,15 @@ recycle_buffer (SpaALSASource *this, uint32_t buffer_id)
|
|||
return;
|
||||
|
||||
b->outstanding = false;
|
||||
b->next = NULL;
|
||||
SPA_QUEUE_PUSH_TAIL (&this->free, SpaALSABuffer, next, b);
|
||||
spa_list_insert (this->free.prev, &b->list);
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_clear_buffers (SpaALSASource *this)
|
||||
{
|
||||
if (this->n_buffers > 0) {
|
||||
SPA_QUEUE_INIT (&this->free);
|
||||
SPA_QUEUE_INIT (&this->ready);
|
||||
spa_list_init (&this->free);
|
||||
spa_list_init (&this->ready);
|
||||
this->n_buffers = 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -591,8 +590,7 @@ spa_alsa_source_node_port_use_buffers (SpaNode *node,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
b->next = NULL;
|
||||
SPA_QUEUE_PUSH_TAIL (&this->free, SpaALSABuffer, next, b);
|
||||
spa_list_insert (this->free.prev, &b->list);
|
||||
}
|
||||
this->n_buffers = n_buffers;
|
||||
|
||||
|
|
@ -749,11 +747,12 @@ spa_alsa_source_node_process_output (SpaNode *node)
|
|||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
|
||||
SPA_QUEUE_POP_HEAD (&this->ready, SpaALSABuffer, next, b);
|
||||
if (b == NULL) {
|
||||
if (spa_list_is_empty (&this->ready)) {
|
||||
output->status = SPA_RESULT_UNEXPECTED;
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
b = spa_list_first (&this->ready, SpaALSABuffer, list);
|
||||
spa_list_remove (&b->list);
|
||||
b->outstanding = true;
|
||||
|
||||
output->buffer_id = b->outbuf->id;
|
||||
|
|
|
|||
|
|
@ -280,13 +280,12 @@ pull_frames_queue (SpaALSAState *state,
|
|||
snd_pcm_uframes_t offset,
|
||||
snd_pcm_uframes_t frames)
|
||||
{
|
||||
SpaALSABuffer *b;
|
||||
|
||||
SPA_QUEUE_PEEK_HEAD (&state->ready, SpaALSABuffer, b);
|
||||
|
||||
if (b) {
|
||||
if (!spa_list_is_empty (&state->ready)) {
|
||||
uint8_t *src, *dst;
|
||||
size_t n_bytes;
|
||||
SpaALSABuffer *b;
|
||||
|
||||
b = spa_list_first (&state->ready, SpaALSABuffer, list);
|
||||
|
||||
src = SPA_MEMBER (b->outbuf->datas[0].data, b->outbuf->datas[0].offset + state->ready_offset, uint8_t);
|
||||
dst = SPA_MEMBER (my_areas[0].addr, offset * state->frame_size, uint8_t);
|
||||
|
|
@ -299,7 +298,7 @@ pull_frames_queue (SpaALSAState *state,
|
|||
if (state->ready_offset >= b->outbuf->datas[0].size) {
|
||||
SpaNodeEventReuseBuffer rb;
|
||||
|
||||
SPA_QUEUE_POP_HEAD (&state->ready, SpaALSABuffer, next, b);
|
||||
spa_list_remove (&b->list);
|
||||
b->outstanding = true;
|
||||
|
||||
rb.event.type = SPA_NODE_EVENT_TYPE_REUSE_BUFFER;
|
||||
|
|
@ -448,10 +447,13 @@ mmap_read (SpaALSAState *state)
|
|||
state->last_ticks = state->sample_count * SPA_USEC_PER_SEC / state->rate;
|
||||
state->last_monotonic = now;
|
||||
|
||||
SPA_QUEUE_POP_HEAD (&state->free, SpaALSABuffer, next, b);
|
||||
if (b == NULL) {
|
||||
if (spa_list_is_empty (&state->free)) {
|
||||
b = NULL;
|
||||
spa_log_warn (state->log, "no more buffers");
|
||||
} else {
|
||||
b = spa_list_first (&state->free, SpaALSABuffer, list);
|
||||
spa_list_remove (&b->list);
|
||||
|
||||
dest = SPA_MEMBER (b->outbuf->datas[0].data, b->outbuf->datas[0].offset, void);
|
||||
destsize = b->outbuf->datas[0].size;
|
||||
|
||||
|
|
@ -496,8 +498,7 @@ mmap_read (SpaALSAState *state)
|
|||
d = b->outbuf->datas;
|
||||
d[0].size = avail * state->frame_size;
|
||||
|
||||
b->next = NULL;
|
||||
SPA_QUEUE_PUSH_TAIL (&state->ready, SpaALSABuffer, next, b);
|
||||
spa_list_insert (state->ready.prev, &b->list);
|
||||
|
||||
ho.event.type = SPA_NODE_EVENT_TYPE_HAVE_OUTPUT;
|
||||
ho.event.size = sizeof (ho);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ extern "C" {
|
|||
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/queue.h>
|
||||
#include <spa/list.h>
|
||||
#include <spa/node.h>
|
||||
#include <spa/ringbuffer.h>
|
||||
#include <spa/audio/format.h>
|
||||
|
|
@ -55,7 +55,7 @@ struct _SpaALSABuffer {
|
|||
SpaMetaHeader *h;
|
||||
SpaMetaRingbuffer *rb;
|
||||
bool outstanding;
|
||||
SpaALSABuffer *next;
|
||||
SpaList list;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -109,8 +109,8 @@ struct _SpaALSAState {
|
|||
bool use_ringbuffer;
|
||||
SpaALSABuffer *ringbuffer;
|
||||
|
||||
SpaQueue free;
|
||||
SpaQueue ready;
|
||||
SpaList free;
|
||||
SpaList ready;
|
||||
size_t ready_offset;
|
||||
|
||||
bool started;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#include <spa/id-map.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/node.h>
|
||||
#include <spa/queue.h>
|
||||
#include <spa/list.h>
|
||||
#include <spa/audio/format.h>
|
||||
#include <lib/props.h>
|
||||
|
||||
|
|
@ -52,10 +52,10 @@ typedef struct _ATSBuffer ATSBuffer;
|
|||
struct _ATSBuffer {
|
||||
SpaBuffer *outbuf;
|
||||
bool outstanding;
|
||||
ATSBuffer *next;
|
||||
SpaMetaHeader *h;
|
||||
void *ptr;
|
||||
size_t size;
|
||||
SpaList list;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -102,8 +102,8 @@ struct _SpaAudioTestSrc {
|
|||
uint64_t elapsed_time;
|
||||
|
||||
uint64_t sample_count;
|
||||
SpaQueue empty;
|
||||
SpaQueue ready;
|
||||
SpaList empty;
|
||||
SpaList ready;
|
||||
};
|
||||
|
||||
#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) == 0)
|
||||
|
|
@ -266,12 +266,13 @@ audiotestsrc_on_output (SpaPollNotifyData *data)
|
|||
SpaAudioTestSrc *this = data->user_data;
|
||||
ATSBuffer *b;
|
||||
|
||||
SPA_QUEUE_POP_HEAD (&this->empty, ATSBuffer, next, b);
|
||||
if (b == NULL) {
|
||||
if (spa_list_is_empty (&this->empty)) {
|
||||
if (!this->props[1].live)
|
||||
update_poll_enabled (this, false);
|
||||
return 0;
|
||||
}
|
||||
b = spa_list_first (&this->empty, ATSBuffer, list);
|
||||
spa_list_remove (&b->list);
|
||||
|
||||
fill_buffer (this, b);
|
||||
|
||||
|
|
@ -296,8 +297,7 @@ audiotestsrc_on_output (SpaPollNotifyData *data)
|
|||
timerfd_settime (this->fds[0].fd, TFD_TIMER_ABSTIME, &this->timerspec, NULL);
|
||||
}
|
||||
|
||||
b->next = NULL;
|
||||
SPA_QUEUE_PUSH_TAIL (&this->ready, ATSBuffer, next, b);
|
||||
spa_list_insert (this->ready.prev, &b->list);
|
||||
send_have_output (this);
|
||||
|
||||
return 0;
|
||||
|
|
@ -530,8 +530,8 @@ clear_buffers (SpaAudioTestSrc *this)
|
|||
if (this->n_buffers > 0) {
|
||||
spa_log_info (this->log, "audiotestsrc %p: clear buffers", this);
|
||||
this->n_buffers = 0;
|
||||
SPA_QUEUE_INIT (&this->empty);
|
||||
SPA_QUEUE_INIT (&this->ready);
|
||||
spa_list_init (&this->empty);
|
||||
spa_list_init (&this->ready);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -701,8 +701,7 @@ spa_audiotestsrc_node_port_use_buffers (SpaNode *node,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
b->next = NULL;
|
||||
SPA_QUEUE_PUSH_TAIL (&this->empty, ATSBuffer, next, b);
|
||||
spa_list_insert (this->empty.prev, &b->list);
|
||||
}
|
||||
this->n_buffers = n_buffers;
|
||||
|
||||
|
|
@ -799,10 +798,9 @@ spa_audiotestsrc_node_port_reuse_buffer (SpaNode *node,
|
|||
return SPA_RESULT_OK;
|
||||
|
||||
b->outstanding = false;
|
||||
b->next = NULL;
|
||||
SPA_QUEUE_PUSH_TAIL (&this->empty, ATSBuffer, next, b);
|
||||
spa_list_insert (this->empty.prev, &b->list);
|
||||
|
||||
if (this->empty.length == 1 && !this->props[1].live)
|
||||
if (!this->props[1].live)
|
||||
update_poll_enabled (this, true);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -837,11 +835,12 @@ spa_audiotestsrc_node_process_output (SpaNode *node)
|
|||
if ((output = this->output) == NULL)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
SPA_QUEUE_POP_HEAD (&this->ready, ATSBuffer, next, b);
|
||||
if (b == NULL) {
|
||||
if (spa_list_is_empty (&this->ready)) {
|
||||
output->status = SPA_RESULT_UNEXPECTED;
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
b = spa_list_first (&this->ready, ATSBuffer, list);
|
||||
spa_list_remove (&b->list);
|
||||
b->outstanding = true;
|
||||
|
||||
output->buffer_id = b->outbuf->id;
|
||||
|
|
@ -1007,8 +1006,8 @@ audiotestsrc_init (const SpaHandleFactory *factory,
|
|||
this->props[1].props.prop_info = prop_info;
|
||||
reset_audiotestsrc_props (&this->props[1]);
|
||||
|
||||
SPA_QUEUE_INIT (&this->empty);
|
||||
SPA_QUEUE_INIT (&this->ready);
|
||||
spa_list_init (&this->empty);
|
||||
spa_list_init (&this->ready);
|
||||
|
||||
this->fds[0].fd = timerfd_create (CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC);
|
||||
this->fds[0].events = POLLIN | POLLPRI | POLLERR;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <spa/node.h>
|
||||
#include <spa/video/format.h>
|
||||
#include <spa/queue.h>
|
||||
#include <spa/list.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/id-map.h>
|
||||
#include <lib/debug.h>
|
||||
|
|
@ -60,7 +60,8 @@ struct _V4l2Buffer {
|
|||
bool outstanding;
|
||||
bool allocated;
|
||||
struct v4l2_buffer v4l2_buffer;
|
||||
V4l2Buffer *next;
|
||||
// V4l2Buffer *next;
|
||||
SpaList list;
|
||||
};
|
||||
|
||||
typedef struct _V4l2Format V4l2Format;
|
||||
|
|
@ -112,7 +113,7 @@ typedef struct {
|
|||
|
||||
V4l2Buffer buffers[MAX_BUFFERS];
|
||||
unsigned int n_buffers;
|
||||
SpaQueue ready;
|
||||
SpaList ready;
|
||||
|
||||
SpaPollFd fds[1];
|
||||
SpaPollItem poll;
|
||||
|
|
@ -854,11 +855,17 @@ spa_v4l2_source_node_process_output (SpaNode *node)
|
|||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
|
||||
SPA_QUEUE_POP_HEAD (&state->ready, V4l2Buffer, next, b);
|
||||
if (spa_list_is_empty (&state->ready)) {
|
||||
output->status = SPA_RESULT_UNEXPECTED;
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
|
||||
b = spa_list_first (&state->ready, V4l2Buffer, list);
|
||||
if (b == NULL) {
|
||||
output->status = SPA_RESULT_UNEXPECTED;
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
spa_list_remove (&b->list);
|
||||
b->outstanding = true;
|
||||
|
||||
output->buffer_id = b->outbuf->id;
|
||||
|
|
@ -1021,7 +1028,8 @@ v4l2_source_init (const SpaHandleFactory *factory,
|
|||
this->props[1].props.prop_info = prop_info;
|
||||
reset_v4l2_source_props (&this->props[1]);
|
||||
|
||||
SPA_QUEUE_INIT (&this->state[0].ready);
|
||||
spa_list_init (&this->state[0].ready);
|
||||
// SPA_QUEUE_INIT (&this->state[0].ready);
|
||||
|
||||
this->state[0].log = this->log;
|
||||
this->state[0].info.flags = SPA_PORT_INFO_FLAG_LIVE;
|
||||
|
|
|
|||
|
|
@ -885,8 +885,7 @@ mmap_read (SpaV4l2Source *this)
|
|||
d = b->outbuf->datas;
|
||||
d[0].size = buf.bytesused;
|
||||
|
||||
b->next = NULL;
|
||||
SPA_QUEUE_PUSH_TAIL (&state->ready, V4l2Buffer, next, b);
|
||||
spa_list_insert (state->ready.prev, &b->list);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
#include <spa/id-map.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/node.h>
|
||||
#include <spa/queue.h>
|
||||
#include <spa/list.h>
|
||||
#include <spa/video/format.h>
|
||||
#include <lib/props.h>
|
||||
|
||||
|
|
@ -60,10 +60,10 @@ typedef struct _VTSBuffer VTSBuffer;
|
|||
struct _VTSBuffer {
|
||||
SpaBuffer *outbuf;
|
||||
bool outstanding;
|
||||
VTSBuffer *next;
|
||||
SpaMetaHeader *h;
|
||||
void *ptr;
|
||||
size_t stride;
|
||||
SpaList list;
|
||||
};
|
||||
|
||||
struct _SpaVideoTestSrc {
|
||||
|
|
@ -104,8 +104,8 @@ struct _SpaVideoTestSrc {
|
|||
uint64_t elapsed_time;
|
||||
|
||||
uint64_t frame_count;
|
||||
SpaQueue empty;
|
||||
SpaQueue ready;
|
||||
SpaList empty;
|
||||
SpaList ready;
|
||||
};
|
||||
|
||||
#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) == 0)
|
||||
|
|
@ -213,12 +213,13 @@ videotestsrc_on_output (SpaPollNotifyData *data)
|
|||
SpaVideoTestSrc *this = data->user_data;
|
||||
VTSBuffer *b;
|
||||
|
||||
SPA_QUEUE_POP_HEAD (&this->empty, VTSBuffer, next, b);
|
||||
if (b == NULL) {
|
||||
if (spa_list_is_empty (&this->empty)) {
|
||||
if (!this->props[1].live)
|
||||
update_poll_enabled (this, false);
|
||||
return 0;
|
||||
}
|
||||
b = spa_list_first (&this->empty, VTSBuffer, list);
|
||||
spa_list_remove (&b->list);
|
||||
|
||||
fill_buffer (this, b);
|
||||
|
||||
|
|
@ -243,8 +244,7 @@ videotestsrc_on_output (SpaPollNotifyData *data)
|
|||
timerfd_settime (this->fds[0].fd, TFD_TIMER_ABSTIME, &this->timerspec, NULL);
|
||||
}
|
||||
|
||||
b->next = NULL;
|
||||
SPA_QUEUE_PUSH_TAIL (&this->ready, VTSBuffer, next, b);
|
||||
spa_list_insert (this->ready.prev, &b->list);
|
||||
send_have_output (this);
|
||||
|
||||
return 0;
|
||||
|
|
@ -477,8 +477,8 @@ clear_buffers (SpaVideoTestSrc *this)
|
|||
if (this->n_buffers > 0) {
|
||||
spa_log_info (this->log, "videotestsrc %p: clear buffers", this);
|
||||
this->n_buffers = 0;
|
||||
SPA_QUEUE_INIT (&this->empty);
|
||||
SPA_QUEUE_INIT (&this->ready);
|
||||
spa_list_init (&this->empty);
|
||||
spa_list_init (&this->ready);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -649,8 +649,7 @@ spa_videotestsrc_node_port_use_buffers (SpaNode *node,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
b->next = NULL;
|
||||
SPA_QUEUE_PUSH_TAIL (&this->empty, VTSBuffer, next, b);
|
||||
spa_list_insert (this->empty.prev, &b->list);
|
||||
}
|
||||
this->n_buffers = n_buffers;
|
||||
|
||||
|
|
@ -746,10 +745,9 @@ spa_videotestsrc_node_port_reuse_buffer (SpaNode *node,
|
|||
return SPA_RESULT_OK;
|
||||
|
||||
b->outstanding = false;
|
||||
b->next = NULL;
|
||||
SPA_QUEUE_PUSH_TAIL (&this->empty, VTSBuffer, next, b);
|
||||
spa_list_insert (this->empty.prev, &b->list);
|
||||
|
||||
if (this->empty.length == 1 && !this->props[1].live)
|
||||
if (!this->props[1].live)
|
||||
update_poll_enabled (this, true);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -790,11 +788,11 @@ spa_videotestsrc_node_process_output (SpaNode *node)
|
|||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
|
||||
SPA_QUEUE_POP_HEAD (&this->ready, VTSBuffer, next, b);
|
||||
if (b == NULL) {
|
||||
if (spa_list_is_empty (&this->ready)) {
|
||||
output->status = SPA_RESULT_UNEXPECTED;
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
b = spa_list_first (&this->ready, VTSBuffer, list);
|
||||
b->outstanding = true;
|
||||
|
||||
output->buffer_id = b->outbuf->id;
|
||||
|
|
@ -956,8 +954,8 @@ videotestsrc_init (const SpaHandleFactory *factory,
|
|||
this->props[1].props.prop_info = prop_info;
|
||||
reset_videotestsrc_props (&this->props[1]);
|
||||
|
||||
SPA_QUEUE_INIT (&this->empty);
|
||||
SPA_QUEUE_INIT (&this->ready);
|
||||
spa_list_init (&this->empty);
|
||||
spa_list_init (&this->ready);
|
||||
|
||||
this->fds[0].fd = timerfd_create (CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC);
|
||||
this->fds[0].events = POLLIN | POLLPRI | POLLERR;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue