summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSangchul Lee <sc11.lee@samsung.com>2016-04-12 17:37:32 +0900
committerSangchul Lee <sc11.lee@samsung.com>2016-04-14 13:14:33 +0900
commitb2f735e4d71fc3eaef336644caef085c0ebdc9c0 (patch)
tree8f1748bbae712ce3a283cf0466373617bb86e59c
parent53cf9d7b07a2c25a06cee3f235f589efd138b755 (diff)
downloadaudio-hal-sc7727-b2f735e4d71fc3eaef336644caef085c0ebdc9c0.tar.gz
audio-hal-sc7727-b2f735e4d71fc3eaef336644caef085c0ebdc9c0.tar.bz2
audio-hal-sc7727-b2f735e4d71fc3eaef336644caef085c0ebdc9c0.zip
Modify logic to set devices properly when call-voice routing is changed before it gets a connection message from modemsubmit/tizen/20160414.044323accepted/tizen/mobile/20160414.092103
[Version] 0.1.8 [Profile] Common [Issue Type] Bug fix Change-Id: I08283fa735da8d2dc9b398bb1253e5d33a3b4bdd
-rw-r--r--packaging/audio-hal-sc7727.spec2
-rw-r--r--tizen-audio-device.c33
2 files changed, 28 insertions, 7 deletions
diff --git a/packaging/audio-hal-sc7727.spec b/packaging/audio-hal-sc7727.spec
index 82ff77e..c068660 100644
--- a/packaging/audio-hal-sc7727.spec
+++ b/packaging/audio-hal-sc7727.spec
@@ -1,6 +1,6 @@
Name: audio-hal-sc7727
Summary: TIZEN Audio HAL for SC7727
-Version: 0.1.7
+Version: 0.1.8
Release: 0
Group: System/Libraries
License: Apache-2.0
diff --git a/tizen-audio-device.c b/tizen-audio-device.c
index b58f84b..0f33117 100644
--- a/tizen-audio-device.c
+++ b/tizen-audio-device.c
@@ -354,6 +354,8 @@ audio_return_t audio_do_route(void *audio_handle, audio_route_info_t *info)
audio_hal_t *ah = (audio_hal_t *)audio_handle;
device_info_t *devices = NULL;
uint32_t prev_size;
+ int32_t i;
+ int32_t j;
AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
AUDIO_RETURN_VAL_IF_FAIL(info, AUDIO_ERR_PARAMETER);
@@ -376,12 +378,31 @@ audio_return_t audio_do_route(void *audio_handle, audio_route_info_t *info)
}
} else if (ah->device.num_of_call_devices) {
prev_size = ah->device.num_of_call_devices;
- ah->device.num_of_call_devices += info->num_of_devices;
- if ((ah->device.init_call_devices = (device_info_t*)realloc(ah->device.init_call_devices, sizeof(device_info_t)*ah->device.num_of_call_devices))) {
- memcpy((void*)&(ah->device.init_call_devices[prev_size]), devices, info->num_of_devices*sizeof(device_info_t));
+ if (prev_size == 2) {
+ /* There's a chance to be requested to change routing from user
+ * though two devices(for input/output) has already been set for call-voice routing.
+ * In this case, exchange an old device for a new device if it's direction is same as an old one's. */
+ for (i = 0; i < prev_size; i++) {
+ for (j = 0; j < info->num_of_devices; j++) {
+ if (devices[j].direction == ah->device.init_call_devices[i].direction &&
+ devices[j].id != ah->device.init_call_devices[i].id)
+ memcpy(&ah->device.init_call_devices[i], &devices[j], sizeof(device_info_t));
+ }
+ }
+ } else if (prev_size < 2) {
+ /* A device has already been added for call-voice routing,
+ * and now it is about to add a new device(input or output device). */
+ ah->device.num_of_call_devices += info->num_of_devices;
+ if ((ah->device.init_call_devices = (device_info_t*)realloc(ah->device.init_call_devices, sizeof(device_info_t)*ah->device.num_of_call_devices))) {
+ memcpy((void*)&(ah->device.init_call_devices[prev_size]), devices, info->num_of_devices*sizeof(device_info_t));
+ } else {
+ AUDIO_LOG_ERROR("failed to realloc");
+ audio_ret = AUDIO_ERR_RESOURCE;
+ goto ERROR;
+ }
} else {
- AUDIO_LOG_ERROR("failed to realloc");
- audio_ret = AUDIO_ERR_RESOURCE;
+ AUDIO_LOG_ERROR("invaild previous num. of call devices");
+ audio_ret = AUDIO_ERR_INTERNAL;
goto ERROR;
}
}
@@ -389,7 +410,7 @@ audio_return_t audio_do_route(void *audio_handle, audio_route_info_t *info)
AUDIO_LOG_ERROR("failed to do route for call-voice, num_of_devices is 0");
audio_ret = AUDIO_ERR_PARAMETER;
goto ERROR;
- }
+ }
AUDIO_LOG_INFO("modem is not ready, skip...");
} else {
audio_ret = _do_route_voicecall(ah, devices, info->num_of_devices);