diff options
author | Sangchul Lee <sc11.lee@samsung.com> | 2017-09-07 20:28:22 +0900 |
---|---|---|
committer | Sangchul Lee <sc11.lee@samsung.com> | 2017-09-07 20:55:16 +0900 |
commit | 927e03cb8e9565c3b90e67640420443e7cad7cd0 (patch) | |
tree | 95cfe7a6980dc10128014a85b477fec9c3b6e9fd | |
parent | ff9c862565ef111b4ff0aaad8fd91705d4e1c543 (diff) | |
download | audio-hal-wm1831-tw2-927e03cb8e9565c3b90e67640420443e7cad7cd0.tar.gz audio-hal-wm1831-tw2-927e03cb8e9565c3b90e67640420443e7cad7cd0.tar.bz2 audio-hal-wm1831-tw2-927e03cb8e9565c3b90e67640420443e7cad7cd0.zip |
Set BT SCO devices only after obtaining 'bt-sco-ready' from routing optiontizen_4.0.IoT.p1_releasesubmit/tizen_4.0/20170913.051439submit/tizen_4.0/20170913.051218accepted/tizen/4.0/unified/20170913.153838
In this target, there are several UCM BT SCO devices depending on its bandwidth
and network bandwidth. To work well, BT bandwidth should be got right after
BT SCO is ready. This patch makes it possible to set the BT SCO device properly
by keeping the call sequences with 'bt-sco-ready' and 'bt-wideband' options.
[Version] 0.1.7
[Profile] Wearable
[Issue Type] Enhancement
Change-Id: I079328c55e299acb7b9ea8b3dba0b42dfd95ca8b
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
-rw-r--r-- | packaging/audio-hal-wm1831-tw2.spec | 2 | ||||
-rw-r--r-- | tizen-audio-internal.h | 5 | ||||
-rw-r--r-- | tizen-audio-routing.c | 71 |
3 files changed, 69 insertions, 9 deletions
diff --git a/packaging/audio-hal-wm1831-tw2.spec b/packaging/audio-hal-wm1831-tw2.spec index 4832c75..152496a 100644 --- a/packaging/audio-hal-wm1831-tw2.spec +++ b/packaging/audio-hal-wm1831-tw2.spec @@ -1,6 +1,6 @@ Name: audio-hal-wm1831-tw2 Summary: TIZEN Audio HAL for WM1831(TW2) -Version: 0.1.6 +Version: 0.1.7 Release: 0 Group: System/Libraries License: Apache-2.0 diff --git a/tizen-audio-internal.h b/tizen-audio-internal.h index d1a3867..862ba5c 100644 --- a/tizen-audio-internal.h +++ b/tizen-audio-internal.h @@ -203,6 +203,7 @@ typedef struct audio_hal_device { audio_pcm_devices_t bt_pcm; audio_route_mode_t mode; bool bt_wideband; + bool bt_sco_ready; } audio_hal_device_t; /* Volume */ @@ -292,11 +293,13 @@ typedef enum audio_sample_format { } audio_sample_format_t; /* Overall */ +#define MAX_DIRECTION 2 typedef struct audio_hal { audio_hal_device_t device; audio_hal_volume_t volume; audio_hal_ucm_t ucm; audio_hal_mixer_t mixer; + audio_route_info_t *saved_route_infos[MAX_DIRECTION]; bool call_wideband; } audio_hal_t; @@ -309,8 +312,6 @@ audio_return_t _audio_stream_deinit(audio_hal_t *ah); audio_return_t _audio_pcm_init(audio_hal_t *ah); audio_return_t _audio_pcm_deinit(audio_hal_t *ah); -audio_return_t _audio_update_route_voicecall(audio_hal_t *ah, device_info_t *devices, int32_t num_of_devices); - typedef struct _dump_data { char *strbuf; int left; diff --git a/tizen-audio-routing.c b/tizen-audio-routing.c index fa47e8f..1b43573 100644 --- a/tizen-audio-routing.c +++ b/tizen-audio-routing.c @@ -209,6 +209,51 @@ static audio_return_t __set_devices(audio_hal_t *ah, const char *verb, device_in return audio_ret; } +static audio_return_t __save_route_infos(audio_hal_t *ah, device_info_t *devices, int32_t num_of_devices) +{ + int i = 0; + + AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER); + AUDIO_RETURN_VAL_IF_FAIL(devices, AUDIO_ERR_PARAMETER); + + for (i = 0; i < MAX_DIRECTION; i++) { + if (!ah->saved_route_infos[i]) { + ah->saved_route_infos[i] = malloc(sizeof(audio_route_info_t)); + memset(ah->saved_route_infos[i], 0, sizeof(audio_route_info_t)); + + ah->saved_route_infos[i]->device_infos = malloc(sizeof(device_info_t)); + memcpy(ah->saved_route_infos[i]->device_infos, devices, sizeof(device_info_t)); + + ah->saved_route_infos[i]->num_of_devices = num_of_devices; + + AUDIO_LOG_INFO("SAVE route infos[%d]: device_infos->type[%s],id[%u]", + i, ah->saved_route_infos[i]->device_infos->type, ah->saved_route_infos[i]->device_infos->id); + return AUDIO_RET_OK; + } + } + + AUDIO_LOG_ERROR("could not find empty slot to save route infos"); + return AUDIO_ERR_INTERNAL; +} + +static void __reset_saved_route_infos(void *audio_handle) +{ + audio_hal_t *ah = (audio_hal_t *)audio_handle; + int i = 0; + + AUDIO_RETURN_IF_FAIL(ah); + + for (i = 0; i < MAX_DIRECTION; i++) { + if (ah->saved_route_infos[i]) { + if (ah->saved_route_infos[i]->device_infos) + free(ah->saved_route_infos[i]->device_infos); + free(ah->saved_route_infos[i]); + ah->saved_route_infos[i] = NULL; + AUDIO_LOG_INFO("reset saved route infos[%d] well", i); + } + } +} + static audio_return_t __update_route_ap_playback_capture(audio_hal_t *ah, audio_route_info_t *route_info) { audio_return_t audio_ret = AUDIO_RET_OK; @@ -246,6 +291,10 @@ static audio_return_t __update_route_voicecall(audio_hal_t *ah, device_info_t *d AUDIO_LOG_INFO("update_route_voicecall++"); + if (!strncmp(devices[0].type, "bt-sco", MAX_NAME_LEN)) + if (!ah->device.bt_sco_ready) + return __save_route_infos(ah, devices, num_of_devices); + if ((audio_ret = __set_devices(ah, verb, devices, num_of_devices))) { AUDIO_LOG_ERROR("Failed to set devices: error = 0x%x", audio_ret); return audio_ret; @@ -422,6 +471,8 @@ static audio_return_t __update_route_reset(audio_hal_t *ah, uint32_t direction) } } + __reset_saved_route_infos(ah); + if (active_devices[0] == NULL) { AUDIO_LOG_DEBUG("active device is NULL, no need to update."); return AUDIO_RET_OK; @@ -433,15 +484,11 @@ static audio_return_t __update_route_reset(audio_hal_t *ah, uint32_t direction) /* reset bandwidth information */ ah->device.bt_wideband = false; ah->call_wideband = false; + ah->device.bt_sco_ready = false; return audio_ret; } -audio_return_t _audio_update_route_voicecall(audio_hal_t *ah, device_info_t *devices, int32_t num_of_devices) -{ - return __update_route_voicecall(ah, devices, num_of_devices); -} - audio_return_t _audio_routing_init(audio_hal_t *ah) { audio_return_t audio_ret = AUDIO_RET_OK; @@ -527,10 +574,22 @@ audio_return_t audio_update_route_option(void *audio_handle, audio_route_option_ ah->device.bt_wideband = (option->value > 0) ? true : false; } else if (!strncmp("call-wideband", option->name, MAX_NAME_LEN)) { ah->call_wideband = (option->value > 0) ? true : false; + } else if (!strncmp("bt-sco-ready", option->name, MAX_NAME_LEN)) { + ah->device.bt_sco_ready = (option->value > 0) ? true : false; + if (ah->device.bt_sco_ready) { + int i = 0; + for (i = 0; i < MAX_DIRECTION; i++) { + if (ah->saved_route_infos[i]) { + if ((audio_ret = __update_route_voicecall(ah, ah->saved_route_infos[i]->device_infos, ah->saved_route_infos[i]->num_of_devices))) + AUDIO_LOG_WARN("update voicecall route from SAVED return 0x%x", audio_ret); + } + } + } + __reset_saved_route_infos(ah); } else { AUDIO_LOG_ERROR("undefined route option"); audio_ret = AUDIO_ERR_UNDEFINED; } return audio_ret; -} +}
\ No newline at end of file |