Split out header files

Use separate header files
Add pull-based alsasink
Add audiotestsrc
Implement negotiation and scheduling of audiotestsrc ! alsasink
This commit is contained in:
Wim Taymans 2016-06-03 19:05:19 +02:00
parent 03046301bf
commit 4b2520d173
15 changed files with 2869 additions and 287 deletions

View file

@ -20,15 +20,14 @@
#ifndef __SPI_BUFFER_H__
#define __SPI_BUFFER_H__
G_BEGIN_DECLS
#include <inttypes.h>
#include <pinos/spi/result.h>
#include <pinos/spi/params.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _SpiBuffer SpiBuffer;
#include <spi/defs.h>
typedef enum {
SPI_META_TYPE_INVALID = 0,
SPI_META_TYPE_HEADER,
@ -118,12 +117,16 @@ spi_buffer_unref (SpiBuffer *buffer)
{
if (buffer != NULL) {
if (--buffer->refcount == 0) {
buffer->notify (buffer);
if (buffer->notify)
buffer->notify (buffer);
return NULL;
}
}
return buffer;
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPI_BUFFER_H__ */

55
pinos/spi/command.h Normal file
View file

@ -0,0 +1,55 @@
/* Simple Plugin Interface
* 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 __SPI_COMMAND_H__
#define __SPI_COMMAND_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _SpiCommand SpiCommand;
#include <spi/defs.h>
typedef enum {
SPI_COMMAND_INVALID = 0,
SPI_COMMAND_ACTIVATE,
SPI_COMMAND_DEACTIVATE,
SPI_COMMAND_START,
SPI_COMMAND_STOP,
SPI_COMMAND_FLUSH,
SPI_COMMAND_DRAIN,
SPI_COMMAND_MARKER,
} SpiCommandType;
struct _SpiCommand {
volatile int refcount;
SpiNotify notify;
SpiCommandType type;
uint32_t port_id;
void *data;
size_t size;
};
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPI_COMMAND_H__ */

View file

@ -17,10 +17,16 @@
* Boston, MA 02110-1301, USA.
*/
#ifndef __SPI_RESULT_H__
#define __SPI_RESULT_H__
#ifndef __SPI_DEFS_H__
#define __SPI_DEFS_H__
G_BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#else
#include <stdbool.h>
#endif
#include <inttypes.h>
#include <stdlib.h>
typedef enum {
SPI_RESULT_OK = 0,
@ -38,17 +44,26 @@ typedef enum {
SPI_RESULT_NOT_IMPLEMENTED = -12,
SPI_RESULT_INVALID_PARAM_ID = -13,
SPI_RESULT_PARAM_UNSET = -14,
SPI_RESULT_NO_MORE_FORMATS = -15,
SPI_RESULT_ENUM_END = -15,
SPI_RESULT_WRONG_PARAM_TYPE = -16,
SPI_RESULT_INVALID_MEDIA_TYPE = -17,
SPI_RESULT_INVALID_FORMAT_PARAMS = -18,
SPI_RESULT_FORMAT_INCOMPLETE = -19,
SPI_RESULT_NO_MORE_PARAM_INFO = -20,
SPI_RESULT_WRONG_PARAM_SIZE = -17,
SPI_RESULT_INVALID_MEDIA_TYPE = -18,
SPI_RESULT_INVALID_FORMAT_PARAMS = -19,
SPI_RESULT_FORMAT_INCOMPLETE = -20,
SPI_RESULT_INVALID_ARGUMENTS = -21,
} SpiResult;
typedef enum {
SPI_DIRECTION_INVALID = 0,
SPI_DIRECTION_INPUT,
SPI_DIRECTION_OUTPUT
} SpiDirection;
typedef void (*SpiNotify) (void *data);
G_END_DECLS
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPI_RESULT_H__ */
#endif /* __SPI_DEFS_H__ */

57
pinos/spi/event.h Normal file
View file

@ -0,0 +1,57 @@
/* Simple Plugin Interface
* 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 __SPI_EVENT_H__
#define __SPI_EVENT_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _SpiEvent SpiEvent;
#include <spi/defs.h>
typedef enum {
SPI_EVENT_TYPE_INVALID = 0,
SPI_EVENT_TYPE_ACTIVATED,
SPI_EVENT_TYPE_DEACTIVATED,
SPI_EVENT_TYPE_HAVE_OUTPUT,
SPI_EVENT_TYPE_NEED_INPUT,
SPI_EVENT_TYPE_REQUEST_DATA,
SPI_EVENT_TYPE_DRAINED,
SPI_EVENT_TYPE_MARKER,
SPI_EVENT_TYPE_ERROR,
SPI_EVENT_TYPE_BUFFERING,
} SpiEventType;
struct _SpiEvent {
volatile int refcount;
SpiNotify notify;
SpiEventType type;
uint32_t port_id;
void *data;
size_t size;
};
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPI_EVENT_H__ */

View file

@ -20,94 +20,18 @@
#ifndef __SPI_NODE_H__
#define __SPI_NODE_H__
G_BEGIN_DECLS
#include <inttypes.h>
#include <pinos/spi/result.h>
#include <pinos/spi/params.h>
#include <pinos/spi/buffer.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _SpiNode SpiNode;
typedef struct _SpiEvent SpiEvent;
/**
* SpiPortInfoFlags:
* @SPI_PORT_INFO_FLAG_NONE: no flags
* @SPI_PORT_INFO_FLAG_REMOVABLE: port can be removed
* @SPI_PORT_INFO_FLAG_OPTIONAL: processing on port is optional
* @SPI_PORT_INFO_FLAG_CAN_GIVE_BUFFER: the port can give a buffer
* @SPI_PORT_INFO_FLAG_CAN_USE_BUFFER: the port can use a provided buffer
* @SPI_PORT_INFO_FLAG_IN_PLACE: the port can process data in-place and will need
* a writable input buffer when no output buffer is specified.
* @SPI_PORT_INFO_FLAG_NO_REF: the port does not keep a ref on the buffer
*/
typedef enum {
SPI_PORT_INFO_FLAG_NONE = 0,
SPI_PORT_INFO_FLAG_REMOVABLE = 1 << 0,
SPI_PORT_INFO_FLAG_OPTIONAL = 1 << 1,
SPI_PORT_INFO_FLAG_CAN_GIVE_BUFFER = 1 << 2,
SPI_PORT_INFO_FLAG_CAN_USE_BUFFER = 1 << 3,
SPI_PORT_INFO_FLAG_IN_PLACE = 1 << 4,
SPI_PORT_INFO_FLAG_NO_REF = 1 << 5,
} SpiPortInfoFlags;
/**
* SpiPortInfo
* @flags: extra port flags
* @size: minimum size of the buffers or 0 when not specified
* @align: required alignment of the data
* @maxbuffering: the maximum amount of bytes that the element will keep
* around internally
* @latency: latency on this port in nanoseconds
* @features: NULL terminated array of extra port features
*
*/
typedef struct {
SpiPortInfoFlags flags;
size_t minsize;
uint32_t align;
unsigned int maxbuffering;
uint64_t latency;
const char **features;
} SpiPortInfo;
/**
* SpiPortStatusFlags:
* @SPI_PORT_STATUS_FLAG_NONE: no status flags
* @SPI_PORT_STATUS_FLAG_HAVE_OUTPUT: port has output
* @SPI_PORT_STATUS_FLAG_NEED_INPUT: port needs input
*/
typedef enum {
SPI_PORT_STATUS_FLAG_NONE = 0,
SPI_PORT_STATUS_FLAG_HAVE_OUTPUT = 1 << 0,
SPI_PORT_STATUS_FLAG_NEED_INPUT = 1 << 1,
} SpiPortStatusFlags;
typedef struct {
SpiPortStatusFlags flags;
} SpiPortStatus;
typedef enum {
SPI_EVENT_TYPE_INVALID = 0,
SPI_EVENT_TYPE_ACTIVATED,
SPI_EVENT_TYPE_DEACTIVATED,
SPI_EVENT_TYPE_HAVE_OUTPUT,
SPI_EVENT_TYPE_NEED_INPUT,
SPI_EVENT_TYPE_REQUEST_DATA,
SPI_EVENT_TYPE_DRAINED,
SPI_EVENT_TYPE_MARKER,
SPI_EVENT_TYPE_ERROR,
} SpiEventType;
struct _SpiEvent {
volatile int refcount;
SpiNotify notify;
SpiEventType type;
uint32_t port_id;
void *data;
size_t size;
};
#include <spi/defs.h>
#include <spi/params.h>
#include <spi/port.h>
#include <spi/event.h>
#include <spi/buffer.h>
#include <spi/command.h>
/**
* SpiDataFlags:
@ -141,36 +65,25 @@ typedef struct {
SpiEvent *event;
} SpiDataInfo;
typedef enum {
SPI_COMMAND_INVALID = 0,
SPI_COMMAND_ACTIVATE,
SPI_COMMAND_DEACTIVATE,
SPI_COMMAND_START,
SPI_COMMAND_STOP,
SPI_COMMAND_FLUSH,
SPI_COMMAND_DRAIN,
SPI_COMMAND_MARKER,
} SpiCommandType;
typedef struct {
volatile int refcount;
SpiNotify notify;
SpiCommandType type;
uint32_t port_id;
void *data;
size_t size;
} SpiCommand;
typedef enum {
SPI_DIRECTION_INVALID = 0,
SPI_DIRECTION_INPUT,
SPI_DIRECTION_OUTPUT
} SpiDirection;
typedef void (*SpiEventCallback) (SpiNode *node,
SpiEvent *event,
void *user_data);
/**
* SpiInterfaceInfo:
* @interface_id: the id of the interface, can be used to get the interface
* @name: name of the interface
* @description: Human readable description of the interface.
*
* This structure lists the information about available interfaces on
* objects.
*/
typedef struct {
uint32_t interface_id;
const char *name;
const char *description;
} SpiInterfaceInfo;
/**
* SpiNode:
*
@ -290,9 +203,9 @@ struct _SpiNode {
SpiResult (*remove_port) (SpiNode *node,
uint32_t port_id);
SpiResult (*get_port_formats) (SpiNode *node,
SpiResult (*enum_port_formats) (SpiNode *node,
uint32_t port_id,
unsigned int format_idx,
unsigned int index,
SpiParams **format);
SpiResult (*set_port_format) (SpiNode *node,
uint32_t port_id,
@ -323,8 +236,43 @@ struct _SpiNode {
unsigned int n_data,
SpiDataInfo *data);
/**
* SpiNode::enum_interface_info:
* @node: a #SpiNode
* @index: the interface index
* @info: result to hold SpiInterfaceInfo.
*
* Get the interface provided by @node at @index.
*
* Returns: #SPI_RESULT_OK on success
* #SPI_RESULT_NOT_IMPLEMENTED when there are no extensions
* #SPI_RESULT_INVALID_ARGUMENTS when node or info is %NULL
* #SPI_RESULT_ENUM_END when there are no more infos
*/
SpiResult (*enum_interface_info) (SpiNode *node,
unsigned int index,
const SpiInterfaceInfo **info);
/**
* SpiNode::enum_interface_info:
* @node: a #SpiNode
* @index: the interface index
* @info: result to hold SpiInterfaceInfo.
*
* Get the interface provided by @node at @index.
*
* Returns: #SPI_RESULT_OK on success
* #SPI_RESULT_NOT_IMPLEMENTED when there are no extensions
* #SPI_RESULT_INVALID_ARGUMENTS when node or info is %NULL
* #SPI_RESULT_ENUM_END when there are no more infos
*/
SpiResult (*get_interface) (SpiNode *node,
uint32_t interface_id,
void **interface);
};
G_END_DECLS
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPI_NODE_H__ */

View file

@ -20,12 +20,14 @@
#ifndef __SPI_PARAMS_H__
#define __SPI_PARAMS_H__
G_BEGIN_DECLS
#include <pinos/spi/result.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _SpiParams SpiParams;
#include <spi/defs.h>
/**
* SpiParamType:
*/
@ -92,7 +94,7 @@ typedef enum {
typedef struct {
const char *name;
const char *description;
int size;
size_t size;
const void *value;
} SpiParamRangeInfo;
@ -112,13 +114,13 @@ typedef struct {
* @priv: extra private data
*/
typedef struct {
int id;
uint32_t id;
const char *name;
const char *description;
SpiParamFlags flags;
SpiParamType type;
int maxsize;
int default_size;
size_t maxsize;
size_t default_size;
const void *default_value;
SpiParamRangeType range_type;
const SpiParamRangeInfo *range_values;
@ -141,11 +143,11 @@ struct _SpiParams {
* Gets the information about the parameter at @idx in @params.
*
* Returns: #SPI_RESULT_OK on success.
* #SPI_RESULT_NO_MORE_PARAM_INFO when there is no param info
* #SPI_RESULT_ENM_END when there is no param info
* at @idx. This can be used to iterate the @params.
*/
SpiResult (*get_param_info) (const SpiParams *params,
int idx,
SpiResult (*enum_param_info) (const SpiParams *params,
unsigned int idx,
const SpiParamInfo **infos);
/**
* SpiParams::set_param
@ -164,7 +166,7 @@ struct _SpiParams {
* #SPI_RESULT_WRONG_PARAM_TYPE when @type is not correct
*/
SpiResult (*set_param) (SpiParams *params,
int id,
uint32_t id,
SpiParamType type,
size_t size,
const void *value);
@ -183,12 +185,14 @@ struct _SpiParams {
* #SPI_RESULT_PARAM_UNSET when no value has been set yet
*/
SpiResult (*get_param) (const SpiParams *params,
int id,
uint32_t id,
SpiParamType *type,
size_t *size,
const void **value);
};
G_END_DECLS
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPI_PARAMS_H__ */

91
pinos/spi/port.h Normal file
View file

@ -0,0 +1,91 @@
/* Simple Plugin Interface
* 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 __SPI_PORT_H__
#define __SPI_PORT_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <spi/defs.h>
/**
* SpiPortInfoFlags:
* @SPI_PORT_INFO_FLAG_NONE: no flags
* @SPI_PORT_INFO_FLAG_REMOVABLE: port can be removed
* @SPI_PORT_INFO_FLAG_OPTIONAL: processing on port is optional
* @SPI_PORT_INFO_FLAG_CAN_GIVE_BUFFER: the port can give a buffer
* @SPI_PORT_INFO_FLAG_CAN_USE_BUFFER: the port can use a provided buffer
* @SPI_PORT_INFO_FLAG_IN_PLACE: the port can process data in-place and will need
* a writable input buffer when no output buffer is specified.
* @SPI_PORT_INFO_FLAG_NO_REF: the port does not keep a ref on the buffer
*/
typedef enum {
SPI_PORT_INFO_FLAG_NONE = 0,
SPI_PORT_INFO_FLAG_REMOVABLE = 1 << 0,
SPI_PORT_INFO_FLAG_OPTIONAL = 1 << 1,
SPI_PORT_INFO_FLAG_CAN_GIVE_BUFFER = 1 << 2,
SPI_PORT_INFO_FLAG_CAN_USE_BUFFER = 1 << 3,
SPI_PORT_INFO_FLAG_IN_PLACE = 1 << 4,
SPI_PORT_INFO_FLAG_NO_REF = 1 << 5,
} SpiPortInfoFlags;
/**
* SpiPortInfo
* @flags: extra port flags
* @size: minimum size of the buffers or 0 when not specified
* @align: required alignment of the data
* @maxbuffering: the maximum amount of bytes that the element will keep
* around internally
* @latency: latency on this port in nanoseconds
* @features: NULL terminated array of extra port features
*
*/
typedef struct {
SpiPortInfoFlags flags;
size_t minsize;
uint32_t align;
unsigned int maxbuffering;
uint64_t latency;
const char **features;
} SpiPortInfo;
/**
* SpiPortStatusFlags:
* @SPI_PORT_STATUS_FLAG_NONE: no status flags
* @SPI_PORT_STATUS_FLAG_HAVE_OUTPUT: port has output
* @SPI_PORT_STATUS_FLAG_NEED_INPUT: port needs input
*/
typedef enum {
SPI_PORT_STATUS_FLAG_NONE = 0,
SPI_PORT_STATUS_FLAG_HAVE_OUTPUT = 1 << 0,
SPI_PORT_STATUS_FLAG_NEED_INPUT = 1 << 1,
} SpiPortStatusFlags;
typedef struct {
SpiPortStatusFlags flags;
} SpiPortStatus;
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPI_PORT_H__ */