monitor: remove monitor API and use device

Remove the monitor API, we can use the device API for it. Make sure
we support creating devices (like alsa) from another device (udev).

Use new object.id to store the object id in the object properties. Use
the port.id/node.id etc to make relations to other objects.
This commit is contained in:
Wim Taymans 2019-09-20 13:04:14 +02:00
parent 818fb9e904
commit 6756a3c8fc
43 changed files with 474 additions and 1015 deletions

View file

@ -37,8 +37,6 @@ install_headers(spa_graph_headers,
spa_monitor_headers = [
'monitor/device.h',
'monitor/monitor.h',
'monitor/type-info.h',
'monitor/utils.h',
]

View file

@ -236,8 +236,10 @@ struct spa_device_methods {
#define spa_device_enum_params(d,...) spa_device_method(d, enum_params, 0, __VA_ARGS__)
#define spa_device_set_param(d,...) spa_device_method(d, set_param, 0, __VA_ARGS__)
#define SPA_KEY_DEVICE_ENUM_API "device.enum.api" /**< the api used to discover this
* device */
#define SPA_KEY_DEVICE_API "device.api" /**< the api used by the device
* Ex. "alsa", "v4l2". */
* Ex. "udev", "alsa", "v4l2". */
#define SPA_KEY_DEVICE_NAME "device.name" /**< the name of the device */
#define SPA_KEY_DEVICE_ALIAS "device.alias" /**< altenative name of the device */
#define SPA_KEY_DEVICE_NICK "device.nick" /**< the device short name */

View file

@ -1,133 +0,0 @@
/* Simple Plugin API
*
* Copyright © 2018 Wim Taymans
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef SPA_MONITOR_H
#define SPA_MONITOR_H
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/defs.h>
#include <spa/utils/dict.h>
#include <spa/pod/event.h>
#include <spa/pod/builder.h>
#define SPA_VERSION_MONITOR 0
struct spa_monitor { struct spa_interface iface; };
struct spa_monitor_info {
#define SPA_VERSION_MONITOR_INFO 0
uint32_t version;
#define SPA_MONITOR_CHANGE_MASK_FLAGS (1u<<0)
#define SPA_MONITOR_CHANGE_MASK_PROPS (1u<<1)
uint64_t change_mask;
uint64_t flags;
const struct spa_dict *props;
};
#define SPA_MONITOR_INFO_INIT() (struct spa_monitor_info){ SPA_VERSION_MONITOR_INFO, }
struct spa_monitor_object_info {
#define SPA_VERSION_MONITOR_OBJECT_INFO 0
uint32_t version;
uint32_t type;
const char *factory_name;
#define SPA_MONITOR_OBJECT_CHANGE_MASK_FLAGS (1u<<0)
#define SPA_MONITOR_OBJECT_CHANGE_MASK_PROPS (1u<<1)
uint64_t change_mask;
uint64_t flags;
const struct spa_dict *props;
};
#define SPA_MONITOR_OBJECT_INFO_INIT() (struct spa_monitor_object_info){ SPA_VERSION_MONITOR_OBJECT_INFO, }
/**
* spa_monitor_callbacks:
*/
struct spa_monitor_callbacks {
/** version of the structure */
#define SPA_VERSION_MONITOR_CALLBACKS 0
uint32_t version;
/** receive extra information about the monitor */
int (*info) (void *data, const struct spa_monitor_info *info);
/** an item is added/removed/changed on the monitor */
int (*event) (void *data, const struct spa_event *event);
/** info changed for an object managed by the monitor, info is NULL when
* the object is removed */
int (*object_info) (void *data, uint32_t id,
const struct spa_monitor_object_info *info);
};
/**
* spa_monitor_methods:
*
* The device monitor methods.
*/
struct spa_monitor_methods {
/* the version of this monitor. This can be used to expand this
* structure in the future */
#define SPA_VERSION_MONITOR_METHODS 0
uint32_t version;
/**
* Set callbacks to receive asynchronous notifications from
* the monitor.
*
* Setting the callbacks will emit the info
*
* \param monitor: a #spa_monitor
* \param callback: a #callbacks
* \return 0 on success
* < 0 errno on error
*/
int (*set_callbacks) (void *object,
const struct spa_monitor_callbacks *callbacks,
void *data);
};
static inline int spa_monitor_set_callbacks(struct spa_monitor *m,
const struct spa_monitor_callbacks *callbacks, void *data)
{
int res = -ENOTSUP;
spa_interface_call_res(&m->iface,
struct spa_monitor_methods, res, set_callbacks, 0,
callbacks, data);
return res;
}
#define SPA_KEY_MONITOR_API "monitor.api" /**< the api used by the monitor.
* Ex. "udev", "dbus", ... */
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* SPA_MONITOR_H */

View file

@ -1,51 +0,0 @@
/* Simple Plugin API
*
* Copyright © 2018 Wim Taymans
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef SPA_MONITOR_TYPES_H
#define SPA_MONITOR_TYPES_H
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/type-info.h>
#include <spa/monitor/monitor.h>
#define SPA_TYPE_INFO_MonitorEvent SPA_TYPE_INFO_EVENT_BASE "Monitor"
#define SPA_TYPE_INFO_MONITOR_EVENT_BASE SPA_TYPE_INFO_MonitorEvent ":"
static const struct spa_type_info spa_type_monitor_event_id[] = {
{ 0, 0, NULL, NULL },
};
static const struct spa_type_info spa_type_monitor_event[] = {
{ 0, SPA_TYPE_Id, SPA_TYPE_INFO_MONITOR_EVENT_BASE, spa_type_monitor_event_id },
{ 0, 0, NULL, NULL },
};
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* SPA_MONITOR_TYPES_H */

View file

@ -66,9 +66,9 @@ struct spa_interface {
struct spa_hook {
struct spa_list link;
struct spa_callbacks cb;
void *priv; /**< private data for the hook list */
/** callback and data for the hook list */
void (*removed) (struct spa_hook *hook);
void *priv;
};
/** Initialize a hook list */
@ -77,6 +77,11 @@ static inline void spa_hook_list_init(struct spa_hook_list *list)
spa_list_init(&list->list);
}
static inline bool spa_hook_list_is_empty(struct spa_hook_list *list)
{
return spa_list_is_empty(&list->list);
}
/** Append a hook \memberof spa_hook */
static inline void spa_hook_list_append(struct spa_hook_list *list,
struct spa_hook *hook,

View file

@ -37,6 +37,10 @@ extern "C" {
* Screen, Communication, Game,
* Notification, DSP, Production,
* Accessibility, Test */
/** keys for udev api */
#define SPA_KEY_API_UDEV "api.udev" /**< key for the udev api */
#define SPA_KEY_API_UDEV_MATCH "api.udev.match" /**< udev subsystem match */
/** keys for alsa api */
#define SPA_KEY_API_ALSA "api.alsa" /**< key for the alsa api */
#define SPA_KEY_API_ALSA_PATH "api.alsa.path" /**< alsa device path as can be

View file

@ -77,7 +77,7 @@ extern "C" {
#define SPA_NAME_VIDEO_ADAPT "video.adapt" /**< combination of a node and a
* video.convert. */
/** keys for alsa factory names */
#define SPA_NAME_API_ALSA_MONITOR "api.alsa.monitor" /**< an alsa Monitor interface */
#define SPA_NAME_API_ALSA_ENUM_UDEV "api.alsa.enum.udev" /**< an alsa udev Device interface */
#define SPA_NAME_API_ALSA_DEVICE "api.alsa.device" /**< an alsa Device interface */
#define SPA_NAME_API_ALSA_PCM_SOURCE "api.alsa.pcm.source" /**< an alsa Node interface for
* capturing PCM */
@ -87,7 +87,7 @@ extern "C" {
* capturing midi */
/** keys for bluez5 factory names */
#define SPA_NAME_API_BLUEZ5_MONITOR "api.bluez5.monitor" /**< a Monitor interface */
#define SPA_NAME_API_BLUEZ5_ENUM_DBUS "api.bluez5.enum.dbus" /**< a dbus Device interface */
#define SPA_NAME_API_BLUEZ5_DEVICE "api.bluez5.device" /**< a Device interface */
#define SPA_NAME_API_BLUEZ5_A2DP_SINK "api.bluez5.a2dp.sink" /**< a playback Node interface for A2DP profiles */
#define SPA_NAME_API_BLUEZ5_A2DP_SOURCE "api.bluez5.a2dp.source" /**< a capture Node interface for A2DP profiles */
@ -95,7 +95,7 @@ extern "C" {
#define SPA_NAME_API_BLUEZ5_SCO_SOURCE "api.bluez5.sco.source" /**< a capture Node interface for HSP/HFP profiles */
/** keys for v4l2 factory names */
#define SPA_NAME_API_V4L2_MONITOR "api.v4l2.monitor" /**< a v4l2 Monitor interface */
#define SPA_NAME_API_V4L2_ENUM_UDEV "api.v4l2.enum.udev" /**< a v4l2 udev Device interface */
#define SPA_NAME_API_V4L2_DEVICE "api.v4l2.device" /**< a v4l2 Device interface */
#define SPA_NAME_API_V4L2_SOURCE "api.v4l2.source" /**< a v4l2 Node interface for
* capturing */

View file

@ -52,7 +52,6 @@ static const struct spa_type_info spa_type_direction[] = {
{ 0, 0, NULL, NULL }
};
#include <spa/monitor/type-info.h>
#include <spa/node/type-info.h>
#include <spa/param/type-info.h>
#include <spa/control/type-info.h>
@ -110,16 +109,16 @@ static const struct spa_type_info spa_types[] = {
{ SPA_TYPE_INTERFACE_DataSystem, SPA_TYPE_Pointer, SPA_TYPE_INFO_INTERFACE_BASE "DataSystem", NULL },
{ SPA_TYPE_INTERFACE_DataLoop, SPA_TYPE_Pointer, SPA_TYPE_INFO_INTERFACE_BASE "DataLoop", NULL },
{ SPA_TYPE_INTERFACE_DBus, SPA_TYPE_Pointer, SPA_TYPE_INFO_INTERFACE_BASE "DBus", NULL },
{ SPA_TYPE_INTERFACE_Monitor, SPA_TYPE_Pointer, SPA_TYPE_INFO_INTERFACE_BASE "Monitor", NULL },
{ SPA_TYPE_INTERFACE_Node, SPA_TYPE_Pointer, SPA_TYPE_INFO_INTERFACE_BASE "Node", NULL },
{ SPA_TYPE_INTERFACE_Device, SPA_TYPE_Pointer, SPA_TYPE_INFO_INTERFACE_BASE "Device", NULL },
{ SPA_TYPE_INTERFACE_CPU, SPA_TYPE_Pointer, SPA_TYPE_INFO_INTERFACE_BASE "CPU", NULL },
{ SPA_TYPE_EVENT_START, SPA_TYPE_Object, SPA_TYPE_INFO_Event, NULL },
{ SPA_TYPE_EVENT_Monitor, SPA_TYPE_Object, SPA_TYPE_INFO_EVENT_BASE "Monitor", spa_type_monitor_event },
{ SPA_TYPE_EVENT_Device, SPA_TYPE_Object, SPA_TYPE_INFO_EVENT_BASE "Device", NULL },
{ SPA_TYPE_EVENT_Node, SPA_TYPE_Object, SPA_TYPE_INFO_EVENT_BASE "Node", spa_type_node_event },
{ SPA_TYPE_COMMAND_START, SPA_TYPE_Object, SPA_TYPE_INFO_Command, NULL },
{ SPA_TYPE_COMMAND_Device, SPA_TYPE_Object, SPA_TYPE_INFO_COMMAND_BASE "Device", NULL },
{ SPA_TYPE_COMMAND_Node, SPA_TYPE_Object, SPA_TYPE_INFO_COMMAND_BASE "Node", spa_type_node_command },
{ SPA_TYPE_OBJECT_START, SPA_TYPE_Object, SPA_TYPE_INFO_Object, NULL },

View file

@ -75,7 +75,6 @@ enum {
SPA_TYPE_INTERFACE_DataSystem, /**< System functions for data loop */
SPA_TYPE_INTERFACE_DataLoop, /**< a data loop */
SPA_TYPE_INTERFACE_DBus, /**< dbus connection */
SPA_TYPE_INTERFACE_Monitor, /**< monitor of devices */
SPA_TYPE_INTERFACE_Node, /**< nodes for data processing */
SPA_TYPE_INTERFACE_Device, /**< device managing nodes */
SPA_TYPE_INTERFACE_CPU, /**< CPU functions */
@ -83,12 +82,13 @@ enum {
/* Events */
SPA_TYPE_EVENT_START = 0x30000,
SPA_TYPE_EVENT_Monitor,
SPA_TYPE_EVENT_Device,
SPA_TYPE_EVENT_Node,
SPA_TYPE_EVENT_LAST, /**< not part of ABI */
/* Commands */
SPA_TYPE_COMMAND_START = 0x40000,
SPA_TYPE_COMMAND_Device,
SPA_TYPE_COMMAND_Node,
SPA_TYPE_COMMAND_LAST, /**< not part of ABI */