summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2007-05-26 21:12:20 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2007-05-26 21:12:20 +0000
commite343f2b21a2209d5713e20ad38bbcc862897380b (patch)
tree9a3fc2f20d11d1886de65b352bffa2f9f73ab72d
parentd2d76421ad539e2c6da87e4b4fd2a42493053f49 (diff)
Move more common stuff to ipc.h
-rw-r--r--audio/ctl_bluetooth.c11
-rw-r--r--audio/ipc.h6
-rw-r--r--audio/pcm_bluetooth.c11
-rw-r--r--audio/unix.c4
4 files changed, 12 insertions, 20 deletions
diff --git a/audio/ctl_bluetooth.c b/audio/ctl_bluetooth.c
index bcc37659..4d73c788 100644
--- a/audio/ctl_bluetooth.c
+++ b/audio/ctl_bluetooth.c
@@ -31,14 +31,10 @@
#include <alsa/asoundlib.h>
#include <alsa/control_external.h>
-#ifndef UNIX_PATH_MAX
-#define UNIX_PATH_MAX 108
-#endif
+#include "ipc.h"
#define DBG(fmt, arg...) printf("DEBUG: %s: " fmt "\n" , __FUNCTION__ , ## arg)
-#define SOCKET_NAME "/org/bluez/audio"
-
#define BLUETOOTH_MINVOL 0
#define BLUETOOTH_MAXVOL 15
@@ -220,7 +216,8 @@ SND_CTL_PLUGIN_DEFINE_FUNC(bluetooth)
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
- snprintf(addr.sun_path + 1, UNIX_PATH_MAX - 2, "%s/%d", SOCKET_NAME, id);
+ snprintf(addr.sun_path + 1, UNIX_PATH_MAX - 2, "%s/%d",
+ IPC_SOCKET_NAME, id);
if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
SNDERR("Can't bind socket");
@@ -230,7 +227,7 @@ SND_CTL_PLUGIN_DEFINE_FUNC(bluetooth)
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
- snprintf(addr.sun_path + 1, UNIX_PATH_MAX - 2, "%s", SOCKET_NAME);
+ snprintf(addr.sun_path + 1, UNIX_PATH_MAX - 2, "%s", IPC_SOCKET_NAME);
if (connect(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
SNDERR("Can't connect socket");
diff --git a/audio/ipc.h b/audio/ipc.h
index 8de85531..038ec4d9 100644
--- a/audio/ipc.h
+++ b/audio/ipc.h
@@ -25,7 +25,11 @@
#define IPC_TYPE_CONNECT 0x0001
-#define IPC_SOCKET_NAME "/org/bluez/audio"
+#define IPC_SOCKET_NAME "\0/org/bluez/audio"
+
+#ifndef UNIX_PATH_MAX
+#define UNIX_PATH_MAX 108
+#endif
struct ipc_hdr {
uint16_t id;
diff --git a/audio/pcm_bluetooth.c b/audio/pcm_bluetooth.c
index d3e457ae..838dcd39 100644
--- a/audio/pcm_bluetooth.c
+++ b/audio/pcm_bluetooth.c
@@ -33,14 +33,8 @@
#include "ipc.h"
-#ifndef UNIX_PATH_MAX
-#define UNIX_PATH_MAX 108
-#endif
-
#define DBG(fmt, arg...) printf("DEBUG: %s: " fmt "\n" , __FUNCTION__ , ## arg)
-#define SOCKET_NAME "/org/bluez/audio"
-
struct bluetooth_data {
snd_pcm_ioplug_t io;
snd_pcm_sframes_t hw_ptr;
@@ -198,7 +192,8 @@ SND_PCM_PLUGIN_DEFINE_FUNC(bluetooth)
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
- snprintf(addr.sun_path + 1, UNIX_PATH_MAX - 2, "%s/%d", SOCKET_NAME, id);
+ snprintf(addr.sun_path + 1, UNIX_PATH_MAX - 2, "%s/%d",
+ IPC_SOCKET_NAME, id);
if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
SNDERR("Can't bind socket");
@@ -208,7 +203,7 @@ SND_PCM_PLUGIN_DEFINE_FUNC(bluetooth)
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
- snprintf(addr.sun_path + 1, UNIX_PATH_MAX - 2, "%s", SOCKET_NAME);
+ snprintf(addr.sun_path + 1, UNIX_PATH_MAX - 2, "%s", IPC_SOCKET_NAME);
if (connect(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
SNDERR("Can't connect socket");
diff --git a/audio/unix.c b/audio/unix.c
index 4f99e5e4..ce2041b2 100644
--- a/audio/unix.c
+++ b/audio/unix.c
@@ -42,10 +42,6 @@
#include "ipc.h"
#include "unix.h"
-#ifndef UNIX_PATH_MAX
-#define UNIX_PATH_MAX 108
-#endif
-
static int unix_sock = -1;
static gboolean unix_event(GIOChannel *chan, GIOCondition cond, gpointer data)