summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorBrad Midgley <bmidgley@xmission.com>2007-09-03 19:12:40 +0000
committerBrad Midgley <bmidgley@xmission.com>2007-09-03 19:12:40 +0000
commite1ca1c0fbb4694b4b2c8e7532b05dbfcd4144687 (patch)
treeaff694f72f2fb363b44df3487fbd1c51b33c6030 /audio
parentf7ca86c9aa904a915af6720a0add59dd6148cca1 (diff)
stub in the state change ipc for pausing a stream (but don't enable it yet)
Diffstat (limited to 'audio')
-rw-r--r--audio/pcm_bluetooth.c62
-rw-r--r--audio/unix.c47
2 files changed, 85 insertions, 24 deletions
diff --git a/audio/pcm_bluetooth.c b/audio/pcm_bluetooth.c
index bc962012..7cf802b8 100644
--- a/audio/pcm_bluetooth.c
+++ b/audio/pcm_bluetooth.c
@@ -215,6 +215,62 @@ iter_sleep:
}
}
+static int bluetooth_state_init(struct ipc_packet *pkt, int newstate)
+{
+ struct ipc_data_state *state = (void *) pkt->data;
+
+ pkt->length = sizeof(*state);
+ pkt->type = PKT_TYPE_STATE_REQ;
+ pkt->error = PKT_ERROR_NONE;
+ state->state = newstate;
+
+ return 0;
+}
+
+static int bluetooth_state(struct bluetooth_data *data, int newstate)
+{
+ char buf[IPC_MTU];
+ struct ipc_packet *pkt = (void *) buf;
+ struct ipc_data_state *state = (void *) pkt->data;
+ int ret, total;
+
+ memset(buf, 0, sizeof(buf));
+
+ ret = bluetooth_state_init(pkt, newstate);
+ if (ret < 0)
+ return -ret;
+
+ ret = send(data->sock, pkt, sizeof(*pkt) + pkt->length, 0);
+ if (ret < 0)
+ return -errno;
+ else if (ret == 0)
+ return -EIO;
+
+ DBG("OK - %d bytes sent. Waiting for response...", ret);
+
+ memset(buf, 0, sizeof(buf));
+
+ ret = recv(data->sock, buf, sizeof(*pkt) + sizeof(*state), 0);
+ if (ret < 0)
+ return -errno;
+ else if (ret == 0)
+ return -EIO;
+
+ total = ret;
+
+ if (pkt->type != PKT_TYPE_STATE_RSP) {
+ SNDERR("Unexpected packet type %d received", pkt->type);
+ return -EINVAL;
+ }
+
+ if (pkt->error != PKT_ERROR_NONE) {
+ SNDERR("Error %d while configuring device", pkt->error);
+ return -pkt->error;
+ }
+
+ return 0;
+}
+
static int bluetooth_playback_start(snd_pcm_ioplug_t *io)
{
struct bluetooth_data *data = io->private_data;
@@ -222,6 +278,9 @@ static int bluetooth_playback_start(snd_pcm_ioplug_t *io)
DBG("%p", io);
+#if 0
+ bluetooth_state(data, STATE_STREAMING);
+#endif
data->stopped = 0;
if (data->hw_thread)
@@ -238,6 +297,9 @@ static int bluetooth_playback_stop(snd_pcm_ioplug_t *io)
DBG("%p", io);
+#if 0
+ bluetooth_state(data, STATE_CONNECTED);
+#endif
data->stopped = 1;
return 0;
diff --git a/audio/unix.c b/audio/unix.c
index c39c80c4..accf6efb 100644
--- a/audio/unix.c
+++ b/audio/unix.c
@@ -637,6 +637,27 @@ static void ctl_event(struct unix_client *client,
{
}
+static int reply_state(int sock, struct ipc_packet *pkt)
+{
+ struct ipc_data_state *state = (struct ipc_data_state *) pkt->data;
+ int len;
+
+ info("status=%u", state->state);
+
+ pkt->type = PKT_TYPE_STATE_RSP;
+ pkt->length = sizeof(struct ipc_data_state);
+ pkt->error = PKT_ERROR_NONE;
+
+ len = sizeof(struct ipc_packet) + sizeof(struct ipc_data_state);
+ len = send(sock, pkt, len, 0);
+ if (len < 0)
+ error("Error %s(%d)", strerror(errno), errno);
+
+ debug("%d bytes sent", len);
+
+ return 0;
+}
+
static void state_event(struct unix_client *client,
struct ipc_packet *pkt, int len)
{
@@ -648,9 +669,9 @@ static void state_event(struct unix_client *client,
device_set_state(dev, state->state);
else
state->state = device_get_state(dev);
-
- unix_send_state(client->sock, pkt);
#endif
+
+ reply_state(client->sock, pkt);
}
static gboolean client_cb(GIOChannel *chan, GIOCondition cond, gpointer data)
@@ -812,25 +833,3 @@ void unix_exit(void)
unix_sock = -1;
}
-#if 0
-static int unix_send_state(int sock, struct ipc_packet *pkt)
-{
- struct ipc_data_state *state = (struct ipc_data_state *) pkt->data;
- int len;
-
- info("status=%u", state->state);
-
- pkt->type = PKT_TYPE_STATE_RSP;
- pkt->length = sizeof(struct ipc_data_state);
- pkt->error = PKT_ERROR_NONE;
-
- len = sizeof(struct ipc_packet) + sizeof(struct ipc_data_state);
- len = send(sock, pkt, len, 0);
- if (len < 0)
- error("Error %s(%d)", strerror(errno), errno);
-
- debug("%d bytes sent", len);
-
- return 0;
-}
-#endif