diff options
author | Andrei Emeltchenko <andrei.emeltchenko@intel.com> | 2014-07-18 12:48:14 +0300 |
---|---|---|
committer | Szymon Janc <szymon.janc@tieto.com> | 2014-07-18 13:41:22 +0200 |
commit | 946d78cd078db1a4c32dbb25108fbe8dd30f079c (patch) | |
tree | ad24abbbf89a47e4efdf280c58a436dc83369fdd /android/hal-sco.c | |
parent | 47a539d67f298775e09b374f0d69e23310c6e4ed (diff) | |
download | bluez-946d78cd078db1a4c32dbb25108fbe8dd30f079c.tar.gz |
android/hal-sco: Get SCO audio fd on demand
When SCO fd is not known try to get it from the daemon. SCO is
established via handsfree HAL independently from Audio HAL.
Diffstat (limited to 'android/hal-sco.c')
-rw-r--r-- | android/hal-sco.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/android/hal-sco.c b/android/hal-sco.c index 79c13dca8..1627b833d 100644 --- a/android/hal-sco.c +++ b/android/hal-sco.c @@ -280,15 +280,16 @@ failed: static int ipc_connect_sco(void) { - struct sco_rsp_connect rsp; - size_t rsp_len = sizeof(rsp); int ret = SCO_STATUS_SUCCESS; - DBG(""); - pthread_mutex_lock(&sco_mutex); if (sco_fd < 0) { + struct sco_rsp_connect rsp; + size_t rsp_len = sizeof(rsp); + + DBG("Connecting SCO"); + ret = sco_ipc_cmd(SCO_SERVICE_ID, SCO_OP_CONNECT, 0, NULL, &rsp_len, &rsp, &sco_fd); @@ -445,7 +446,7 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, DBG("write to fd %d bytes %zu", sco_fd, bytes); - if (sco_fd < 0) + if (ipc_connect_sco() != SCO_STATUS_SUCCESS) return -1; if (!out->downmix_buf) { @@ -1009,7 +1010,7 @@ static ssize_t in_read(struct audio_stream_in *stream, void *buffer, DBG("Read from fd %d bytes %zu", sco_fd, bytes); - if (sco_fd < 0) + if (ipc_connect_sco() != SCO_STATUS_SUCCESS) return -1; if (!in->resampler && in->cfg.rate != AUDIO_STREAM_SCO_RATE) { |