summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2007-06-04 22:03:21 +0000
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2007-06-04 22:03:21 +0000
commita551604373fc46741c44524b01353d50852b26f4 (patch)
treedde8089fc6c56270584fc247050afa591e278084 /audio
parentf63a68d621017f6ba41f14136622ce3ff68d6cd3 (diff)
Add experiemental code for audio service ipc.
Diffstat (limited to 'audio')
-rw-r--r--audio/ipc.h74
-rw-r--r--audio/pcm_bluetooth.c9
2 files changed, 72 insertions, 11 deletions
diff --git a/audio/ipc.h b/audio/ipc.h
index 119aa7b3..e6859a50 100644
--- a/audio/ipc.h
+++ b/audio/ipc.h
@@ -31,19 +31,71 @@
#define UNIX_PATH_MAX 108
#endif
-struct ipc_hdr {
- uint16_t id;
- uint16_t type;
- uint16_t seqnum;
- uint16_t length;
+/* Supported roles */
+#define PKT_ROLE_NONE 0
+#define PKT_ROLE_AUTO 1
+#define PKT_ROLE_VOICE 2
+#define PKT_ROLE_HIFI 3
+
+/* Packet types */
+#define PKT_TYPE_CFG_REQ 0
+#define PKT_TYPE_CFG_RSP 1
+#define PKT_TYPE_STATUS_REQ 3
+#define PKT_TYPE_STATUS_RSP 4
+#define PKT_TYPE_CTL_REQ 5
+#define PKT_TYPE_CTL_RSP 6
+
+/* Errors codes */
+#define PKT_ERROR_NONE 0
+
+struct ipc_packet {
+ uint8_t id; /* Device id */
+ uint8_t role; /* Audio role eg: voice, wifi, auto... */
+ uint8_t type; /* Packet type */
+ uint8_t error; /* Packet error code */
+ uint8_t length; /* Payload length in bytes */
+ uint8_t data[0]; /* Packet payload */
} __attribute__ ((packed));
-struct ipc_connect_cmd {
- uint8_t src[6];
- uint8_t dst[6];
- uint16_t uuid;
+/* File descriptor options */
+#define CFG_FD_OPT_READ 0
+#define CFG_FD_OPT_WRITE 1
+#define CFG_FD_OPT_READWRITE 2
+
+struct ipc_data_cfg {
+ int fd; /* Stream file descriptor */
+ uint8_t fd_opt; /* Stream file descriptor options: read, write or readwrite*/
+ uint8_t encoding; /* Stream encoding */
+ uint8_t bitpool; /* Encoding bitpool */
+ uint8_t channels; /* Number of audio channel */
+ uint16_t rate; /* Stream sample rate */
} __attribute__ ((packed));
-struct ipc_connect_evt {
- uint16_t id;
+/* Device status */
+#define STATUS_DISCONNECTED 0
+#define STATUS_CONNECTING 1
+#define STATUS_CONNECTED 2
+#define STATUS_STREAMING 3
+
+struct ipc_data_status {
+ uint8_t status; /* Stream status */
} __attribute__ ((packed));
+
+/* Supported control operations */
+#define DATA_CTL_POWER 0x40
+#define DATA_CTL_VOL_UP 0x41
+#define DATA_CTL_VOL_DOWN 0x42
+#define DATA_CTL_MUTE 0x43
+#define DATA_CTL_PLAY 0x44
+#define DATA_CTL_STOP 0x45
+#define DATA_CTL_PAUSE 0x46
+#define DATA_CTL_RECORD 0x47
+#define DATA_CTL_REWIND 0x48
+#define DATA_CTL_FAST_FORWARD 0x49
+#define DATA_CTL_EJECT 0x4A
+#define DATA_CTL_FORWARD 0x4B
+#define DATA_CTL_BACKWARD 0x4C
+
+struct ipc_data_ctl {
+ uint8_t operation; /* Operation ID */
+} __attribute__ ((packed));
diff --git a/audio/pcm_bluetooth.c b/audio/pcm_bluetooth.c
index 838dcd39..3e473d6c 100644
--- a/audio/pcm_bluetooth.c
+++ b/audio/pcm_bluetooth.c
@@ -182,6 +182,15 @@ SND_PCM_PLUGIN_DEFINE_FUNC(bluetooth)
return -EINVAL;
}
+ if((stream == SND_PCM_STREAM_PLAYBACK) && (opened_for & OPENED_PLAYBACK)) {
+ SNDERR("Cannot open Bluetooth Headset PCM plugin twice for playback.");
+ return -EINVAL;
+ }
+ if((stream == SND_PCM_STREAM_CAPTURE) && (opened_for & OPENED_CAPTURE)) {
+ SNDERR("Cannot open Bluetooth Headset PCM plugin twice for capture.");
+ return -EINVAL;
+ }
+
id = abs(getpid() * rand());
sk = socket(PF_LOCAL, SOCK_DGRAM, 0);