mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	Refactor all linked lists to use pulsecore/llist.h
This commit is contained in:
		
							parent
							
								
									d893a1ff53
								
							
						
					
					
						commit
						1e03c323ca
					
				
					 1 changed files with 74 additions and 81 deletions
				
			
		| 
						 | 
					@ -29,6 +29,7 @@
 | 
				
			||||||
#include <pulsecore/module.h>
 | 
					#include <pulsecore/module.h>
 | 
				
			||||||
#include <pulsecore/modargs.h>
 | 
					#include <pulsecore/modargs.h>
 | 
				
			||||||
#include <pulsecore/macro.h>
 | 
					#include <pulsecore/macro.h>
 | 
				
			||||||
 | 
					#include <pulsecore/llist.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "dbus-util.h"
 | 
					#include "dbus-util.h"
 | 
				
			||||||
#include "module-bt-discover-symdef.h"
 | 
					#include "module-bt-discover-symdef.h"
 | 
				
			||||||
| 
						 | 
					@ -43,95 +44,100 @@ PA_MODULE_USAGE("");
 | 
				
			||||||
#define A2DP_SOURCE_UUID        "0000110A-0000-1000-8000-00805F9B34FB"
 | 
					#define A2DP_SOURCE_UUID        "0000110A-0000-1000-8000-00805F9B34FB"
 | 
				
			||||||
#define A2DP_SINK_UUID          "0000110B-0000-1000-8000-00805F9B34FB"
 | 
					#define A2DP_SINK_UUID          "0000110B-0000-1000-8000-00805F9B34FB"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct adapter adapter_t;
 | 
					 | 
				
			||||||
typedef struct device device_t;
 | 
					 | 
				
			||||||
typedef struct uuid uuid_t;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct uuid {
 | 
					struct uuid {
 | 
				
			||||||
    char *uuid;
 | 
					    char *uuid;
 | 
				
			||||||
    uuid_t *next;
 | 
					    PA_LLIST_FIELDS(struct uuid);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct device {
 | 
					struct device {
 | 
				
			||||||
    char *name;
 | 
					    char *name;
 | 
				
			||||||
    char *object_path;
 | 
					    char *object_path;
 | 
				
			||||||
    int paired;
 | 
					    int paired;
 | 
				
			||||||
    adapter_t *adapter;
 | 
					    struct adapter *adapter;
 | 
				
			||||||
    char *alias;
 | 
					    char *alias;
 | 
				
			||||||
    int connected;
 | 
					    int connected;
 | 
				
			||||||
    uuid_t *uuid_list;
 | 
					    PA_LLIST_HEAD(struct uuid, uuid_list);
 | 
				
			||||||
    char *address;
 | 
					    char *address;
 | 
				
			||||||
    int class;
 | 
					    int class;
 | 
				
			||||||
    int trusted;
 | 
					    int trusted;
 | 
				
			||||||
    device_t *next;
 | 
					    PA_LLIST_FIELDS(struct device);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct adapter {
 | 
					struct adapter {
 | 
				
			||||||
    char *object_path;
 | 
					    char *object_path;
 | 
				
			||||||
    char *mode;
 | 
					    char *mode;
 | 
				
			||||||
    char *address;
 | 
					    char *address;
 | 
				
			||||||
    device_t *device_list;
 | 
					    PA_LLIST_HEAD(struct device, device_list);
 | 
				
			||||||
    adapter_t *next;
 | 
					    PA_LLIST_FIELDS(struct adapter);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct userdata {
 | 
					struct userdata {
 | 
				
			||||||
    pa_module *module;
 | 
					    pa_module *module;
 | 
				
			||||||
    pa_dbus_connection *conn;
 | 
					    pa_dbus_connection *conn;
 | 
				
			||||||
    adapter_t *adapter_list;
 | 
					    PA_LLIST_HEAD(struct adapter, adapter_list);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static uuid_t *uuid_new(const char *uuid) {
 | 
					static struct uuid *uuid_new(const char *uuid) {
 | 
				
			||||||
    uuid_t *node = pa_xnew0(uuid_t, 1);
 | 
					    struct uuid *node = pa_xnew(struct uuid, 1);
 | 
				
			||||||
    node->uuid = pa_xstrdup(uuid);
 | 
					    node->uuid = pa_xstrdup(uuid);
 | 
				
			||||||
    node->next = NULL;
 | 
					    PA_LLIST_INIT(struct uuid, node);
 | 
				
			||||||
    return node;
 | 
					    return node;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void uuid_list_append(uuid_t *node, const char *uuid) {
 | 
					static void uuid_free(struct uuid *uuid) {
 | 
				
			||||||
    while (node->next != NULL) node = node->next;
 | 
					    pa_xfree(uuid);
 | 
				
			||||||
    node->next = uuid_new(uuid);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static device_t *device_new(const char *device, adapter_t *adapter) {
 | 
					static struct device *device_new(const char *device, struct adapter *adapter) {
 | 
				
			||||||
    device_t *node = pa_xnew0(device_t, 1);
 | 
					    struct device *node = pa_xnew(struct device, 1);
 | 
				
			||||||
    node->name = NULL;
 | 
					    node->name = NULL;
 | 
				
			||||||
    node->object_path = pa_xstrdup(device);
 | 
					    node->object_path = pa_xstrdup(device);
 | 
				
			||||||
    node->paired = -1;
 | 
					    node->paired = -1;
 | 
				
			||||||
    node->adapter = adapter;
 | 
					    node->adapter = adapter;
 | 
				
			||||||
    node->alias = NULL;
 | 
					    node->alias = NULL;
 | 
				
			||||||
    node->connected = -1;
 | 
					    node->connected = -1;
 | 
				
			||||||
    node->uuid_list = uuid_new("UUID_HEAD");
 | 
					    PA_LLIST_HEAD_INIT(struct uuid, node->uuid_list);
 | 
				
			||||||
    node->address = NULL;
 | 
					    node->address = NULL;
 | 
				
			||||||
    node->class = -1;
 | 
					    node->class = -1;
 | 
				
			||||||
    node->trusted = -1;
 | 
					    node->trusted = -1;
 | 
				
			||||||
    node->next = NULL;
 | 
					    PA_LLIST_INIT(struct device, node);
 | 
				
			||||||
    return node;
 | 
					    return node;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void device_list_append(device_t *node, const char *device, adapter_t *adapter) {
 | 
					static void device_free(struct device *device) {
 | 
				
			||||||
    while (node->next != NULL) node = node->next;
 | 
					    struct uuid *uuid_list_i;
 | 
				
			||||||
    node->next = device_new(device, adapter);
 | 
					    while (device->uuid_list) {
 | 
				
			||||||
 | 
					        uuid_list_i = device->uuid_list;
 | 
				
			||||||
 | 
					        PA_LLIST_REMOVE(struct uuid, device->uuid_list, uuid_list_i);
 | 
				
			||||||
 | 
					        uuid_free(uuid_list_i);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    pa_xfree(device);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static adapter_t *adapter_new(const char *adapter) {
 | 
					static struct adapter *adapter_new(const char *adapter) {
 | 
				
			||||||
    adapter_t *node = pa_xnew0(adapter_t, 1);
 | 
					    struct adapter *node = pa_xnew(struct adapter, 1);
 | 
				
			||||||
    node->object_path = pa_xstrdup(adapter);
 | 
					    node->object_path = pa_xstrdup(adapter);
 | 
				
			||||||
    node->mode = NULL;
 | 
					    node->mode = NULL;
 | 
				
			||||||
    node->address = NULL;
 | 
					    node->address = NULL;
 | 
				
			||||||
    node->device_list = device_new("/DEVICE_HEAD", NULL);
 | 
					    PA_LLIST_HEAD_INIT(struct device, node->device_list);
 | 
				
			||||||
    node->next = NULL;
 | 
					    PA_LLIST_INIT(struct adapter, node);
 | 
				
			||||||
    return node;
 | 
					    return node;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void adapter_list_append(adapter_t *node, const char *adapter) {
 | 
					static void adapter_free(struct adapter *adapter) {
 | 
				
			||||||
    while (node->next != NULL) node = node->next;
 | 
					    struct device *device_list_i;
 | 
				
			||||||
    node->next = adapter_new(adapter);
 | 
					    while (adapter->device_list) {
 | 
				
			||||||
 | 
					        device_list_i = adapter->device_list;
 | 
				
			||||||
 | 
					        PA_LLIST_REMOVE(struct device, adapter->device_list, device_list_i);
 | 
				
			||||||
 | 
					        device_free(device_list_i);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    pa_xfree(adapter);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void print_devices(device_t *device_list) {
 | 
					static void print_devices(struct device *device_list) {
 | 
				
			||||||
    device_t *device_list_i = device_list;
 | 
					    struct device *device_list_i = device_list;
 | 
				
			||||||
    while (device_list_i != NULL) {
 | 
					    while (device_list_i != NULL) {
 | 
				
			||||||
        uuid_t *uuid_list_i = device_list_i->uuid_list;
 | 
					        struct uuid *uuid_list_i = device_list_i->uuid_list;
 | 
				
			||||||
        if (strcmp(device_list_i->object_path, "/DEVICE_HEAD") != 0) {
 | 
					        if (strcmp(device_list_i->object_path, "/DEVICE_HEAD") != 0) {
 | 
				
			||||||
            pa_log("    [ %s ]", device_list_i->object_path);
 | 
					            pa_log("    [ %s ]", device_list_i->object_path);
 | 
				
			||||||
            pa_log("        Name = %s", device_list_i->name);
 | 
					            pa_log("        Name = %s", device_list_i->name);
 | 
				
			||||||
| 
						 | 
					@ -153,8 +159,8 @@ static void print_devices(device_t *device_list) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void print_adapters(adapter_t *adapter_list) {
 | 
					static void print_adapters(struct adapter *adapter_list) {
 | 
				
			||||||
    adapter_t *adapter_list_i = adapter_list;
 | 
					    struct adapter *adapter_list_i = adapter_list;
 | 
				
			||||||
    while (adapter_list_i != NULL) {
 | 
					    while (adapter_list_i != NULL) {
 | 
				
			||||||
        if (strcmp(adapter_list_i->object_path, "/ADAPTER_HEAD") != 0) {
 | 
					        if (strcmp(adapter_list_i->object_path, "/ADAPTER_HEAD") != 0) {
 | 
				
			||||||
            pa_log("[ %s ]", adapter_list_i->object_path);
 | 
					            pa_log("[ %s ]", adapter_list_i->object_path);
 | 
				
			||||||
| 
						 | 
					@ -170,7 +176,7 @@ static void detect_adapters(struct userdata *u) {
 | 
				
			||||||
    DBusError e;
 | 
					    DBusError e;
 | 
				
			||||||
    DBusMessage *m = NULL, *r = NULL;
 | 
					    DBusMessage *m = NULL, *r = NULL;
 | 
				
			||||||
    DBusMessageIter arg_i, element_i, dict_i, variant_i;
 | 
					    DBusMessageIter arg_i, element_i, dict_i, variant_i;
 | 
				
			||||||
    adapter_t *adapter_list_i;
 | 
					    struct adapter *adapter_list_i;
 | 
				
			||||||
    const char *key, *value;
 | 
					    const char *key, *value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_assert(u);
 | 
					    pa_assert(u);
 | 
				
			||||||
| 
						 | 
					@ -192,18 +198,18 @@ static void detect_adapters(struct userdata *u) {
 | 
				
			||||||
        goto fail;
 | 
					        goto fail;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    dbus_message_iter_recurse(&arg_i, &element_i);
 | 
					    dbus_message_iter_recurse(&arg_i, &element_i);
 | 
				
			||||||
    /* TODO: Review error checking
 | 
					 | 
				
			||||||
     * should this be changed to while (dbus_message_iter_get_arg_type(&element_i) == DBUS_TYPE_OBJECT_PATH) ? */
 | 
					 | 
				
			||||||
    while (dbus_message_iter_get_arg_type(&element_i) != DBUS_TYPE_INVALID) {
 | 
					    while (dbus_message_iter_get_arg_type(&element_i) != DBUS_TYPE_INVALID) {
 | 
				
			||||||
        if (dbus_message_iter_get_arg_type(&element_i) == DBUS_TYPE_OBJECT_PATH) {
 | 
					        if (dbus_message_iter_get_arg_type(&element_i) == DBUS_TYPE_OBJECT_PATH) {
 | 
				
			||||||
 | 
					            struct adapter *node;
 | 
				
			||||||
            dbus_message_iter_get_basic(&element_i, &value);
 | 
					            dbus_message_iter_get_basic(&element_i, &value);
 | 
				
			||||||
            adapter_list_append(u->adapter_list, value);
 | 
					            node = adapter_new(value);
 | 
				
			||||||
 | 
					            PA_LLIST_PREPEND(struct adapter, u->adapter_list, node);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        dbus_message_iter_next(&element_i);
 | 
					        dbus_message_iter_next(&element_i);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* get adapter properties */
 | 
					    /* get adapter properties */
 | 
				
			||||||
    adapter_list_i = u->adapter_list->next;
 | 
					    adapter_list_i = u->adapter_list;
 | 
				
			||||||
    while (adapter_list_i != NULL) {
 | 
					    while (adapter_list_i != NULL) {
 | 
				
			||||||
        pa_assert_se(m = dbus_message_new_method_call("org.bluez", adapter_list_i->object_path, "org.bluez.Adapter", "GetProperties"));
 | 
					        pa_assert_se(m = dbus_message_new_method_call("org.bluez", adapter_list_i->object_path, "org.bluez.Adapter", "GetProperties"));
 | 
				
			||||||
        r = dbus_connection_send_with_reply_and_block(pa_dbus_connection_get(u->conn), m, -1, &e);
 | 
					        r = dbus_connection_send_with_reply_and_block(pa_dbus_connection_get(u->conn), m, -1, &e);
 | 
				
			||||||
| 
						 | 
					@ -249,8 +255,8 @@ static void detect_devices(struct userdata *u) {
 | 
				
			||||||
    DBusError e;
 | 
					    DBusError e;
 | 
				
			||||||
    DBusMessage *m = NULL, *r = NULL;
 | 
					    DBusMessage *m = NULL, *r = NULL;
 | 
				
			||||||
    DBusMessageIter arg_i, element_i, dict_i, variant_i;
 | 
					    DBusMessageIter arg_i, element_i, dict_i, variant_i;
 | 
				
			||||||
    adapter_t *adapter_list_i;
 | 
					    struct adapter *adapter_list_i;
 | 
				
			||||||
    device_t *device_list_i, *device_list_prev_i;
 | 
					    struct device *device_list_i;
 | 
				
			||||||
    const char *key, *value;
 | 
					    const char *key, *value;
 | 
				
			||||||
    unsigned int uvalue;
 | 
					    unsigned int uvalue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -258,7 +264,7 @@ static void detect_devices(struct userdata *u) {
 | 
				
			||||||
    dbus_error_init(&e);
 | 
					    dbus_error_init(&e);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* get devices of each adapter */
 | 
					    /* get devices of each adapter */
 | 
				
			||||||
    adapter_list_i = u->adapter_list->next;
 | 
					    adapter_list_i = u->adapter_list;
 | 
				
			||||||
    while (adapter_list_i != NULL) {
 | 
					    while (adapter_list_i != NULL) {
 | 
				
			||||||
        pa_assert_se(m = dbus_message_new_method_call("org.bluez", adapter_list_i->object_path, "org.bluez.Adapter", "ListDevices"));
 | 
					        pa_assert_se(m = dbus_message_new_method_call("org.bluez", adapter_list_i->object_path, "org.bluez.Adapter", "ListDevices"));
 | 
				
			||||||
        r = dbus_connection_send_with_reply_and_block(pa_dbus_connection_get(u->conn), m, -1, &e);
 | 
					        r = dbus_connection_send_with_reply_and_block(pa_dbus_connection_get(u->conn), m, -1, &e);
 | 
				
			||||||
| 
						 | 
					@ -275,12 +281,12 @@ static void detect_devices(struct userdata *u) {
 | 
				
			||||||
            goto fail;
 | 
					            goto fail;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        dbus_message_iter_recurse(&arg_i, &element_i);
 | 
					        dbus_message_iter_recurse(&arg_i, &element_i);
 | 
				
			||||||
        /* TODO: Review error checking
 | 
					 | 
				
			||||||
         * should this be changed to while (dbus_message_iter_get_arg_type(&element_i) == DBUS_TYPE_OBJECT_PATH) ? */
 | 
					 | 
				
			||||||
        while (dbus_message_iter_get_arg_type(&element_i) != DBUS_TYPE_INVALID) {
 | 
					        while (dbus_message_iter_get_arg_type(&element_i) != DBUS_TYPE_INVALID) {
 | 
				
			||||||
            if (dbus_message_iter_get_arg_type(&element_i) == DBUS_TYPE_OBJECT_PATH) {
 | 
					            if (dbus_message_iter_get_arg_type(&element_i) == DBUS_TYPE_OBJECT_PATH) {
 | 
				
			||||||
 | 
					                struct device *node;
 | 
				
			||||||
                dbus_message_iter_get_basic(&element_i, &value);
 | 
					                dbus_message_iter_get_basic(&element_i, &value);
 | 
				
			||||||
                device_list_append(adapter_list_i->device_list, value, adapter_list_i);
 | 
					                node = device_new(value, adapter_list_i);
 | 
				
			||||||
 | 
					                PA_LLIST_PREPEND(struct device, adapter_list_i->device_list, node);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            dbus_message_iter_next(&element_i);
 | 
					            dbus_message_iter_next(&element_i);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -288,10 +294,9 @@ static void detect_devices(struct userdata *u) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* get device properties */
 | 
					    /* get device properties */
 | 
				
			||||||
    adapter_list_i = u->adapter_list->next;
 | 
					    adapter_list_i = u->adapter_list;
 | 
				
			||||||
    while (adapter_list_i != NULL) {
 | 
					    while (adapter_list_i != NULL) {
 | 
				
			||||||
        device_list_prev_i = adapter_list_i->device_list;
 | 
					        device_list_i = adapter_list_i->device_list;
 | 
				
			||||||
        device_list_i = adapter_list_i->device_list->next;
 | 
					 | 
				
			||||||
        while (device_list_i != NULL) {
 | 
					        while (device_list_i != NULL) {
 | 
				
			||||||
            pa_assert_se(m = dbus_message_new_method_call("org.bluez", device_list_i->object_path, "org.bluez.Device", "GetProperties"));
 | 
					            pa_assert_se(m = dbus_message_new_method_call("org.bluez", device_list_i->object_path, "org.bluez.Device", "GetProperties"));
 | 
				
			||||||
            r = dbus_connection_send_with_reply_and_block(pa_dbus_connection_get(u->conn), m, -1, &e);
 | 
					            r = dbus_connection_send_with_reply_and_block(pa_dbus_connection_get(u->conn), m, -1, &e);
 | 
				
			||||||
| 
						 | 
					@ -335,16 +340,18 @@ static void detect_devices(struct userdata *u) {
 | 
				
			||||||
                        pa_bool_t is_audio_device = FALSE;
 | 
					                        pa_bool_t is_audio_device = FALSE;
 | 
				
			||||||
                        dbus_message_iter_recurse(&variant_i, &uuid_i);
 | 
					                        dbus_message_iter_recurse(&variant_i, &uuid_i);
 | 
				
			||||||
                        while (dbus_message_iter_get_arg_type(&uuid_i) != DBUS_TYPE_INVALID) {
 | 
					                        while (dbus_message_iter_get_arg_type(&uuid_i) != DBUS_TYPE_INVALID) {
 | 
				
			||||||
 | 
					                            struct uuid *node;
 | 
				
			||||||
                            dbus_message_iter_get_basic(&uuid_i, &value);
 | 
					                            dbus_message_iter_get_basic(&uuid_i, &value);
 | 
				
			||||||
 | 
					                            node = uuid_new(value);
 | 
				
			||||||
 | 
					                            PA_LLIST_PREPEND(struct uuid, device_list_i->uuid_list, node);
 | 
				
			||||||
                            if ( (strcasecmp(value, HSP_HS_UUID) == 0) || (strcasecmp(value, HFP_HS_UUID) == 0) ||
 | 
					                            if ( (strcasecmp(value, HSP_HS_UUID) == 0) || (strcasecmp(value, HFP_HS_UUID) == 0) ||
 | 
				
			||||||
                                (strcasecmp(value, A2DP_SOURCE_UUID) == 0) || (strcasecmp(value, A2DP_SINK_UUID) == 0) )
 | 
					                                (strcasecmp(value, A2DP_SOURCE_UUID) == 0) || (strcasecmp(value, A2DP_SINK_UUID) == 0) )
 | 
				
			||||||
                                is_audio_device = TRUE;
 | 
					                                is_audio_device = TRUE;
 | 
				
			||||||
                            uuid_list_append(device_list_i->uuid_list, value);
 | 
					 | 
				
			||||||
                            dbus_message_iter_next(&uuid_i);
 | 
					                            dbus_message_iter_next(&uuid_i);
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        if (!is_audio_device) {
 | 
					                        if (!is_audio_device) {
 | 
				
			||||||
                            /* remove current device */
 | 
					                            /* remove the current device from the list */
 | 
				
			||||||
                            device_list_prev_i->next = device_list_i->next;
 | 
					                            PA_LLIST_REMOVE(struct device, adapter_list_i->device_list, device_list_i);
 | 
				
			||||||
                            pa_xfree(device_list_i);
 | 
					                            pa_xfree(device_list_i);
 | 
				
			||||||
                            break;
 | 
					                            break;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
| 
						 | 
					@ -364,11 +371,7 @@ static void detect_devices(struct userdata *u) {
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                dbus_message_iter_next(&element_i);
 | 
					                dbus_message_iter_next(&element_i);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            device_list_prev_i = device_list_prev_i->next;
 | 
					            device_list_i = device_list_i->next;
 | 
				
			||||||
            if (device_list_prev_i == NULL)
 | 
					 | 
				
			||||||
                device_list_i = NULL;
 | 
					 | 
				
			||||||
            else
 | 
					 | 
				
			||||||
                device_list_i = device_list_prev_i->next;
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        adapter_list_i = adapter_list_i->next;
 | 
					        adapter_list_i = adapter_list_i->next;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -445,27 +448,17 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *msg, void *
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void pa__done(pa_module* m) {
 | 
					void pa__done(pa_module* m) {
 | 
				
			||||||
    struct userdata *u;
 | 
					    struct userdata *u;
 | 
				
			||||||
    adapter_t *adapter_list_i, *adapter_list_next_i;
 | 
					    struct adapter *adapter_list_i;
 | 
				
			||||||
    device_t *device_list_i, *device_list_next_i;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_assert(m);
 | 
					    pa_assert(m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!(u = m->userdata))
 | 
					    if (!(u = m->userdata))
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ((adapter_list_i = u->adapter_list) != NULL) {
 | 
					    while (u->adapter_list) {
 | 
				
			||||||
        while ((adapter_list_next_i = adapter_list_i->next) != NULL) {
 | 
					        adapter_list_i = u->adapter_list;
 | 
				
			||||||
            if ((device_list_i = adapter_list_i->device_list) != NULL) {
 | 
					        PA_LLIST_REMOVE(struct adapter, u->adapter_list, adapter_list_i);
 | 
				
			||||||
                while ((device_list_next_i = device_list_i->next) != NULL) {
 | 
					        adapter_free(adapter_list_i);
 | 
				
			||||||
                    pa_xfree(device_list_i);
 | 
					 | 
				
			||||||
                    device_list_i = device_list_next_i;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                pa_xfree(device_list_i);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            pa_xfree(adapter_list_i);
 | 
					 | 
				
			||||||
            adapter_list_i = adapter_list_next_i;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        pa_xfree(adapter_list_i);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_dbus_connection_unref(u->conn);
 | 
					    pa_dbus_connection_unref(u->conn);
 | 
				
			||||||
| 
						 | 
					@ -477,15 +470,16 @@ void pa__done(pa_module* m) {
 | 
				
			||||||
int pa__init(pa_module* m) {
 | 
					int pa__init(pa_module* m) {
 | 
				
			||||||
    pa_modargs *ma = NULL;
 | 
					    pa_modargs *ma = NULL;
 | 
				
			||||||
    DBusError err;
 | 
					    DBusError err;
 | 
				
			||||||
    adapter_t *adapter_list_i;
 | 
					    struct adapter *adapter_list_i;
 | 
				
			||||||
    device_t *device_list_i;
 | 
					    struct device *device_list_i;
 | 
				
			||||||
    struct userdata *u;
 | 
					    struct userdata *u;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_assert(m);
 | 
					    pa_assert(m);
 | 
				
			||||||
    dbus_error_init(&err);
 | 
					 | 
				
			||||||
    pa_log("Loading module-bt-discover");
 | 
					    pa_log("Loading module-bt-discover");
 | 
				
			||||||
 | 
					    dbus_error_init(&err);
 | 
				
			||||||
    m->userdata = u = pa_xnew0(struct userdata, 1);
 | 
					    m->userdata = u = pa_xnew0(struct userdata, 1);
 | 
				
			||||||
    u->module = m;
 | 
					    u->module = m;
 | 
				
			||||||
 | 
					    PA_LLIST_HEAD_INIT(struct adapter, u->adapter_list);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* connect to the bus */
 | 
					    /* connect to the bus */
 | 
				
			||||||
    u->conn = pa_dbus_bus_get(m->core, DBUS_BUS_SYSTEM, &err);
 | 
					    u->conn = pa_dbus_bus_get(m->core, DBUS_BUS_SYSTEM, &err);
 | 
				
			||||||
| 
						 | 
					@ -495,19 +489,18 @@ int pa__init(pa_module* m) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* static detection of bluetooth audio devices */
 | 
					    /* static detection of bluetooth audio devices */
 | 
				
			||||||
    u->adapter_list = adapter_new("/ADAPTER_HEAD");
 | 
					 | 
				
			||||||
    detect_adapters(u);
 | 
					    detect_adapters(u);
 | 
				
			||||||
    detect_devices(u);
 | 
					    detect_devices(u);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    print_adapters(u->adapter_list);
 | 
					    print_adapters(u->adapter_list);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* load device modules */
 | 
					    /* load device modules */
 | 
				
			||||||
    adapter_list_i = u->adapter_list->next;
 | 
					    adapter_list_i = u->adapter_list;
 | 
				
			||||||
    while (adapter_list_i != NULL) {
 | 
					    while (adapter_list_i != NULL) {
 | 
				
			||||||
        device_list_i = adapter_list_i->device_list->next;
 | 
					        device_list_i = adapter_list_i->device_list;
 | 
				
			||||||
        while (device_list_i != NULL) {
 | 
					        while (device_list_i != NULL) {
 | 
				
			||||||
            pa_log("Loading module-bt-device for %s", device_list_i->name); /* CHECK: Should it be name or alias? */
 | 
					            pa_log("Loading module-bt-device for %s", device_list_i->name);
 | 
				
			||||||
            /* call module */
 | 
					            /* TODO: call module */
 | 
				
			||||||
            device_list_i = device_list_i->next;
 | 
					            device_list_i = device_list_i->next;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        adapter_list_i = adapter_list_i->next;
 | 
					        adapter_list_i = adapter_list_i->next;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue