Пример #1
0
struct audio_device *audio_device_register(DBusConnection *conn,
        struct btd_device *device,
        const char *path, const bdaddr_t *src,
        const bdaddr_t *dst)
{
    struct audio_device *dev;

    if (!conn || !path)
        return NULL;

    dev = g_new0(struct audio_device, 1);

    dev->btd_dev = btd_device_ref(device);
    dev->path = g_strdup(path);
    bacpy(&dev->dst, dst);
    bacpy(&dev->src, src);
    dev->conn = dbus_connection_ref(conn);
    dev->priv = g_new0(struct dev_priv, 1);
    dev->priv->state = AUDIO_STATE_DISCONNECTED;

    if (!g_dbus_register_interface(dev->conn, dev->path,
                                   AUDIO_INTERFACE,
                                   dev_methods, dev_signals, NULL,
                                   dev, NULL)) {
        error("Unable to register %s on %s", AUDIO_INTERFACE,
              dev->path);
        device_free(dev);
        return NULL;
    }

    DBG("Registered interface %s on path %s", AUDIO_INTERFACE,
        dev->path);

    if (sink_callback_id == 0)
        sink_callback_id = sink_add_state_cb(device_sink_cb, NULL);

    if (avdtp_callback_id == 0)
        avdtp_callback_id = avdtp_add_state_cb(device_avdtp_cb, NULL);
    if (avctp_callback_id == 0)
        avctp_callback_id = avctp_add_state_cb(device_avctp_cb, NULL);

    if (headset_callback_id == 0)
        headset_callback_id = headset_add_state_cb(device_headset_cb,
                              NULL);

    return dev;
}
Пример #2
0
struct source *source_init(struct audio_device *dev,
						struct btd_service *service)
{
	struct source *source;

	DBG("%s", device_get_path(dev->btd_dev));

	source = g_new0(struct source, 1);

	source->dev = dev;
	source->service = btd_service_ref(service);

	source->avdtp_callback_id = avdtp_add_state_cb(dev,
							avdtp_state_callback);

	return source;
}
Пример #3
0
int sink_init(struct btd_service *service)
{
	struct btd_device *dev = btd_service_get_device(service);
	struct sink *sink;

	DBG("%s", device_get_path(dev));

	sink = g_new0(struct sink, 1);

	sink->service = btd_service_ref(service);

	sink->avdtp_callback_id = avdtp_add_state_cb(dev, avdtp_state_callback,
									sink);

	btd_service_set_user_data(service, sink);

	return 0;
}
Пример #4
0
struct audio_device *audio_device_register(struct btd_device *device)
{
	struct audio_device *dev;

	DBG("%s", device_get_path(device));

	dev = g_new0(struct audio_device, 1);

	dev->btd_dev = btd_device_ref(device);
	dev->priv = g_new0(struct dev_priv, 1);
	dev->priv->state = AUDIO_STATE_DISCONNECTED;

	if (sink_callback_id == 0)
		sink_callback_id = sink_add_state_cb(device_sink_cb, NULL);

	if (avdtp_callback_id == 0)
		avdtp_callback_id = avdtp_add_state_cb(device_avdtp_cb, NULL);
	if (avctp_callback_id == 0)
		avctp_callback_id = avctp_add_state_cb(device_avctp_cb, NULL);

	return dev;
}
Пример #5
0
struct sink *sink_init(struct audio_device *dev)
{
	struct sink *sink;

	if (!g_dbus_register_interface(dev->conn, dev->path,
					AUDIO_SINK_INTERFACE,
					sink_methods, sink_signals, NULL,
					dev, path_unregister))
		return NULL;

	DBG("Registered interface %s on path %s",
		AUDIO_SINK_INTERFACE, dev->path);

	if (avdtp_callback_id == 0)
		avdtp_callback_id = avdtp_add_state_cb(avdtp_state_callback,
									NULL);

	sink = g_new0(struct sink, 1);

	sink->dev = dev;

	return sink;
}
Пример #6
0
struct source *source_init(struct audio_device *dev)
{
	struct source *source;

	if (!g_dbus_register_interface(dev->conn, dev->path,
					AUDIO_SOURCE_INTERFACE,
					source_methods, source_signals, NULL,
					dev, path_unregister))
		return NULL;

	debug("Registered interface %s on path %s",
		AUDIO_SOURCE_INTERFACE, dev->path);

	if (avdtp_callback_id == 0)
		avdtp_callback_id = avdtp_add_state_cb(avdtp_state_callback,
									NULL);

	source = g_new0(struct source, 1);

	source->dev = dev;

	return source;
}