return manager_get_audio_device(device, TRUE);
}
-static GSList *manager_find_devices(const char *path,
- const bdaddr_t *src,
- const bdaddr_t *dst,
- const char *interface,
- gboolean connected)
+static struct audio_device *manager_find_device(struct btd_device *device)
{
- GSList *result = NULL;
GSList *l;
for (l = devices; l != NULL; l = l->next) {
struct audio_device *dev = l->data;
- const bdaddr_t *dev_src;
- const bdaddr_t *dev_dst;
- dev_src = adapter_get_address(device_get_adapter(dev->btd_dev));
- dev_dst = device_get_address(dev->btd_dev);
-
- if ((path && (strcmp(path, "")) &&
- strcmp(device_get_path(dev->btd_dev), path)))
- continue;
-
- if ((src && bacmp(src, BDADDR_ANY)) && bacmp(dev_src, src))
- continue;
-
- if ((dst && bacmp(dst, BDADDR_ANY)) && bacmp(dev_dst, dst))
- continue;
-
- if (interface && !strcmp(AUDIO_SINK_INTERFACE, interface)
- && !dev->sink)
- continue;
-
- if (interface && !strcmp(AUDIO_SOURCE_INTERFACE, interface)
- && !dev->source)
- continue;
-
- if (interface && !strcmp(AUDIO_CONTROL_INTERFACE, interface)
- && !dev->control)
- continue;
-
- if (connected && !audio_device_is_active(dev, interface))
- continue;
-
- result = g_slist_append(result, dev);
+ if (dev->btd_dev == device)
+ return dev;
}
- return result;
-}
-
-static struct audio_device *manager_find_device(const char *path,
- const bdaddr_t *src,
- const bdaddr_t *dst,
- const char *interface,
- gboolean connected)
-{
- struct audio_device *result;
- GSList *l;
-
- l = manager_find_devices(path, src, dst, interface, connected);
- if (l == NULL)
- return NULL;
-
- result = l->data;
- g_slist_free(l);
- return result;
+ return NULL;
}
static void audio_remove(struct btd_profile *p, struct btd_device *device)
{
struct audio_device *dev;
- const char *path;
-
- path = device_get_path(device);
- dev = manager_find_device(path, NULL, NULL, NULL, FALSE);
+ dev = manager_find_device(device);
if (dev == NULL)
return;
gboolean create)
{
struct audio_device *dev;
- struct btd_adapter *adapter = device_get_adapter(device);
- dev = manager_find_device(NULL, adapter_get_address(adapter),
- device_get_address(device), NULL,
- FALSE);
+ dev = manager_find_device(device);
if (dev)
return dev;