summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2007-12-04 19:42:00 +0000
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2007-12-04 19:42:00 +0000
commitd51c190ddd0c2774509d0284979b24b9b0f3524a (patch)
tree2fa2dac6abc9633e3f4a6495c2f6a2380be97447
parent2934e194f3ffe754e18477113c870a7b98f88454 (diff)
Fix error messages. (thanks to fchevalier for the patch)
-rw-r--r--audio/ctl_bluetooth.c14
-rw-r--r--audio/gsta2dpsink.c30
-rw-r--r--audio/ipc.h43
-rw-r--r--audio/pcm_bluetooth.c46
-rw-r--r--audio/unix.c40
5 files changed, 89 insertions, 84 deletions
diff --git a/audio/ctl_bluetooth.c b/audio/ctl_bluetooth.c
index 5c198b1a..04185b36 100644
--- a/audio/ctl_bluetooth.c
+++ b/audio/ctl_bluetooth.c
@@ -164,24 +164,24 @@ static int bluetooth_send_ctl(struct bluetooth_data *data,
return -errno;
}
- type = bt_audio_strmsg(ctl_rsp->h.msg_type);
+ type = bt_audio_strmsg(ctl_rsp->rsp_h.msg_h.msg_type);
if (!type) {
SNDERR("Bogus message type %d "
"received from audio service",
- ctl_rsp->h.msg_type);
+ ctl_rsp->rsp_h.msg_h.msg_type);
return -EINVAL;
}
- if (ctl_rsp->h.msg_type != BT_CONTROL_RSP) {
+ if (ctl_rsp->rsp_h.msg_h.msg_type != BT_CONTROL_RSP) {
SNDERR("Unexpected message %s received", type);
return -EINVAL;
}
- if (ctl_rsp->posix_errno != 0) {
+ if (ctl_rsp->rsp_h.posix_errno != 0) {
SNDERR("BT_CONTROL failed : %s (%d)",
- strerror(ctl_rsp->posix_errno),
- ctl_rsp->posix_errno);
- return -ctl_rsp->posix_errno;
+ strerror(ctl_rsp->rsp_h.posix_errno),
+ ctl_rsp->rsp_h.posix_errno);
+ return -ctl_rsp->rsp_h.posix_errno;
}
return 0;
diff --git a/audio/gsta2dpsink.c b/audio/gsta2dpsink.c
index 1b893cc1..5798bc24 100644
--- a/audio/gsta2dpsink.c
+++ b/audio/gsta2dpsink.c
@@ -582,6 +582,7 @@ static gboolean gst_a2dp_sink_get_capabilities(GstA2dpSink *self)
{
gchar *buf[BT_AUDIO_IPC_PACKET_SIZE];
struct bt_getcapabilities_req *req = (void *) buf;
+ bt_audio_rsp_msg_header_t *rsp_hdr = (void *) buf;
struct bt_getcapabilities_rsp *rsp = (void *) buf;
GIOError io_error;
@@ -595,17 +596,17 @@ static gboolean gst_a2dp_sink_get_capabilities(GstA2dpSink *self)
GST_ERROR_OBJECT(self, "Error while asking device caps");
}
- io_error = gst_a2dp_sink_audioservice_expect(self, &rsp->h,
+ io_error = gst_a2dp_sink_audioservice_expect(self, &rsp_hdr->msg_h,
BT_GETCAPABILITIES_RSP);
if (io_error != G_IO_ERROR_NONE) {
GST_ERROR_OBJECT(self, "Error while getting device caps");
return FALSE;
}
- if (rsp->posix_errno != 0) {
+ if (rsp_hdr->posix_errno != 0) {
GST_ERROR_OBJECT(self, "BT_GETCAPABILITIES failed : %s(%d)",
- strerror(rsp->posix_errno),
- rsp->posix_errno);
+ strerror(rsp_hdr->posix_errno),
+ rsp_hdr->posix_errno);
return FALSE;
}
@@ -660,8 +661,8 @@ static gboolean gst_a2dp_sink_stream_start(GstA2dpSink *self)
{
gchar buf[BT_AUDIO_IPC_PACKET_SIZE];
struct bt_streamstart_req *req = (void *) buf;
- struct bt_streamstart_rsp *rsp = (void *) buf;
- struct bt_datafd_ind *ind = (void*) buf;
+ bt_audio_rsp_msg_header_t *rsp_hdr = (void *) buf;
+ struct bt_streamfd_ind *ind = (void*) buf;
GIOError io_error;
GST_DEBUG_OBJECT(self, "stream start");
@@ -678,17 +679,17 @@ static gboolean gst_a2dp_sink_stream_start(GstA2dpSink *self)
GST_DEBUG_OBJECT(self, "stream start packet sent");
- io_error = gst_a2dp_sink_audioservice_expect(self, &rsp->h,
+ io_error = gst_a2dp_sink_audioservice_expect(self, &rsp_hdr->msg_h,
BT_STREAMSTART_RSP);
if (io_error != G_IO_ERROR_NONE) {
GST_ERROR_OBJECT(self, "Error while stream start confirmation");
return FALSE;
}
- if (rsp->posix_errno != 0) {
+ if (rsp_hdr->posix_errno != 0) {
GST_ERROR_OBJECT(self, "BT_STREAMSTART_RSP failed : %s(%d)",
- strerror(rsp->posix_errno),
- rsp->posix_errno);
+ strerror(rsp_hdr->posix_errno),
+ rsp_hdr->posix_errno);
return FALSE;
}
@@ -711,6 +712,7 @@ static gboolean gst_a2dp_sink_configure(GstA2dpSink *self, GstCaps *caps)
{
gchar buf[BT_AUDIO_IPC_PACKET_SIZE];
struct bt_setconfiguration_req *req = (void *) buf;
+ bt_audio_rsp_msg_header_t *rsp_hdr = (void *) buf;
struct bt_setconfiguration_rsp *rsp = (void *) buf;
gboolean ret;
GIOError io_error;
@@ -737,17 +739,17 @@ static gboolean gst_a2dp_sink_configure(GstA2dpSink *self, GstCaps *caps)
GST_DEBUG_OBJECT(self, "configuration packet sent");
- io_error = gst_a2dp_sink_audioservice_expect(self, &rsp->h,
+ io_error = gst_a2dp_sink_audioservice_expect(self, &rsp_hdr->msg_h,
BT_SETCONFIGURATION_RSP);
if (io_error != G_IO_ERROR_NONE) {
GST_ERROR_OBJECT(self, "Error while receiving device confirmation");
return FALSE;
}
- if (rsp->posix_errno != 0) {
+ if (rsp_hdr->posix_errno != 0) {
GST_ERROR_OBJECT(self, "BT_SETCONFIGURATION_RSP failed : %s(%d)",
- strerror(rsp->posix_errno),
- rsp->posix_errno);
+ strerror(rsp_hdr->posix_errno),
+ rsp_hdr->posix_errno);
return FALSE;
}
diff --git a/audio/ipc.h b/audio/ipc.h
index 096c29f1..3e1200fa 100644
--- a/audio/ipc.h
+++ b/audio/ipc.h
@@ -74,11 +74,17 @@ extern "C" {
#define BT_AUDIO_IPC_PACKET_SIZE 128
#define BT_IPC_SOCKET_NAME "\0/org/bluez/audio"
-/* Generic message header definition */
+/* Generic message header definition, except for RSP messages */
typedef struct {
uint8_t msg_type;
} __attribute__ ((packed)) bt_audio_msg_header_t;
+/* Generic message header definition, for all RSP messages */
+typedef struct {
+ bt_audio_msg_header_t msg_h;
+ uint8_t posix_errno;
+} __attribute__ ((packed)) bt_audio_rsp_msg_header_t;
+
/* Messages list */
#define BT_GETCAPABILITIES_REQ 0
#define BT_GETCAPABILITIES_RSP 1
@@ -161,12 +167,11 @@ typedef struct {
} __attribute__ ((packed)) mpeg_capabilities_t;
struct bt_getcapabilities_rsp {
- bt_audio_msg_header_t h;
- uint8_t posix_errno;
- uint8_t transport; /* Granted transport */
- sbc_capabilities_t sbc_capabilities; /* A2DP only */
- mpeg_capabilities_t mpeg_capabilities; /* A2DP only */
- uint16_t sampling_rate; /* SCO only */
+ bt_audio_rsp_msg_header_t rsp_h;
+ uint8_t transport; /* Granted transport */
+ sbc_capabilities_t sbc_capabilities; /* A2DP only */
+ mpeg_capabilities_t mpeg_capabilities; /* A2DP only */
+ uint16_t sampling_rate; /* SCO only */
} __attribute__ ((packed));
/* BT_SETCONFIGURATION_REQ */
@@ -182,11 +187,10 @@ struct bt_setconfiguration_req {
/* BT_SETCONFIGURATION_RSP */
struct bt_setconfiguration_rsp {
- bt_audio_msg_header_t h;
- uint8_t transport; /* Granted transport */
- uint8_t access_mode; /* Granted access mode */
- uint16_t link_mtu; /* Max length that transport supports */
- uint8_t posix_errno;
+ bt_audio_rsp_msg_header_t rsp_h;
+ uint8_t transport; /* Granted transport */
+ uint8_t access_mode; /* Granted access mode */
+ uint16_t link_mtu; /* Max length that transport supports */
} __attribute__ ((packed));
/* BT_STREAMSTART_REQ */
@@ -199,14 +203,13 @@ struct bt_streamstart_req {
/* BT_STREAMSTART_RSP */
struct bt_streamstart_rsp {
- bt_audio_msg_header_t h;
- uint8_t posix_errno;
+ bt_audio_rsp_msg_header_t rsp_h;
} __attribute__ ((packed));
/* BT_STREAMFD_IND */
/* This message is followed by one byte of data containing the stream data fd
as ancilliary data */
-struct bt_datafd_ind {
+struct bt_streamfd_ind {
bt_audio_msg_header_t h;
} __attribute__ ((packed));
@@ -217,8 +220,7 @@ struct bt_streamstop_req {
/* BT_STREAMSTOP_RSP */
struct bt_streamstop_rsp {
- bt_audio_msg_header_t h;
- uint8_t posix_errno;
+ bt_audio_rsp_msg_header_t rsp_h;
} __attribute__ ((packed));
/* BT_STREAMSUSPEND_IND */
@@ -255,10 +257,9 @@ struct bt_control_req {
/* BT_CONTROL_RSP */
struct bt_control_rsp {
- bt_audio_msg_header_t h;
- uint8_t posix_errno;
- uint8_t mode; /* Control Mode */
- uint8_t key; /* Control Key */
+ bt_audio_rsp_msg_header_t rsp_h;
+ uint8_t mode; /* Control Mode */
+ uint8_t key; /* Control Key */
} __attribute__ ((packed));
/* BT_CONTROL_IND */
diff --git a/audio/pcm_bluetooth.c b/audio/pcm_bluetooth.c
index a177274a..6f67ca57 100644
--- a/audio/pcm_bluetooth.c
+++ b/audio/pcm_bluetooth.c
@@ -332,8 +332,8 @@ static int bluetooth_prepare(snd_pcm_ioplug_t *io)
char c = 'w';
char buf[BT_AUDIO_IPC_PACKET_SIZE];
struct bt_streamstart_req *start_req = (void*) buf;
- struct bt_streamstart_rsp *start_rsp = (void*) buf;
- struct bt_datafd_ind *datafd_ind = (void*) buf;
+ bt_audio_rsp_msg_header_t *rsp_hdr = (void*) buf;
+ struct bt_streamfd_ind *streamfd_ind = (void*) buf;
uint32_t period_count = io->buffer_size / io->period_size;
int opt_name, err;
struct timeval t = { 0, period_count };
@@ -368,19 +368,19 @@ static int bluetooth_prepare(snd_pcm_ioplug_t *io)
if (err < 0)
return err;
- err = audioservice_expect(data->server.fd, &start_rsp->h,
+ err = audioservice_expect(data->server.fd, &rsp_hdr->msg_h,
BT_STREAMSTART_RSP);
if (err < 0)
return err;
- if (start_rsp->posix_errno != 0) {
+ if (rsp_hdr->posix_errno != 0) {
SNDERR("BT_START failed : %s(%d)",
- strerror(start_rsp->posix_errno),
- start_rsp->posix_errno);
- return -start_rsp->posix_errno;
+ strerror(rsp_hdr->posix_errno),
+ rsp_hdr->posix_errno);
+ return -rsp_hdr->posix_errno;
}
- err = audioservice_expect(data->server.fd, &datafd_ind->h,
+ err = audioservice_expect(data->server.fd, &streamfd_ind->h,
BT_STREAMFD_IND);
if (err < 0)
return err;
@@ -542,6 +542,7 @@ static int bluetooth_a2dp_hw_params(snd_pcm_ioplug_t *io,
struct bluetooth_data *data = io->private_data;
struct bluetooth_a2dp *a2dp = &data->a2dp;
char buf[BT_AUDIO_IPC_PACKET_SIZE];
+ bt_audio_rsp_msg_header_t *rsp_hdr = (void*) buf;
struct bt_setconfiguration_req *setconf_req = (void*) buf;
struct bt_setconfiguration_rsp *setconf_rsp = (void*) buf;
unsigned int rate, channels;
@@ -573,16 +574,16 @@ static int bluetooth_a2dp_hw_params(snd_pcm_ioplug_t *io,
if (err < 0)
return err;
- err = audioservice_expect(data->server.fd, &setconf_rsp->h,
+ err = audioservice_expect(data->server.fd, &rsp_hdr->msg_h,
BT_SETCONFIGURATION_RSP);
if (err < 0)
return err;
- if (setconf_rsp->posix_errno != 0) {
+ if (rsp_hdr->posix_errno != 0) {
SNDERR("BT_SETCONFIGURATION failed : %s(%d)",
- strerror(setconf_rsp->posix_errno),
- setconf_rsp->posix_errno);
- return -setconf_rsp->posix_errno;
+ strerror(rsp_hdr->posix_errno),
+ rsp_hdr->posix_errno);
+ return -rsp_hdr->posix_errno;
}
data->transport = setconf_rsp->transport;
@@ -1399,16 +1400,16 @@ static int audioservice_recv(int sk, bt_audio_msg_header_t *inmsg)
return err;
}
-static int audioservice_expect(int sk, bt_audio_msg_header_t *outmsg,
+static int audioservice_expect(int sk, bt_audio_msg_header_t *rsp_hdr,
int expected_type)
{
- int err = audioservice_recv(sk, outmsg);
+ int err = audioservice_recv(sk, rsp_hdr);
if (err == 0) {
- if (outmsg->msg_type != expected_type) {
+ if (rsp_hdr->msg_type != expected_type) {
err = -EINVAL;
SNDERR("Bogus message %s received while "
"%s was expected",
- bt_audio_strmsg(outmsg->msg_type),
+ bt_audio_strmsg(rsp_hdr->msg_type),
bt_audio_strmsg(expected_type));
}
}
@@ -1421,6 +1422,7 @@ static int bluetooth_init(struct bluetooth_data *data, snd_pcm_stream_t stream,
int sk, err;
struct bluetooth_alsa_config *alsa_conf = &data->alsa_config;
char buf[BT_AUDIO_IPC_PACKET_SIZE];
+ bt_audio_rsp_msg_header_t *rsp_hdr = (void*) buf;
struct bt_getcapabilities_req *getcaps_req = (void*) buf;
struct bt_getcapabilities_rsp *getcaps_rsp = (void*) buf;
@@ -1474,15 +1476,15 @@ static int bluetooth_init(struct bluetooth_data *data, snd_pcm_stream_t stream,
if (err < 0)
goto failed;
- err = audioservice_expect(data->server.fd, &getcaps_rsp->h, BT_GETCAPABILITIES_RSP);
+ err = audioservice_expect(data->server.fd, &rsp_hdr->msg_h, BT_GETCAPABILITIES_RSP);
if (err < 0)
goto failed;
- if (getcaps_rsp->posix_errno != 0) {
+ if (rsp_hdr->posix_errno != 0) {
SNDERR("BT_GETCAPABILITIES failed : %s(%d)",
- strerror(getcaps_rsp->posix_errno),
- getcaps_rsp->posix_errno);
- return -getcaps_rsp->posix_errno;
+ strerror(rsp_hdr->posix_errno),
+ rsp_hdr->posix_errno);
+ return -rsp_hdr->posix_errno;
}
data->transport = getcaps_rsp->transport;
diff --git a/audio/unix.c b/audio/unix.c
index c321b99b..8267e895 100644
--- a/audio/unix.c
+++ b/audio/unix.c
@@ -161,13 +161,13 @@ static void unix_ipc_sendmsg(struct unix_client *client,
static void unix_ipc_error(struct unix_client *client, int type, int err)
{
char buf[BT_AUDIO_IPC_PACKET_SIZE];
- struct bt_getcapabilities_rsp *rsp = (void *) buf;
+ bt_audio_rsp_msg_header_t *rsp_hdr = (void *) buf;
memset(buf, 0, sizeof(buf));
- rsp->h.msg_type = type;
- rsp->posix_errno = err;
+ rsp_hdr->msg_h.msg_type = type;
+ rsp_hdr->posix_errno = err;
- unix_ipc_sendmsg(client, &rsp->h);
+ unix_ipc_sendmsg(client, &rsp_hdr->msg_h);
}
static service_type_t select_service(struct device *dev, const char *interface)
@@ -304,13 +304,13 @@ static void headset_setup_complete(struct device *dev, void *user_data)
memset(buf, 0, sizeof(buf));
- rsp->h.msg_type = BT_SETCONFIGURATION_RSP;
+ rsp->rsp_h.msg_h.msg_type = BT_SETCONFIGURATION_RSP;
rsp->transport = BT_CAPABILITIES_TRANSPORT_SCO;
rsp->access_mode = client->access_mode;
client->data_fd = headset_get_sco_fd(dev);
- unix_ipc_sendmsg(client, &rsp->h);
+ unix_ipc_sendmsg(client, &rsp->rsp_h.msg_h);
}
static void a2dp_discovery_complete(struct avdtp *session, GSList *seps,
@@ -330,7 +330,7 @@ static void a2dp_discovery_complete(struct avdtp *session, GSList *seps,
memset(buf, 0, sizeof(buf));
client->req_id = 0;
- rsp->h.msg_type = BT_GETCAPABILITIES_RSP;
+ rsp->rsp_h.msg_h.msg_type = BT_GETCAPABILITIES_RSP;
rsp->transport = BT_CAPABILITIES_TRANSPORT_A2DP;
for (l = seps; l; l = g_slist_next(l)) {
@@ -361,7 +361,7 @@ static void a2dp_discovery_complete(struct avdtp *session, GSList *seps,
rsp->sbc_capabilities.max_bitpool = sbc_cap->max_bitpool;
}
- unix_ipc_sendmsg(client, &rsp->h);
+ unix_ipc_sendmsg(client, &rsp->rsp_h.msg_h);
return;
@@ -406,14 +406,14 @@ static void a2dp_config_complete(struct avdtp *session, struct a2dp_sep *sep,
goto failed;
}
- rsp->h.msg_type = BT_SETCONFIGURATION_RSP;
+ rsp->rsp_h.msg_h.msg_type = BT_SETCONFIGURATION_RSP;
rsp->transport = BT_CAPABILITIES_TRANSPORT_A2DP;
client->access_mode = BT_CAPABILITIES_ACCESS_MODE_WRITE;
rsp->access_mode = client->access_mode;
/* FIXME: Use imtu when fd_opt is CFG_FD_OPT_READ */
rsp->link_mtu = omtu;
- unix_ipc_sendmsg(client, &rsp->h);
+ unix_ipc_sendmsg(client, &rsp->rsp_h.msg_h);
client->cb_id = avdtp_stream_add_cb(session, stream,
stream_state_changed, client);
@@ -441,13 +441,13 @@ static void a2dp_resume_complete(struct avdtp *session,
struct unix_client *client = user_data;
char buf[BT_AUDIO_IPC_PACKET_SIZE];
struct bt_streamstart_rsp *rsp = (void *) buf;
- struct bt_datafd_ind *ind = (void *) buf;
+ struct bt_streamfd_ind *ind = (void *) buf;
struct a2dp_data *a2dp = &client->d.a2dp;
memset(buf, 0, sizeof(buf));
- rsp->h.msg_type = BT_STREAMSTART_RSP;
- rsp->posix_errno = 0;
- unix_ipc_sendmsg(client, &rsp->h);
+ rsp->rsp_h.msg_h.msg_type = BT_STREAMSTART_RSP;
+ rsp->rsp_h.posix_errno = 0;
+ unix_ipc_sendmsg(client, &rsp->rsp_h.msg_h);
memset(buf, 0, sizeof(buf));
ind->h.msg_type = BT_STREAMFD_IND;
@@ -487,9 +487,9 @@ static void a2dp_suspend_complete(struct avdtp *session,
goto failed;
memset(buf, 0, sizeof(buf));
- rsp->h.msg_type = BT_STREAMSTOP_RSP;
- rsp->posix_errno = 0;
- unix_ipc_sendmsg(client, &rsp->h);
+ rsp->rsp_h.msg_h.msg_type = BT_STREAMSTOP_RSP;
+ rsp->rsp_h.posix_errno = 0;
+ unix_ipc_sendmsg(client, &rsp->rsp_h.msg_h);
return;
@@ -863,10 +863,10 @@ static void handle_control_req(struct unix_client *client,
struct bt_setconfiguration_rsp *rsp = (void *) buf;
memset(buf, 0, sizeof(buf));
- rsp->h.msg_type = BT_CONTROL_RSP;
- rsp->posix_errno = 0;
+ rsp->rsp_h.msg_h.msg_type = BT_CONTROL_RSP;
+ rsp->rsp_h.posix_errno = 0;
- unix_ipc_sendmsg(client, &rsp->h);
+ unix_ipc_sendmsg(client, &rsp->rsp_h.msg_h);
}
static gboolean client_cb(GIOChannel *chan, GIOCondition cond, gpointer data)