Move more common stuff to ipc.h

This commit is contained in:
Johan Hedberg 2007-05-26 21:12:20 +00:00
parent d2d76421ad
commit e343f2b21a
4 changed files with 12 additions and 20 deletions

View File

@ -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");

View File

@ -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;

View File

@ -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");

View File

@ -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)