media-session: handle device events

The object config event should set props on the object.
This commit is contained in:
Wim Taymans 2021-01-07 17:30:10 +01:00
parent ece8a95c29
commit deb3fa1d9b

View file

@ -31,12 +31,14 @@
#include "config.h" #include "config.h"
#include <spa/monitor/device.h> #include <spa/monitor/device.h>
#include <spa/monitor/event.h>
#include <spa/node/node.h> #include <spa/node/node.h>
#include <spa/utils/hook.h> #include <spa/utils/hook.h>
#include <spa/utils/result.h> #include <spa/utils/result.h>
#include <spa/utils/names.h> #include <spa/utils/names.h>
#include <spa/utils/result.h> #include <spa/utils/result.h>
#include <spa/pod/builder.h> #include <spa/pod/builder.h>
#include <spa/pod/parser.h>
#include <spa/param/props.h> #include <spa/param/props.h>
#include <spa/debug/dict.h> #include <spa/debug/dict.h>
#include <spa/debug/pod.h> #include <spa/debug/pod.h>
@ -229,9 +231,37 @@ static void bluez5_device_object_info(void *data, uint32_t id,
} }
static void bluez_device_event(void *data, const struct spa_event *event)
{
struct device *device = data;
struct node *node;
uint32_t id, type;
struct spa_pod *props = NULL;
if (spa_pod_parse_object(&event->pod,
SPA_TYPE_EVENT_Device, &type,
SPA_EVENT_DEVICE_Object, SPA_POD_Int(&id),
SPA_EVENT_DEVICE_Props, SPA_POD_OPT_Pod(&props)) < 0)
return;
if ((node = bluez5_find_node(device, id)) == NULL)
return;
switch (type) {
case SPA_DEVICE_EVENT_ObjectConfig:
if (props)
pw_node_set_param((struct pw_node*)node->snode->obj.proxy,
SPA_PARAM_Props, 0, props);
break;
default:
break;
}
}
static const struct spa_device_events bluez5_device_events = { static const struct spa_device_events bluez5_device_events = {
SPA_VERSION_DEVICE_EVENTS, SPA_VERSION_DEVICE_EVENTS,
.object_info = bluez5_device_object_info .object_info = bluez5_device_object_info,
.event = bluez_device_event,
}; };
static struct device *bluez5_find_device(struct impl *impl, uint32_t id) static struct device *bluez5_find_device(struct impl *impl, uint32_t id)