summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--audio/device.c2
-rw-r--r--audio/manager.c35
-rw-r--r--audio/pcm_bluetooth.c11
-rw-r--r--audio/unix.c1
4 files changed, 33 insertions, 16 deletions
diff --git a/audio/device.c b/audio/device.c
index 785d0115..884a2661 100644
--- a/audio/device.c
+++ b/audio/device.c
@@ -186,7 +186,7 @@ int device_store(struct device *device, gboolean is_default)
if (is_default)
textfile_put(filename, "default", dst_addr);
if (device->headset)
- snprintf(value, 64, "headset");
+ snprintf(value, 64, "headset#%d", headset_get_channel(device));
else if (device->gateway)
snprintf(value, 64, "gateway");
else if (device->sink)
diff --git a/audio/manager.c b/audio/manager.c
index 0ea8a99b..8ca57100 100644
--- a/audio/manager.c
+++ b/audio/manager.c
@@ -31,7 +31,6 @@
#include <errno.h>
#include <unistd.h>
#include <stdint.h>
-#include <assert.h>
#include <sys/stat.h>
#include <dirent.h>
#include <ctype.h>
@@ -187,7 +186,7 @@ static void handle_record(sdp_record_t *record, struct device *device)
headset_update(device, record, uuid16);
else
device->headset = headset_init(device,
- record, uuid16);
+ record, uuid16, -1);
break;
case HEADSET_AGW_SVCLASS_ID:
debug("Found Headset AG record");
@@ -198,7 +197,7 @@ static void handle_record(sdp_record_t *record, struct device *device)
headset_update(device, record, uuid16);
else
device->headset = headset_init(device,
- record, uuid16);
+ record, uuid16, -1);
break;
case HANDSFREE_AGW_SVCLASS_ID:
debug("Found Handsfree AG record");
@@ -638,7 +637,7 @@ struct device *manager_device_connected(bdaddr_t *bda)
}
if (!device->headset)
- device->headset = headset_init(device, NULL, 0);
+ device->headset = headset_init(device, NULL, 0, -1);
if (!device->headset)
return NULL;
@@ -1102,8 +1101,15 @@ static void parse_stored_devices(char *key, char *value, void *data)
if (!device)
return;
- if (strcmp(value, "headset") == 0)
- device->headset = headset_init(device, NULL, 0);
+ if (strncmp(value, "headset", strlen("headset")) == 0) {
+ int channel = -1;
+ char *ptr;
+
+ if ((ptr = strchr(value, '#')))
+ channel = strtol(ptr+1, NULL, 10);
+
+ device->headset = headset_init(device, NULL, 0, channel);
+ }
add_device(device);
}
@@ -1167,10 +1173,21 @@ static void register_stored(void)
closedir(dir);
}
+static void manager_unregister(DBusConnection *conn, void *data)
+{
+ info("Unregistered manager path");
+
+ if (devices) {
+ g_slist_foreach(devices, (GFunc)remove_device, NULL);
+ g_slist_free(devices);
+ devices = NULL;
+ }
+}
+
int audio_init(DBusConnection *conn)
{
if (!dbus_connection_create_object_path(conn, AUDIO_MANAGER_PATH,
- NULL, NULL)) {
+ NULL, manager_unregister)) {
error("D-Bus failed to register %s path", AUDIO_MANAGER_PATH);
return -1;
}
@@ -1197,9 +1214,7 @@ int audio_init(DBusConnection *conn)
void audio_exit(void)
{
- g_slist_foreach(devices, (GFunc) remove_device, NULL);
- g_slist_free(devices);
- devices = NULL;
+ dbus_connection_destroy_object_path(connection, AUDIO_MANAGER_PATH);
dbus_connection_unref(connection);
diff --git a/audio/pcm_bluetooth.c b/audio/pcm_bluetooth.c
index 16c99f06..f95dcc9c 100644
--- a/audio/pcm_bluetooth.c
+++ b/audio/pcm_bluetooth.c
@@ -92,6 +92,9 @@ static void bluetooth_exit(struct bluetooth_data *data)
if (data->sock >= 0)
close(data->sock);
+ if (data->cfg.fd >= 0)
+ close(data->cfg.fd);
+
if (data->buffer)
free(data->buffer);
@@ -196,7 +199,7 @@ static snd_pcm_sframes_t bluetooth_read(snd_pcm_ioplug_t *io,
proceed:
buff = (unsigned char *) areas->addr + (areas->first + areas->step * offset) / 8;
- if ((data->count + cfg.sample_size * size) <= cfg.pkt_len)
+ if ((data->count + size * frame_size) <= cfg.pkt_len)
frames_to_write = size;
else
frames_to_write = (cfg.pkt_len - data->count) / frame_size;
@@ -241,9 +244,9 @@ static snd_pcm_sframes_t bluetooth_write(snd_pcm_ioplug_t *io,
buff = (uint8_t *) areas->addr + (areas->first + areas->step * offset) / 8;
memcpy(data->buffer + data->count, buff, frame_size * frames_to_read);
- if ((data->count + frames_to_read * frame_size) != cfg.pkt_len) {
- /* Remember we have some frame in the pipe now */
- data->count += frames_to_read * frame_size;
+ /* Remember we have some frame in the pipe now */
+ data->count += frames_to_read * frame_size;
+ if (data->count != cfg.pkt_len) {
ret = frames_to_read;
goto done;
}
diff --git a/audio/unix.c b/audio/unix.c
index f17404b4..a4b8f2c4 100644
--- a/audio/unix.c
+++ b/audio/unix.c
@@ -32,7 +32,6 @@
#include <errno.h>
#include <unistd.h>
#include <stdint.h>
-#include <assert.h>
#include <glib.h>