[pulseaudio-discuss] [RFC 4/5] bluetooth: Removed library for IPC to BlueZ

Mikel Astiz mikel.astiz at bmw-carit.de
Wed Nov 16 07:12:17 PST 2011


---
 src/Makefile.am             |   15 +---
 src/modules/bluetooth/ipc.c |  134 -----------------------
 src/modules/bluetooth/ipc.h |  244 +------------------------------------------
 3 files changed, 2 insertions(+), 391 deletions(-)
 delete mode 100644 src/modules/bluetooth/ipc.c

diff --git a/src/Makefile.am b/src/Makefile.am
index 5d63aec..43b0c0c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1197,7 +1197,6 @@ modlibexec_LTLIBRARIES += \
 		libbluetooth-util.la \
 		module-bluetooth-proximity.la \
 		module-bluetooth-discover.la \
-		libbluetooth-ipc.la \
 		libbluetooth-sbc.la \
 		module-bluetooth-device.la
 
@@ -1856,14 +1855,6 @@ libbluetooth_sbc_la_LIBADD = $(MODULE_LIBADD)
 libbluetooth_sbc_la_CFLAGS = $(AM_CFLAGS) -I$(top_srcdir)/src/modules/bluetooth/sbc
 BLUETOOTH_SBC_FILES = $(subst modules/bluetooth/,,$(libbluetooth_sbc_la_SOURCES))
 
-libbluetooth_ipc_la_SOURCES = \
-		modules/bluetooth/a2dp-codecs.h \
-		modules/bluetooth/ipc.c modules/bluetooth/ipc.h
-libbluetooth_ipc_la_LDFLAGS = -avoid-version
-libbluetooth_ipc_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINOR@.la libpulsecommon- at PA_MAJORMINOR@.la libpulse.la
-libbluetooth_ipc_la_CFLAGS = $(AM_CFLAGS)
-BLUETOOTH_IPC_FILES = $(subst modules/bluetooth/,,$(libbluetooth_ipc_la_SOURCES)) rtp.h
-
 libbluetooth_util_la_SOURCES = modules/bluetooth/bluetooth-util.c modules/bluetooth/bluetooth-util.h
 libbluetooth_util_la_LDFLAGS = -avoid-version
 libbluetooth_util_la_LIBADD = $(MODULE_LIBADD) $(DBUS_LIBS)
@@ -1871,7 +1862,7 @@ libbluetooth_util_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
 
 module_bluetooth_device_la_SOURCES = modules/bluetooth/module-bluetooth-device.c modules/bluetooth/rtp.h
 module_bluetooth_device_la_LDFLAGS = $(MODULE_LDFLAGS)
-module_bluetooth_device_la_LIBADD = $(MODULE_LIBADD) $(DBUS_LIBS) libbluetooth-util.la libbluetooth-ipc.la libbluetooth-sbc.la
+module_bluetooth_device_la_LIBADD = $(MODULE_LIBADD) $(DBUS_LIBS) libbluetooth-util.la libbluetooth-sbc.la
 module_bluetooth_device_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS) -I$(top_srcdir)/src/modules/bluetooth/sbc
 
 # Apple Airtunes/RAOP
@@ -1935,10 +1926,6 @@ update-sbc:
 		wget -O /dev/null http://git.kernel.org/\?p=bluetooth/bluez.git\;a=blob_plain\;f=$$i ; \
 		wget -O $(top_srcdir)/src/modules/bluetooth/$$i http://git.kernel.org/\?p=bluetooth/bluez.git\;a=blob_plain\;f=$$i ; \
 	done
-	for i in $(BLUETOOTH_IPC_FILES); do \
-		wget -O /dev/null http://git.kernel.org/\?p=bluetooth/bluez.git\;a=blob_plain\;f=audio/$$i ; \
-		wget -O $(top_srcdir)/src/modules/bluetooth/$$i http://git.kernel.org/\?p=bluetooth/bluez.git\;a=blob_plain\;f=audio/$$i ; \
-	done
 
 update-reserve:
 	for i in reserve.c reserve.h reserve-monitor.c reserve-monitor.h ; do \
diff --git a/src/modules/bluetooth/ipc.c b/src/modules/bluetooth/ipc.c
deleted file mode 100644
index 669eeef..0000000
--- a/src/modules/bluetooth/ipc.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- *
- *  BlueZ - Bluetooth protocol stack for Linux
- *
- *  Copyright (C) 2004-2010  Marcel Holtmann <marcel at holtmann.org>
- *
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License as published by the Free Software Foundation; either
- *  version 2.1 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
- */
-
-#include "ipc.h"
-
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
-
-/* This table contains the string representation for messages types */
-static const char *strtypes[] = {
-	"BT_REQUEST",
-	"BT_RESPONSE",
-	"BT_INDICATION",
-	"BT_ERROR",
-};
-
-/* This table contains the string representation for messages names */
-static const char *strnames[] = {
-	"BT_GET_CAPABILITIES",
-	"BT_OPEN",
-	"BT_SET_CONFIGURATION",
-	"BT_NEW_STREAM",
-	"BT_START_STREAM",
-	"BT_STOP_STREAM",
-	"BT_SUSPEND_STREAM",
-	"BT_RESUME_STREAM",
-	"BT_CONTROL",
-};
-
-int bt_audio_service_open(void)
-{
-	int sk;
-	int err;
-	struct sockaddr_un addr = {
-		AF_UNIX, BT_IPC_SOCKET_NAME
-	};
-
-	sk = socket(PF_LOCAL, SOCK_STREAM, 0);
-	if (sk < 0) {
-		err = errno;
-		fprintf(stderr, "%s: Cannot open socket: %s (%d)\n",
-			__FUNCTION__, strerror(err), err);
-		errno = err;
-		return -1;
-	}
-
-	if (connect(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
-		err = errno;
-		fprintf(stderr, "%s: connect() failed: %s (%d)\n",
-			__FUNCTION__, strerror(err), err);
-		close(sk);
-		errno = err;
-		return -1;
-	}
-
-	return sk;
-}
-
-int bt_audio_service_close(int sk)
-{
-	return close(sk);
-}
-
-int bt_audio_service_get_data_fd(int sk)
-{
-	char cmsg_b[CMSG_SPACE(sizeof(int))], m;
-	int err, ret;
-	struct iovec iov = { &m, sizeof(m) };
-	struct msghdr msgh;
-	struct cmsghdr *cmsg;
-
-	memset(&msgh, 0, sizeof(msgh));
-	msgh.msg_iov = &iov;
-	msgh.msg_iovlen = 1;
-	msgh.msg_control = &cmsg_b;
-	msgh.msg_controllen = CMSG_LEN(sizeof(int));
-
-	ret = recvmsg(sk, &msgh, 0);
-	if (ret < 0) {
-		err = errno;
-		fprintf(stderr, "%s: Unable to receive fd: %s (%d)\n",
-			__FUNCTION__, strerror(err), err);
-		errno = err;
-		return -1;
-	}
-
-	/* Receive auxiliary data in msgh */
-	for (cmsg = CMSG_FIRSTHDR(&msgh); cmsg != NULL;
-			cmsg = CMSG_NXTHDR(&msgh, cmsg)) {
-		if (cmsg->cmsg_level == SOL_SOCKET
-				&& cmsg->cmsg_type == SCM_RIGHTS) {
-			memcpy(&ret, CMSG_DATA(cmsg), sizeof(int));
-			return ret;
-		}
-	}
-
-	errno = EINVAL;
-	return -1;
-}
-
-const char *bt_audio_strtype(uint8_t type)
-{
-	if (type >= ARRAY_SIZE(strtypes))
-		return NULL;
-
-	return strtypes[type];
-}
-
-const char *bt_audio_strname(uint8_t name)
-{
-	if (name >= ARRAY_SIZE(strnames))
-		return NULL;
-
-	return strnames[name];
-}
diff --git a/src/modules/bluetooth/ipc.h b/src/modules/bluetooth/ipc.h
index 77c57d3..fcaef64 100644
--- a/src/modules/bluetooth/ipc.h
+++ b/src/modules/bluetooth/ipc.h
@@ -3,6 +3,7 @@
  *  BlueZ - Bluetooth protocol stack for Linux
  *
  *  Copyright (C) 2004-2010  Marcel Holtmann <marcel at holtmann.org>
+ *  Copyright (C) 2011  BMW Car IT GmbH. All rights reserved.
  *
  *
  *  This library is free software; you can redistribute it and/or
@@ -21,43 +22,6 @@
  *
  */
 
-/*
-  Message sequence chart of streaming sequence for A2DP transport
-
-  Audio daemon			User
-				on snd_pcm_open
-				<--BT_GET_CAPABILITIES_REQ
-
-  BT_GET_CAPABILITIES_RSP-->
-
-				on snd_pcm_hw_params
-				<--BT_SETCONFIGURATION_REQ
-
-  BT_SET_CONFIGURATION_RSP-->
-
-				on snd_pcm_prepare
-				<--BT_START_STREAM_REQ
-
-  <Moves to streaming state>
-  BT_START_STREAM_RSP-->
-
-  BT_NEW_STREAM_IND -->
-
-				<  streams data >
-				..........
-
-				on snd_pcm_drop/snd_pcm_drain
-
-				<--BT_STOP_STREAM_REQ
-
-  <Moves to open state>
-  BT_STOP_STREAM_RSP-->
-
-				on IPC close or appl crash
-  <Moves to idle>
-
- */
-
 #ifndef BT_AUDIOCLIENT_H
 #define BT_AUDIOCLIENT_H
 
@@ -72,58 +36,6 @@ extern "C" {
 #include <sys/un.h>
 #include <errno.h>
 
-#define BT_SUGGESTED_BUFFER_SIZE   512
-#define BT_IPC_SOCKET_NAME "\0/org/bluez/audio"
-
-/* Generic message header definition, except for RESPONSE messages */
-typedef struct {
-	uint8_t type;
-	uint8_t name;
-	uint16_t length;
-} __attribute__ ((packed)) bt_audio_msg_header_t;
-
-typedef struct {
-	bt_audio_msg_header_t h;
-	uint8_t posix_errno;
-} __attribute__ ((packed)) bt_audio_error_t;
-
-/* Message types */
-#define BT_REQUEST			0
-#define BT_RESPONSE			1
-#define BT_INDICATION			2
-#define BT_ERROR			3
-
-/* Messages names */
-#define BT_GET_CAPABILITIES		0
-#define BT_OPEN				1
-#define BT_SET_CONFIGURATION		2
-#define BT_NEW_STREAM			3
-#define BT_START_STREAM			4
-#define BT_STOP_STREAM			5
-#define BT_CLOSE			6
-#define BT_CONTROL			7
-#define BT_DELAY_REPORT			8
-
-#define BT_CAPABILITIES_TRANSPORT_A2DP	0
-#define BT_CAPABILITIES_TRANSPORT_SCO	1
-#define BT_CAPABILITIES_TRANSPORT_ANY	2
-
-#define BT_CAPABILITIES_ACCESS_MODE_READ	1
-#define BT_CAPABILITIES_ACCESS_MODE_WRITE	2
-#define BT_CAPABILITIES_ACCESS_MODE_READWRITE	3
-
-#define BT_FLAG_AUTOCONNECT	1
-
-struct bt_get_capabilities_req {
-	bt_audio_msg_header_t	h;
-	char			source[18];	/* Address of the local Device */
-	char			destination[18];/* Address of the remote Device */
-	char			object[128];	/* DBus object path */
-	uint8_t			transport;	/* Requested transport */
-	uint8_t			flags;		/* Requested flags */
-	uint8_t			seid;		/* Requested capability configuration */
-} __attribute__ ((packed));
-
 /**
  * SBC Codec parameters as per A2DP profile 1.0 § 4.3
  */
@@ -163,25 +75,6 @@ struct bt_get_capabilities_req {
 #define BT_A2DP_ALLOCATION_SNR			(1 << 1)
 #define BT_A2DP_ALLOCATION_LOUDNESS		1
 
-#define BT_MPEG_SAMPLING_FREQ_16000		(1 << 5)
-#define BT_MPEG_SAMPLING_FREQ_22050		(1 << 4)
-#define BT_MPEG_SAMPLING_FREQ_24000		(1 << 3)
-#define BT_MPEG_SAMPLING_FREQ_32000		(1 << 2)
-#define BT_MPEG_SAMPLING_FREQ_44100		(1 << 1)
-#define BT_MPEG_SAMPLING_FREQ_48000		1
-
-#define BT_MPEG_LAYER_1				(1 << 2)
-#define BT_MPEG_LAYER_2				(1 << 1)
-#define BT_MPEG_LAYER_3				1
-
-#define BT_HFP_CODEC_PCM			0x00
-
-#define BT_PCM_FLAG_NREC			0x01
-#define BT_PCM_FLAG_PCM_ROUTING			0x02
-
-#define BT_WRITE_LOCK				(1 << 1)
-#define BT_READ_LOCK				1
-
 typedef struct {
 	uint8_t seid;
 	uint8_t transport;
@@ -219,141 +112,6 @@ typedef struct {
 	uint16_t sampling_rate;
 } __attribute__ ((packed)) pcm_capabilities_t;
 
-struct bt_get_capabilities_rsp {
-	bt_audio_msg_header_t	h;
-	char			source[18];	/* Address of the local Device */
-	char			destination[18];/* Address of the remote Device */
-	char			object[128];	/* DBus object path */
-	uint8_t			data[0];	/* First codec_capabilities_t */
-} __attribute__ ((packed));
-
-struct bt_open_req {
-	bt_audio_msg_header_t	h;
-	char			source[18];	/* Address of the local Device */
-	char			destination[18];/* Address of the remote Device */
-	char			object[128];	/* DBus object path */
-	uint8_t			seid;		/* Requested capability configuration to lock */
-	uint8_t			lock;		/* Requested lock */
-} __attribute__ ((packed));
-
-struct bt_open_rsp {
-	bt_audio_msg_header_t	h;
-	char			source[18];	/* Address of the local Device */
-	char			destination[18];/* Address of the remote Device */
-	char			object[128];	/* DBus object path */
-} __attribute__ ((packed));
-
-struct bt_set_configuration_req {
-	bt_audio_msg_header_t	h;
-	codec_capabilities_t	codec;		/* Requested codec */
-} __attribute__ ((packed));
-
-struct bt_set_configuration_rsp {
-	bt_audio_msg_header_t	h;
-	uint16_t		link_mtu;	/* Max length that transport supports */
-} __attribute__ ((packed));
-
-#define BT_STREAM_ACCESS_READ		0
-#define BT_STREAM_ACCESS_WRITE		1
-#define BT_STREAM_ACCESS_READWRITE	2
-struct bt_start_stream_req {
-	bt_audio_msg_header_t	h;
-} __attribute__ ((packed));
-
-struct bt_start_stream_rsp {
-	bt_audio_msg_header_t	h;
-} __attribute__ ((packed));
-
-/* This message is followed by one byte of data containing the stream data fd
-   as ancilliary data */
-struct bt_new_stream_ind {
-	bt_audio_msg_header_t	h;
-} __attribute__ ((packed));
-
-struct bt_stop_stream_req {
-	bt_audio_msg_header_t	h;
-} __attribute__ ((packed));
-
-struct bt_stop_stream_rsp {
-	bt_audio_msg_header_t	h;
-} __attribute__ ((packed));
-
-struct bt_close_req {
-	bt_audio_msg_header_t	h;
-} __attribute__ ((packed));
-
-struct bt_close_rsp {
-	bt_audio_msg_header_t	h;
-} __attribute__ ((packed));
-
-struct bt_suspend_stream_ind {
-	bt_audio_msg_header_t	h;
-} __attribute__ ((packed));
-
-struct bt_resume_stream_ind {
-	bt_audio_msg_header_t	h;
-} __attribute__ ((packed));
-
-#define BT_CONTROL_KEY_POWER			0x40
-#define BT_CONTROL_KEY_VOL_UP			0x41
-#define BT_CONTROL_KEY_VOL_DOWN			0x42
-#define BT_CONTROL_KEY_MUTE			0x43
-#define BT_CONTROL_KEY_PLAY			0x44
-#define BT_CONTROL_KEY_STOP			0x45
-#define BT_CONTROL_KEY_PAUSE			0x46
-#define BT_CONTROL_KEY_RECORD			0x47
-#define BT_CONTROL_KEY_REWIND			0x48
-#define BT_CONTROL_KEY_FAST_FORWARD		0x49
-#define BT_CONTROL_KEY_EJECT			0x4A
-#define BT_CONTROL_KEY_FORWARD			0x4B
-#define BT_CONTROL_KEY_BACKWARD			0x4C
-
-struct bt_control_req {
-	bt_audio_msg_header_t	h;
-	uint8_t			mode;		/* Control Mode */
-	uint8_t			key;		/* Control Key */
-} __attribute__ ((packed));
-
-struct bt_control_rsp {
-	bt_audio_msg_header_t	h;
-	uint8_t			mode;		/* Control Mode */
-	uint8_t			key;		/* Control Key */
-} __attribute__ ((packed));
-
-struct bt_control_ind {
-	bt_audio_msg_header_t	h;
-	uint8_t			mode;		/* Control Mode */
-	uint8_t			key;		/* Control Key */
-} __attribute__ ((packed));
-
-struct bt_delay_report_req {
-	bt_audio_msg_header_t	h;
-	uint16_t		delay;
-} __attribute__ ((packed));
-
-struct bt_delay_report_ind {
-	bt_audio_msg_header_t	h;
-	uint16_t		delay;
-} __attribute__ ((packed));
-
-/* Function declaration */
-
-/* Opens a connection to the audio service: return a socket descriptor */
-int bt_audio_service_open(void);
-
-/* Closes a connection to the audio service */
-int bt_audio_service_close(int sk);
-
-/* Receives stream data file descriptor : must be called after a
-BT_STREAMFD_IND message is returned */
-int bt_audio_service_get_data_fd(int sk);
-
-/* Human readable message type string */
-const char *bt_audio_strtype(uint8_t type);
-
-/* Human readable message name string */
-const char *bt_audio_strname(uint8_t name);
-
 #ifdef __cplusplus
 }
 #endif
-- 
1.7.6.4



More information about the pulseaudio-discuss mailing list