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:
Wim Taymans 2016-09-19 13:14:14 +02:00
parent fc7b4a9009
commit 1e565a5f65
5 changed files with 235 additions and 59 deletions

View file

@ -81,6 +81,8 @@ typedef struct {
* @SPA_PORT_INFO_FLAG_IN_PLACE: the port can process data in-place and will need
* a writable input buffer
* @SPA_PORT_INFO_FLAG_NO_REF: the port does not keep a ref on the buffer
* @SPA_PORT_INFO_FLAG_LIVE: output buffers from this port are timestamped against
* a live clock.
*/
typedef enum {
SPA_PORT_INFO_FLAG_NONE = 0,
@ -90,6 +92,7 @@ typedef enum {
SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS = 1 << 3,
SPA_PORT_INFO_FLAG_IN_PLACE = 1 << 4,
SPA_PORT_INFO_FLAG_NO_REF = 1 << 5,
SPA_PORT_INFO_FLAG_LIVE = 1 << 6,
} SpaPortInfoFlags;
/**

66
spa/include/spa/queue.h Normal file
View file

@ -0,0 +1,66 @@
/* 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;
#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,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_POP_HEAD(q,t,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__ */