2 * Copyright (C) 2013 Intel Corporation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <sys/socket.h>
28 #include <hardware/audio.h>
29 #include <hardware/hardware.h>
31 #include "audio-msg.h"
34 #include "../profiles/audio/a2dp-codecs.h"
36 static const uint8_t a2dp_src_uuid[] = {
37 0x00, 0x00, 0x11, 0x0a, 0x00, 0x00, 0x10, 0x00,
38 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb };
40 static int listen_sk = -1;
41 static int audio_sk = -1;
42 static bool close_thread = false;
44 static pthread_t ipc_th = 0;
45 static pthread_mutex_t close_mutex = PTHREAD_MUTEX_INITIALIZER;
46 static pthread_mutex_t sk_mutex = PTHREAD_MUTEX_INITIALIZER;
48 struct audio_input_config {
51 audio_format_t format;
54 static int sbc_get_presets(struct audio_preset *preset, size_t *len);
59 int (*get_presets) (struct audio_preset *preset, size_t *len);
61 int (*init) (struct audio_preset *preset, void **codec_data);
62 int (*cleanup) (void *codec_data);
63 int (*get_config) (void *codec_data,
64 struct audio_input_config *config);
65 ssize_t (*write_data) (void *codec_data, const void *buffer,
69 static const struct audio_codec audio_codecs[] = {
71 .type = A2DP_CODEC_SBC,
73 .get_presets = sbc_get_presets,
77 #define NUM_CODECS (sizeof(audio_codecs) / sizeof(audio_codecs[0]))
79 #define MAX_AUDIO_ENDPOINTS NUM_CODECS
81 struct audio_endpoint {
83 const struct audio_codec *codec;
88 static struct audio_endpoint audio_endpoints[MAX_AUDIO_ENDPOINTS];
91 AUDIO_A2DP_STATE_NONE,
92 AUDIO_A2DP_STATE_STANDBY,
93 AUDIO_A2DP_STATE_SUSPENDED,
94 AUDIO_A2DP_STATE_STARTED
97 struct a2dp_stream_out {
98 struct audio_stream_out stream;
100 struct audio_endpoint *ep;
101 enum a2dp_state_t audio_state;
104 struct a2dp_audio_dev {
105 struct audio_hw_device dev;
106 struct a2dp_stream_out *out;
109 static const a2dp_sbc_t sbc_presets[] = {
111 .frequency = SBC_SAMPLING_FREQ_44100 | SBC_SAMPLING_FREQ_48000,
112 .channel_mode = SBC_CHANNEL_MODE_MONO |
113 SBC_CHANNEL_MODE_DUAL_CHANNEL |
114 SBC_CHANNEL_MODE_STEREO |
115 SBC_CHANNEL_MODE_JOINT_STEREO,
116 .subbands = SBC_SUBBANDS_4 | SBC_SUBBANDS_8,
117 .allocation_method = SBC_ALLOCATION_SNR |
118 SBC_ALLOCATION_LOUDNESS,
119 .block_length = SBC_BLOCK_LENGTH_4 | SBC_BLOCK_LENGTH_8 |
120 SBC_BLOCK_LENGTH_12 | SBC_BLOCK_LENGTH_16,
121 .min_bitpool = MIN_BITPOOL,
122 .max_bitpool = MAX_BITPOOL
125 .frequency = SBC_SAMPLING_FREQ_44100,
126 .channel_mode = SBC_CHANNEL_MODE_JOINT_STEREO,
127 .subbands = SBC_SUBBANDS_8,
128 .allocation_method = SBC_ALLOCATION_LOUDNESS,
129 .block_length = SBC_BLOCK_LENGTH_16,
130 .min_bitpool = MIN_BITPOOL,
131 .max_bitpool = MAX_BITPOOL
134 .frequency = SBC_SAMPLING_FREQ_48000,
135 .channel_mode = SBC_CHANNEL_MODE_JOINT_STEREO,
136 .subbands = SBC_SUBBANDS_8,
137 .allocation_method = SBC_ALLOCATION_LOUDNESS,
138 .block_length = SBC_BLOCK_LENGTH_16,
139 .min_bitpool = MIN_BITPOOL,
140 .max_bitpool = MAX_BITPOOL
144 static int sbc_get_presets(struct audio_preset *preset, size_t *len)
149 uint8_t *ptr = (uint8_t *) preset;
150 size_t preset_size = sizeof(*preset) + sizeof(a2dp_sbc_t);
154 count = sizeof(sbc_presets) / sizeof(sbc_presets[0]);
156 for (i = 0; i < count; i++) {
157 preset = (struct audio_preset *) ptr;
159 if (new_len + preset_size > *len)
162 preset->len = sizeof(a2dp_sbc_t);
163 memcpy(preset->data, &sbc_presets[i], preset->len);
165 new_len += preset_size;
174 static void audio_ipc_cleanup(void)
177 shutdown(audio_sk, SHUT_RDWR);
182 static int audio_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len,
183 void *param, size_t *rsp_len, void *rsp, int *fd)
189 char cmsgbuf[CMSG_SPACE(sizeof(int))];
191 size_t s_len = sizeof(s);
194 error("audio: Invalid cmd socket passed to audio_ipc_cmd");
198 if (!rsp || !rsp_len) {
199 memset(&s, 0, s_len);
204 memset(&msg, 0, sizeof(msg));
205 memset(&cmd, 0, sizeof(cmd));
207 cmd.service_id = service_id;
211 iv[0].iov_base = &cmd;
212 iv[0].iov_len = sizeof(cmd);
214 iv[1].iov_base = param;
220 pthread_mutex_lock(&sk_mutex);
222 ret = sendmsg(audio_sk, &msg, 0);
224 error("audio: Sending command failed:%s", strerror(errno));
225 pthread_mutex_unlock(&sk_mutex);
229 /* socket was shutdown */
231 error("audio: Command socket closed");
235 memset(&msg, 0, sizeof(msg));
236 memset(&cmd, 0, sizeof(cmd));
238 iv[0].iov_base = &cmd;
239 iv[0].iov_len = sizeof(cmd);
241 iv[1].iov_base = rsp;
242 iv[1].iov_len = *rsp_len;
248 memset(cmsgbuf, 0, sizeof(cmsgbuf));
249 msg.msg_control = cmsgbuf;
250 msg.msg_controllen = sizeof(cmsgbuf);
253 ret = recvmsg(audio_sk, &msg, 0);
255 error("audio: Receiving command response failed:%s",
257 pthread_mutex_unlock(&sk_mutex);
261 pthread_mutex_unlock(&sk_mutex);
263 if (ret < (ssize_t) sizeof(cmd)) {
264 error("audio: Too small response received(%zd bytes)", ret);
268 if (cmd.service_id != service_id) {
269 error("audio: Invalid service id (%u vs %u)", cmd.service_id,
274 if (ret != (ssize_t) (sizeof(cmd) + cmd.len)) {
275 error("audio: Malformed response received(%zd bytes)", ret);
279 if (cmd.opcode != opcode && cmd.opcode != AUDIO_OP_STATUS) {
280 error("audio: Invalid opcode received (%u vs %u)",
285 if (cmd.opcode == AUDIO_OP_STATUS) {
286 struct hal_status *s = rsp;
288 if (sizeof(*s) != cmd.len) {
289 error("audio: Invalid status length");
293 if (s->code == AUDIO_STATUS_SUCCESS) {
294 error("audio: Invalid success status response");
301 /* Receive auxiliary data in msg */
303 struct cmsghdr *cmsg;
307 for (cmsg = CMSG_FIRSTHDR(&msg); cmsg;
308 cmsg = CMSG_NXTHDR(&msg, cmsg)) {
309 if (cmsg->cmsg_level == SOL_SOCKET
310 && cmsg->cmsg_type == SCM_RIGHTS) {
311 memcpy(fd, CMSG_DATA(cmsg), sizeof(int));
320 return AUDIO_STATUS_SUCCESS;
323 /* Some serious issue happen on IPC - recover */
324 shutdown(audio_sk, SHUT_RDWR);
326 return AUDIO_STATUS_FAILED;
329 static int ipc_open_cmd(const struct audio_codec *codec)
331 uint8_t buf[BLUEZ_AUDIO_MTU];
332 struct audio_cmd_open *cmd = (struct audio_cmd_open *) buf;
333 struct audio_rsp_open rsp;
334 size_t cmd_len = sizeof(buf) - sizeof(*cmd);
335 size_t rsp_len = sizeof(rsp);
340 memcpy(cmd->uuid, a2dp_src_uuid, sizeof(a2dp_src_uuid));
342 cmd->codec = codec->type;
343 cmd->presets = codec->get_presets(cmd->preset, &cmd_len);
345 cmd_len += sizeof(*cmd);
347 result = audio_ipc_cmd(AUDIO_SERVICE_ID, AUDIO_OP_OPEN, cmd_len, cmd,
348 &rsp_len, &rsp, NULL);
350 if (result != AUDIO_STATUS_SUCCESS)
356 static int ipc_close_cmd(uint8_t endpoint_id)
358 struct audio_cmd_close cmd;
363 cmd.id = endpoint_id;
365 result = audio_ipc_cmd(AUDIO_SERVICE_ID, AUDIO_OP_CLOSE,
366 sizeof(cmd), &cmd, NULL, NULL, NULL);
371 static int ipc_open_stream_cmd(uint8_t endpoint_id,
372 struct audio_preset **caps)
374 char buf[BLUEZ_AUDIO_MTU];
375 struct audio_cmd_open_stream cmd;
376 struct audio_rsp_open_stream *rsp =
377 (struct audio_rsp_open_stream *) &buf;
378 size_t rsp_len = sizeof(buf);
384 return AUDIO_STATUS_FAILED;
386 cmd.id = endpoint_id;
388 result = audio_ipc_cmd(AUDIO_SERVICE_ID, AUDIO_OP_OPEN_STREAM,
389 sizeof(cmd), &cmd, &rsp_len, rsp, NULL);
391 if (result == AUDIO_STATUS_SUCCESS) {
392 size_t buf_len = sizeof(struct audio_preset) +
394 *caps = malloc(buf_len);
395 memcpy(*caps, &rsp->preset, buf_len);
403 static int ipc_close_stream_cmd(uint8_t endpoint_id)
405 struct audio_cmd_close_stream cmd;
410 cmd.id = endpoint_id;
412 result = audio_ipc_cmd(AUDIO_SERVICE_ID, AUDIO_OP_CLOSE_STREAM,
413 sizeof(cmd), &cmd, NULL, NULL, NULL);
418 static int ipc_resume_stream_cmd(uint8_t endpoint_id)
420 struct audio_cmd_resume_stream cmd;
425 cmd.id = endpoint_id;
427 result = audio_ipc_cmd(AUDIO_SERVICE_ID, AUDIO_OP_RESUME_STREAM,
428 sizeof(cmd), &cmd, NULL, NULL, NULL);
433 static int ipc_suspend_stream_cmd(uint8_t endpoint_id)
435 struct audio_cmd_suspend_stream cmd;
440 cmd.id = endpoint_id;
442 result = audio_ipc_cmd(AUDIO_SERVICE_ID, AUDIO_OP_SUSPEND_STREAM,
443 sizeof(cmd), &cmd, NULL, NULL, NULL);
448 static int register_endpoints(void)
450 struct audio_endpoint *ep = &audio_endpoints[0];
453 for (i = 0; i < NUM_CODECS; i++, ep++) {
454 const struct audio_codec *codec = &audio_codecs[i];
456 ep->id = ipc_open_cmd(codec);
459 return AUDIO_STATUS_FAILED;
462 ep->codec_data = NULL;
466 return AUDIO_STATUS_SUCCESS;
469 static void unregister_endpoints(void)
473 for (i = 0; i < MAX_AUDIO_ENDPOINTS; i++) {
474 struct audio_endpoint *ep = &audio_endpoints[i];
477 ipc_close_cmd(ep->id);
478 memset(ep, 0, sizeof(*ep));
483 static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,
486 struct a2dp_stream_out *out = (struct a2dp_stream_out *) stream;
488 /* We can auto-start only from standby */
489 if (out->audio_state == AUDIO_A2DP_STATE_STANDBY) {
490 DBG("stream in standby, auto-start");
492 if (ipc_resume_stream_cmd(out->ep->id) != AUDIO_STATUS_SUCCESS)
495 out->audio_state = AUDIO_A2DP_STATE_STARTED;
498 if (out->audio_state != AUDIO_A2DP_STATE_STARTED) {
499 DBG("stream not started");
503 /* TODO: encode data using codec */
508 static uint32_t out_get_sample_rate(const struct audio_stream *stream)
514 static int out_set_sample_rate(struct audio_stream *stream, uint32_t rate)
520 static size_t out_get_buffer_size(const struct audio_stream *stream)
526 static uint32_t out_get_channels(const struct audio_stream *stream)
532 static audio_format_t out_get_format(const struct audio_stream *stream)
538 static int out_set_format(struct audio_stream *stream, audio_format_t format)
544 static int out_standby(struct audio_stream *stream)
546 struct a2dp_stream_out *out = (struct a2dp_stream_out *) stream;
550 if (out->audio_state == AUDIO_A2DP_STATE_STARTED) {
551 if (ipc_suspend_stream_cmd(out->ep->id) != AUDIO_STATUS_SUCCESS)
553 out->audio_state = AUDIO_A2DP_STATE_STANDBY;
559 static int out_dump(const struct audio_stream *stream, int fd)
565 static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
567 struct a2dp_stream_out *out = (struct a2dp_stream_out *) stream;
571 bool enter_suspend = false;
572 bool exit_suspend = false;
576 str = strdup(kvpairs);
577 kvpair = strtok_r(str, ";", &saveptr);
579 for (; kvpair && *kvpair; kvpair = strtok_r(NULL, ";", &saveptr)) {
582 keyval = strchr(kvpair, '=');
589 if (!strcmp(kvpair, "closing")) {
590 if (!strcmp(keyval, "true"))
591 out->audio_state = AUDIO_A2DP_STATE_NONE;
592 } else if (!strcmp(kvpair, "A2dpSuspended")) {
593 if (!strcmp(keyval, "true"))
594 enter_suspend = true;
602 if (enter_suspend && out->audio_state == AUDIO_A2DP_STATE_STARTED) {
603 if (ipc_suspend_stream_cmd(out->ep->id) != AUDIO_STATUS_SUCCESS)
605 out->audio_state = AUDIO_A2DP_STATE_SUSPENDED;
608 if (exit_suspend && out->audio_state == AUDIO_A2DP_STATE_SUSPENDED)
609 out->audio_state = AUDIO_A2DP_STATE_STANDBY;
614 static char *out_get_parameters(const struct audio_stream *stream,
621 static uint32_t out_get_latency(const struct audio_stream_out *stream)
627 static int out_set_volume(struct audio_stream_out *stream, float left,
631 /* volume controlled in audioflinger mixer (digital) */
635 static int out_get_render_position(const struct audio_stream_out *stream,
636 uint32_t *dsp_frames)
642 static int out_add_audio_effect(const struct audio_stream *stream,
643 effect_handle_t effect)
649 static int out_remove_audio_effect(const struct audio_stream *stream,
650 effect_handle_t effect)
656 static uint32_t in_get_sample_rate(const struct audio_stream *stream)
662 static int in_set_sample_rate(struct audio_stream *stream, uint32_t rate)
668 static size_t in_get_buffer_size(const struct audio_stream *stream)
674 static uint32_t in_get_channels(const struct audio_stream *stream)
680 static audio_format_t in_get_format(const struct audio_stream *stream)
686 static int in_set_format(struct audio_stream *stream, audio_format_t format)
692 static int in_standby(struct audio_stream *stream)
698 static int in_dump(const struct audio_stream *stream, int fd)
704 static int in_set_parameters(struct audio_stream *stream, const char *kvpairs)
710 static char *in_get_parameters(const struct audio_stream *stream,
717 static int in_set_gain(struct audio_stream_in *stream, float gain)
723 static ssize_t in_read(struct audio_stream_in *stream, void *buffer,
730 static uint32_t in_get_input_frames_lost(struct audio_stream_in *stream)
736 static int in_add_audio_effect(const struct audio_stream *stream,
737 effect_handle_t effect)
743 static int in_remove_audio_effect(const struct audio_stream *stream,
744 effect_handle_t effect)
750 static int audio_open_output_stream(struct audio_hw_device *dev,
751 audio_io_handle_t handle,
752 audio_devices_t devices,
753 audio_output_flags_t flags,
754 struct audio_config *config,
755 struct audio_stream_out **stream_out)
758 struct a2dp_audio_dev *a2dp_dev = (struct a2dp_audio_dev *) dev;
759 struct a2dp_stream_out *out;
760 struct audio_preset *preset;
762 out = calloc(1, sizeof(struct a2dp_stream_out));
768 out->stream.common.get_sample_rate = out_get_sample_rate;
769 out->stream.common.set_sample_rate = out_set_sample_rate;
770 out->stream.common.get_buffer_size = out_get_buffer_size;
771 out->stream.common.get_channels = out_get_channels;
772 out->stream.common.get_format = out_get_format;
773 out->stream.common.set_format = out_set_format;
774 out->stream.common.standby = out_standby;
775 out->stream.common.dump = out_dump;
776 out->stream.common.set_parameters = out_set_parameters;
777 out->stream.common.get_parameters = out_get_parameters;
778 out->stream.common.add_audio_effect = out_add_audio_effect;
779 out->stream.common.remove_audio_effect = out_remove_audio_effect;
780 out->stream.get_latency = out_get_latency;
781 out->stream.set_volume = out_set_volume;
782 out->stream.write = out_write;
783 out->stream.get_render_position = out_get_render_position;
785 /* TODO: for now we always use endpoint 0 */
786 out->ep = &audio_endpoints[0];
788 if (ipc_open_stream_cmd(out->ep->id, &preset) != AUDIO_STATUS_SUCCESS)
794 /* TODO: initialize codec using received audio_preset */
798 *stream_out = &out->stream;
801 out->audio_state = AUDIO_A2DP_STATE_STANDBY;
811 static void audio_close_output_stream(struct audio_hw_device *dev,
812 struct audio_stream_out *stream)
814 struct a2dp_audio_dev *a2dp_dev = (struct a2dp_audio_dev *) dev;
815 struct audio_endpoint *ep = a2dp_dev->out->ep;
819 ipc_close_stream_cmd(ep->id);
821 /* TODO: cleanup codec */
824 a2dp_dev->out = NULL;
827 static int audio_set_parameters(struct audio_hw_device *dev,
834 static char *audio_get_parameters(const struct audio_hw_device *dev,
841 static int audio_init_check(const struct audio_hw_device *dev)
847 static int audio_set_voice_volume(struct audio_hw_device *dev, float volume)
853 static int audio_set_master_volume(struct audio_hw_device *dev, float volume)
859 static int audio_set_mode(struct audio_hw_device *dev, int mode)
865 static int audio_set_mic_mute(struct audio_hw_device *dev, bool state)
871 static int audio_get_mic_mute(const struct audio_hw_device *dev, bool *state)
877 static size_t audio_get_input_buffer_size(const struct audio_hw_device *dev,
878 const struct audio_config *config)
884 static int audio_open_input_stream(struct audio_hw_device *dev,
885 audio_io_handle_t handle,
886 audio_devices_t devices,
887 struct audio_config *config,
888 struct audio_stream_in **stream_in)
890 struct audio_stream_in *in;
894 in = calloc(1, sizeof(struct audio_stream_in));
898 in->common.get_sample_rate = in_get_sample_rate;
899 in->common.set_sample_rate = in_set_sample_rate;
900 in->common.get_buffer_size = in_get_buffer_size;
901 in->common.get_channels = in_get_channels;
902 in->common.get_format = in_get_format;
903 in->common.set_format = in_set_format;
904 in->common.standby = in_standby;
905 in->common.dump = in_dump;
906 in->common.set_parameters = in_set_parameters;
907 in->common.get_parameters = in_get_parameters;
908 in->common.add_audio_effect = in_add_audio_effect;
909 in->common.remove_audio_effect = in_remove_audio_effect;
910 in->set_gain = in_set_gain;
912 in->get_input_frames_lost = in_get_input_frames_lost;
919 static void audio_close_input_stream(struct audio_hw_device *dev,
920 struct audio_stream_in *stream_in)
926 static int audio_dump(const audio_hw_device_t *device, int fd)
932 static int audio_close(hw_device_t *device)
934 struct a2dp_audio_dev *a2dp_dev = (struct a2dp_audio_dev *)device;
938 pthread_mutex_lock(&close_mutex);
941 pthread_mutex_unlock(&close_mutex);
943 pthread_join(ipc_th, NULL);
952 static void *ipc_handler(void *data)
960 DBG("Waiting for connection ...");
961 audio_sk = accept(listen_sk, NULL, NULL);
964 error("audio: Failed to accept socket: %d (%s)", err,
969 DBG("Audio IPC: Connected");
971 if (register_endpoints() != AUDIO_STATUS_SUCCESS) {
972 error("audio: Failed to register endpoints");
974 unregister_endpoints();
976 shutdown(audio_sk, SHUT_RDWR);
980 memset(&pfd, 0, sizeof(pfd));
982 pfd.events = POLLHUP | POLLERR | POLLNVAL;
984 /* Check if socket is still alive. Empty while loop.*/
985 while (poll(&pfd, 1, -1) < 0 && errno == EINTR);
987 if (pfd.revents & (POLLHUP | POLLERR | POLLNVAL)) {
988 info("Audio HAL: Socket closed");
992 /*Check if audio_dev is closed */
993 pthread_mutex_lock(&close_mutex);
995 close_thread = false;
996 pthread_mutex_unlock(&close_mutex);
999 unregister_endpoints();
1001 info("Closing Audio IPC thread");
1005 static int audio_ipc_init(void)
1007 struct sockaddr_un addr;
1013 sk = socket(PF_LOCAL, SOCK_SEQPACKET, 0);
1016 error("audio: Failed to create socket: %d (%s)", err,
1021 memset(&addr, 0, sizeof(addr));
1022 addr.sun_family = AF_UNIX;
1024 memcpy(addr.sun_path, BLUEZ_AUDIO_SK_PATH,
1025 sizeof(BLUEZ_AUDIO_SK_PATH));
1027 if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
1029 error("audio: Failed to bind socket: %d (%s)", err,
1034 if (listen(sk, 1) < 0) {
1036 error("audio: Failed to listen on the socket: %d (%s)", err,
1043 err = pthread_create(&ipc_th, NULL, ipc_handler, NULL);
1047 error("audio: Failed to start Audio IPC thread: %d (%s)",
1048 err, strerror(err));
1059 static int audio_open(const hw_module_t *module, const char *name,
1060 hw_device_t **device)
1062 struct a2dp_audio_dev *a2dp_dev;
1067 if (strcmp(name, AUDIO_HARDWARE_INTERFACE)) {
1068 error("audio: interface %s not matching [%s]", name,
1069 AUDIO_HARDWARE_INTERFACE);
1073 err = audio_ipc_init();
1077 a2dp_dev = calloc(1, sizeof(struct a2dp_audio_dev));
1081 a2dp_dev->dev.common.version = AUDIO_DEVICE_API_VERSION_CURRENT;
1082 a2dp_dev->dev.common.module = (struct hw_module_t *) module;
1083 a2dp_dev->dev.common.close = audio_close;
1085 a2dp_dev->dev.init_check = audio_init_check;
1086 a2dp_dev->dev.set_voice_volume = audio_set_voice_volume;
1087 a2dp_dev->dev.set_master_volume = audio_set_master_volume;
1088 a2dp_dev->dev.set_mode = audio_set_mode;
1089 a2dp_dev->dev.set_mic_mute = audio_set_mic_mute;
1090 a2dp_dev->dev.get_mic_mute = audio_get_mic_mute;
1091 a2dp_dev->dev.set_parameters = audio_set_parameters;
1092 a2dp_dev->dev.get_parameters = audio_get_parameters;
1093 a2dp_dev->dev.get_input_buffer_size = audio_get_input_buffer_size;
1094 a2dp_dev->dev.open_output_stream = audio_open_output_stream;
1095 a2dp_dev->dev.close_output_stream = audio_close_output_stream;
1096 a2dp_dev->dev.open_input_stream = audio_open_input_stream;
1097 a2dp_dev->dev.close_input_stream = audio_close_input_stream;
1098 a2dp_dev->dev.dump = audio_dump;
1100 /* Note that &a2dp_dev->dev.common is the same pointer as a2dp_dev.
1101 * This results from the structure of following structs:a2dp_audio_dev,
1102 * audio_hw_device. We will rely on this later in the code.*/
1103 *device = &a2dp_dev->dev.common;
1108 static struct hw_module_methods_t hal_module_methods = {
1112 struct audio_module HAL_MODULE_INFO_SYM = {
1114 .tag = HARDWARE_MODULE_TAG,
1117 .id = AUDIO_HARDWARE_MODULE_ID,
1118 .name = "A2DP Bluez HW HAL",
1119 .author = "Intel Corporation",
1120 .methods = &hal_module_methods,