monitor: Remove monitor event

Remove the monitor event and emit events with structures like we do
for the devices.
This commit is contained in:
Wim Taymans 2019-05-30 12:45:06 +02:00
parent 3780bd1b30
commit 9785d99821
12 changed files with 268 additions and 422 deletions

View file

@ -37,41 +37,34 @@ extern "C" {
#define SPA_VERSION_MONITOR 0
struct spa_monitor { struct spa_interface iface; };
enum spa_monitor_event {
SPA_MONITOR_EVENT_Invalid,
SPA_MONITOR_EVENT_Added,
SPA_MONITOR_EVENT_Removed,
SPA_MONITOR_EVENT_Changed,
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;
};
/** monitor event id, one of enum spa_monitor_event */
#define SPA_MONITOR_EVENT_ID(ev) SPA_EVENT_ID(ev, SPA_TYPE_EVENT_Monitor)
#define SPA_MONITOR_INFO_INIT() (struct spa_monitor_info){ SPA_VERSION_MONITOR_INFO, }
enum spa_monitor_item_flags {
SPA_MONITOR_ITEM_FLAG_NONE = 0,
};
/** The monitor item state */
enum spa_monitor_item_state {
SPA_MONITOR_ITEM_STATE_Invalid, /*< The item is available */
SPA_MONITOR_ITEM_STATE_Available, /*< The item is available */
SPA_MONITOR_ITEM_STATE_Disabled, /*< The item is disabled */
SPA_MONITOR_ITEM_STATE_Unavailable, /*< The item is unavailable */
};
/** properties for SPA_TYPE_OBJECT_MonitorItem */
enum spa_monitor_item {
SPA_MONITOR_ITEM_START, /**< id of object, one of enum spa_monitor_event */
SPA_MONITOR_ITEM_id,
SPA_MONITOR_ITEM_flags, /**< one of enum spa_monitor_item_flags */
SPA_MONITOR_ITEM_state, /**< one of enum spa_monitor_item_state */
SPA_MONITOR_ITEM_name,
SPA_MONITOR_ITEM_class,
SPA_MONITOR_ITEM_info,
SPA_MONITOR_ITEM_factory,
SPA_MONITOR_ITEM_type,
struct spa_monitor_object_info {
#define SPA_VERSION_MONITOR_OBJECT_INFO 0
uint32_t version;
uint32_t type;
const struct spa_handle_factory *factory;
#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:
*/
@ -81,10 +74,15 @@ struct spa_monitor_callbacks {
uint32_t version;
/** receive extra information about the monitor */
int (*info) (void *data, const struct spa_dict *info);
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);
};
/**

View file

@ -36,9 +36,6 @@ extern "C" {
#define SPA_TYPE_INFO_MONITOR_EVENT_BASE SPA_TYPE_INFO_MonitorEvent ":"
static const struct spa_type_info spa_type_monitor_event_id[] = {
{ SPA_MONITOR_EVENT_Added, SPA_TYPE_Int, SPA_TYPE_INFO_MONITOR_EVENT_BASE "Added", NULL },
{ SPA_MONITOR_EVENT_Removed, SPA_TYPE_Int, SPA_TYPE_INFO_MONITOR_EVENT_BASE "Removed", NULL },
{ SPA_MONITOR_EVENT_Changed, SPA_TYPE_Int, SPA_TYPE_INFO_MONITOR_EVENT_BASE "Changed", NULL },
{ 0, 0, NULL, NULL },
};
@ -47,42 +44,6 @@ static const struct spa_type_info spa_type_monitor_event[] = {
{ 0, 0, NULL, NULL },
};
#define SPA_TYPE_INFO_MonitorItemFlags SPA_TYPE_INFO_FLAGS_BASE "MonitorItemFlags"
#define SPA_TYPE_INFO_MONITOR_ITEM_FLAGS_BASE SPA_TYPE_INFO_MonitorItemFlags ":"
static const struct spa_type_info spa_type_monitor_item_flags[] = {
{ SPA_MONITOR_ITEM_FLAG_NONE, SPA_TYPE_Int, SPA_TYPE_INFO_MONITOR_ITEM_FLAGS_BASE "none", NULL },
{ 0, 0, NULL, NULL },
};
#define SPA_TYPE_INFO_MonitorItemState SPA_TYPE_INFO_ENUM_BASE "MonitorItemState"
#define SPA_TYPE_INFO_MONITOR_ITEM_STATE_BASE SPA_TYPE_INFO_MonitorItemState ":"
static const struct spa_type_info spa_type_monitor_item_state[] = {
{ SPA_MONITOR_ITEM_STATE_Available, SPA_TYPE_Int, SPA_TYPE_INFO_MONITOR_ITEM_STATE_BASE "Available", NULL },
{ SPA_MONITOR_ITEM_STATE_Disabled, SPA_TYPE_Int, SPA_TYPE_INFO_MONITOR_ITEM_STATE_BASE "Disabled", NULL },
{ SPA_MONITOR_ITEM_STATE_Unavailable, SPA_TYPE_Int, SPA_TYPE_INFO_MONITOR_ITEM_STATE_BASE "Unavailable", NULL },
{ 0, 0, NULL, NULL },
};
#define SPA_TYPE_INFO_MonitorItem SPA_TYPE_INFO_OBJECT_BASE "MonitorItem"
#define SPA_TYPE_INFO_MONITOR_ITEM_BASE SPA_TYPE_INFO_MonitorItem ":"
static const struct spa_type_info spa_type_monitor_item[] = {
{ SPA_MONITOR_ITEM_START, SPA_TYPE_Int, SPA_TYPE_INFO_MONITOR_ITEM_BASE, NULL },
{ SPA_MONITOR_ITEM_id, SPA_TYPE_String, SPA_TYPE_INFO_MONITOR_ITEM_BASE "id", NULL },
{ SPA_MONITOR_ITEM_flags, SPA_TYPE_Id, SPA_TYPE_INFO_MONITOR_ITEM_BASE "flags",
spa_type_monitor_item_flags },
{ SPA_MONITOR_ITEM_state, SPA_TYPE_Id, SPA_TYPE_INFO_MONITOR_ITEM_BASE "state",
spa_type_monitor_item_state },
{ SPA_MONITOR_ITEM_name, SPA_TYPE_String, SPA_TYPE_INFO_MONITOR_ITEM_BASE "name", NULL },
{ SPA_MONITOR_ITEM_class, SPA_TYPE_String, SPA_TYPE_INFO_MONITOR_ITEM_BASE "class", NULL },
{ SPA_MONITOR_ITEM_info, SPA_TYPE_Pod, SPA_TYPE_INFO_MONITOR_ITEM_BASE "info", NULL },
{ SPA_MONITOR_ITEM_factory, SPA_TYPE_Pointer, SPA_TYPE_INFO_MONITOR_ITEM_BASE "factory", NULL },
{ SPA_MONITOR_ITEM_type, SPA_TYPE_Id, SPA_TYPE_INFO_MONITOR_ITEM_BASE "type", NULL },
{ 0, 0, NULL, NULL },
};
#ifdef __cplusplus
} /* extern "C" */
#endif

View file

@ -88,6 +88,7 @@ static inline int spa_device_enum_params_sync(struct spa_device *device,
#define spa_monitor_call_info(hook,i) spa_monitor_call(hook, info, 0, i)
#define spa_monitor_call_event(hook,e) spa_monitor_call(hook, event, 0, e)
#define spa_monitor_call_object_info(hook,id,i) spa_monitor_call(hook, object_info, 0, id, i)
#define spa_device_emit(hooks,method,version,...) \
spa_hook_list_call_simple(hooks, struct spa_device_events, \