summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeungbae Shin <seungbae.shin@samsung.com>2015-12-07 20:16:22 +0900
committerSeungbae Shin <seungbae.shin@samsung.com>2015-12-14 16:14:32 +0900
commit0a60c4614c53fc9dc99389f0ada0aedc60238c98 (patch)
treeacf1b28cc1754ec4af70d607e8d7d604aef4431c
parentaf9737e49951c0f79cd96cb98936cec71f873310 (diff)
downloadaudio-hal-max98090-0a60c4614c53fc9dc99389f0ada0aedc60238c98.tar.gz
audio-hal-max98090-0a60c4614c53fc9dc99389f0ada0aedc60238c98.tar.bz2
audio-hal-max98090-0a60c4614c53fc9dc99389f0ada0aedc60238c98.zip
Change-Id: I3d914615f8092bff648b0464fb3d216acd383dc8
-rw-r--r--tizen-audio-device.c27
-rw-r--r--tizen-audio-internal.h12
-rw-r--r--tizen-audio-ucm.c103
-rw-r--r--tizen-audio-util.c76
-rw-r--r--tizen-audio-volume.c6
-rw-r--r--tizen-audio.c4
6 files changed, 137 insertions, 91 deletions
diff --git a/tizen-audio-device.c b/tizen-audio-device.c
index 8a522d7..b39790a 100644
--- a/tizen-audio-device.c
+++ b/tizen-audio-device.c
@@ -50,23 +50,23 @@ static uint32_t convert_device_string_to_enum(const char* device_str, uint32_t d
{
uint32_t device = 0;
- if (!strncmp(device_str,"builtin-speaker", MAX_NAME_LEN)) {
+ if (!strncmp(device_str, "builtin-speaker", MAX_NAME_LEN)) {
device = AUDIO_DEVICE_OUT_SPEAKER;
- } else if (!strncmp(device_str,"builtin-receiver", MAX_NAME_LEN)) {
+ } else if (!strncmp(device_str, "builtin-receiver", MAX_NAME_LEN)) {
device = AUDIO_DEVICE_OUT_RECEIVER;
- } else if ((!strncmp(device_str,"audio-jack", MAX_NAME_LEN)) && (direction == AUDIO_DIRECTION_OUT)) {
+ } else if ((!strncmp(device_str, "audio-jack", MAX_NAME_LEN)) && (direction == AUDIO_DIRECTION_OUT)) {
device = AUDIO_DEVICE_OUT_JACK;
- } else if ((!strncmp(device_str,"bt", MAX_NAME_LEN)) && (direction == AUDIO_DIRECTION_OUT)) {
+ } else if ((!strncmp(device_str, "bt", MAX_NAME_LEN)) && (direction == AUDIO_DIRECTION_OUT)) {
device = AUDIO_DEVICE_OUT_BT_SCO;
- } else if (!strncmp(device_str,"aux", MAX_NAME_LEN)) {
+ } else if (!strncmp(device_str, "aux", MAX_NAME_LEN)) {
device = AUDIO_DEVICE_OUT_AUX;
- } else if (!strncmp(device_str,"hdmi", MAX_NAME_LEN)) {
+ } else if (!strncmp(device_str, "hdmi", MAX_NAME_LEN)) {
device = AUDIO_DEVICE_OUT_HDMI;
- } else if ((!strncmp(device_str,"builtin-mic", MAX_NAME_LEN))) {
+ } else if ((!strncmp(device_str, "builtin-mic", MAX_NAME_LEN))) {
device = AUDIO_DEVICE_IN_MAIN_MIC;
- } else if ((!strncmp(device_str,"audio-jack", MAX_NAME_LEN)) && (direction == AUDIO_DIRECTION_IN)) {
+ } else if ((!strncmp(device_str, "audio-jack", MAX_NAME_LEN)) && (direction == AUDIO_DIRECTION_IN)) {
device = AUDIO_DEVICE_IN_JACK;
- } else if ((!strncmp(device_str,"bt", MAX_NAME_LEN)) && (direction == AUDIO_DIRECTION_IN)) {
+ } else if ((!strncmp(device_str, "bt", MAX_NAME_LEN)) && (direction == AUDIO_DIRECTION_IN)) {
device = AUDIO_DEVICE_IN_BT_SCO;
} else {
device = AUDIO_DEVICE_NONE;
@@ -210,7 +210,6 @@ audio_return_t _do_route_voip(audio_hal_t *ah, device_info_t *devices, int32_t n
{
audio_return_t audio_ret = AUDIO_RET_OK;
const char *verb = NULL;
- const char *active_devices[MAX_DEVICES] = {NULL,};
verb = AUDIO_USE_CASE_VERB_HIFI;
AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
@@ -225,10 +224,6 @@ audio_return_t _do_route_voip(audio_hal_t *ah, device_info_t *devices, int32_t n
}
/* FIXME. If necessary, set VERB_VOIP */
ah->device.mode = VERB_NORMAL;
- if (active_devices == NULL) {
- AUDIO_LOG_ERROR("Failed to set device: active device is NULL");
- return AUDIO_ERR_PARAMETER;
- }
/* TO DO: Set modifiers */
return audio_ret;
@@ -390,7 +385,7 @@ audio_return_t audio_pcm_open(void *audio_handle, void **pcm_handle, uint32_t di
ah = (audio_hal_t *)audio_handle;
mode = SND_PCM_NONBLOCK | SND_PCM_NO_AUTO_RESAMPLE | SND_PCM_NO_AUTO_CHANNELS | SND_PCM_NO_AUTO_FORMAT;
- if(direction == AUDIO_DIRECTION_OUT)
+ if (direction == AUDIO_DIRECTION_OUT)
device_name = PLAYBACK_PCM_DEVICE;
else if (direction == AUDIO_DIRECTION_IN)
device_name = CAPTURE_PCM_DEVICE;
@@ -894,7 +889,7 @@ audio_return_t audio_pcm_set_params(void *audio_handle, void *pcm_handle, uint32
}
/* Set sw params */
- if ((err = snd_pcm_sw_params_current(pcm_handle, swparams) < 0)) {
+ if ((err = snd_pcm_sw_params_current(pcm_handle, swparams)) < 0) {
AUDIO_LOG_ERROR("Unable to determine current swparams : %d", err);
return AUDIO_ERR_PARAMETER;
}
diff --git a/tizen-audio-internal.h b/tizen-audio-internal.h
index d389e2d..c9fadb7 100644
--- a/tizen-audio-internal.h
+++ b/tizen-audio-internal.h
@@ -320,4 +320,16 @@ audio_return_t _audio_mixer_control_get_element(audio_hal_t *ah, const char *ctl
audio_return_t _audio_pcm_set_sw_params(snd_pcm_t *pcm, snd_pcm_uframes_t avail_min, uint8_t period_event);
audio_return_t _audio_pcm_set_hw_params(snd_pcm_t *pcm, audio_pcm_sample_spec_t *sample_spec, uint8_t *use_mmap, snd_pcm_uframes_t *period_size, snd_pcm_uframes_t *buffer_size);
uint32_t _convert_format(audio_sample_format_t format);
+
+typedef struct _dump_data {
+ char *strbuf;
+ int left;
+ char *p;
+} dump_data_t;
+
+dump_data_t* dump_new(int length);
+void dump_add_str(dump_data_t *dump, const char *fmt, ...);
+char* dump_get_str(dump_data_t *dump);
+void dump_free(dump_data_t *dump);
+
#endif
diff --git a/tizen-audio-ucm.c b/tizen-audio-ucm.c
index 6f9faaf..2bc1aa4 100644
--- a/tizen-audio-ucm.c
+++ b/tizen-audio-ucm.c
@@ -37,6 +37,10 @@
#define SND_USE_CASE_SET snd_use_case_set
#endif
+#define UCM_PREFIX_CURRENT ">>> UCM current"
+#define UCM_PREFIX_REQUESTED "> UCM requested"
+#define UCM_PREFIX_CHANGED "<<< UCM changed"
+
audio_return_t _audio_ucm_init(audio_hal_t *ah)
{
AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
@@ -63,16 +67,14 @@ audio_return_t _audio_ucm_deinit(audio_hal_t *ah)
void _audio_ucm_get_device_name(audio_hal_t *ah, const char *use_case, audio_direction_t direction, const char **value)
{
- char identifier[70] = {0};
+ char identifier[70] = { 0, };
AUDIO_RETURN_IF_FAIL(ah);
AUDIO_RETURN_IF_FAIL(ah->ucm.uc_mgr);
- if (direction == AUDIO_DIRECTION_IN) {
- sprintf(identifier, "CapturePCM//%s", use_case);
- } else {
- sprintf(identifier, "PlaybackPCM//%s", use_case);
- }
+ snprintf(identifier, sizeof(identifier), "%sPCM//%s",
+ (direction == AUDIO_DIRECTION_IN) ? "Capture" : "Playback", use_case);
+
snd_use_case_get(ah->ucm.uc_mgr, identifier, value);
}
@@ -131,43 +133,40 @@ int _audio_ucm_fill_device_info_list(audio_hal_t *ah, audio_device_info_t *devic
return device_info_count;
}
-static void __dump_use_case(const char *verb, const char *devices[], int dev_count, const char *modifiers[], int mod_count, char *dump)
+#define DUMP_LEN 512
+
+static void __dump_use_case(const char* prefix, const char *verb, const char *devices[], int dev_count, const char *modifiers[], int mod_count)
{
- int i, len;
+ int i;
+ dump_data_t* dump = NULL;
+
+ if (!(dump = dump_new(DUMP_LEN))) {
+ AUDIO_LOG_ERROR("Failed to create dump string...");
+ return;
+ }
- len = sprintf(dump, "Verb [ %s ] Devices [ ", verb ? verb : AUDIO_USE_CASE_VERB_INACTIVE);
- if (len > 0)
- dump += len;
+ /* Verb */
+ dump_add_str(dump, "Verb [ %s ] Devices [ ", verb ? verb : AUDIO_USE_CASE_VERB_INACTIVE);
- for (i = 0; i < dev_count; i++) {
- if (i != dev_count - 1) {
- len = sprintf(dump, "%s, ", devices[i]);
- } else {
- len = sprintf(dump, "%s", devices[i]);
+ /* Devices */
+ if (devices) {
+ for (i = 0; i < dev_count; i++) {
+ dump_add_str(dump, (i != dev_count - 1) ? "%s, " : "%s", devices[i]);
}
- if (len > 0)
- dump += len;
}
+ dump_add_str(dump, " ] Modifier [ ");
- len = sprintf(dump, " ] Modifier [ ");
- if (len > 0)
- dump += len;
-
- for (i = 0; i < mod_count; i++) {
- if (i != mod_count - 1) {
- len = sprintf(dump, "%s, ", modifiers[i]);
- } else {
- len = sprintf(dump, "%s", modifiers[i]);
+ /* Modifiers */
+ if (modifiers) {
+ for (i = 0; i < mod_count; i++) {
+ dump_add_str(dump, (i != mod_count - 1) ? "%s, " : "%s", modifiers[i]);
}
- if (len > 0)
- dump += len;
}
+ dump_add_str(dump, " ]");
- len = sprintf(dump, " ]");
- if (len > 0)
- dump += len;
+ AUDIO_LOG_INFO("TEST %s : %s", prefix, dump_get_str(dump));
- *dump = '\0';
+ dump_free(dump);
}
#ifdef ALSA_UCM_DEBUG_TIME
@@ -214,7 +213,6 @@ audio_return_t _audio_ucm_set_use_case(audio_hal_t *ah, const char *verb, const
int dis_dev_count = 0, ena_dev_count = 0;
int dis_mod_count = 0, ena_mod_count = 0;
int i = 0, j = 0;
- char dump_str[512];
AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
AUDIO_RETURN_VAL_IF_FAIL(ah->ucm.uc_mgr, AUDIO_ERR_PARAMETER);
@@ -223,8 +221,7 @@ audio_return_t _audio_ucm_set_use_case(audio_hal_t *ah, const char *verb, const
snd_use_case_get(ah->ucm.uc_mgr, "_verb", &old_verb);
old_dev_count = snd_use_case_get_list(ah->ucm.uc_mgr, "_enadevs", &old_dev_list);
old_mod_count = snd_use_case_get_list(ah->ucm.uc_mgr, "_enamods", &old_mod_list);
- __dump_use_case(old_verb, old_dev_list, old_dev_count, old_mod_list, old_mod_count, &dump_str[0]);
- AUDIO_LOG_INFO(">>> UCM current %s", dump_str);
+ __dump_use_case(UCM_PREFIX_CURRENT, old_verb, old_dev_list, old_dev_count, old_mod_list, old_mod_count);
if (devices) {
for (dev_count = 0; devices[dev_count]; dev_count++);
@@ -233,8 +230,7 @@ audio_return_t _audio_ucm_set_use_case(audio_hal_t *ah, const char *verb, const
for (mod_count = 0; modifiers[mod_count]; mod_count++);
}
- __dump_use_case(verb, devices, dev_count, modifiers, mod_count, &dump_str[0]);
- AUDIO_LOG_INFO("> UCM requested %s", dump_str);
+ __dump_use_case(UCM_PREFIX_REQUESTED, verb, devices, dev_count, modifiers, mod_count);
if (old_verb && streq(verb, old_verb)) {
AUDIO_LOG_DEBUG("current verb and new verb is same. No need to change verb, disable devices explicitely");
@@ -372,13 +368,13 @@ audio_return_t _audio_ucm_set_use_case(audio_hal_t *ah, const char *verb, const
/* enable devices */
for (i = 0; i < dev_count; i++) {
AUDIO_LOG_DEBUG("Enable device : %s", devices[i]);
- if(snd_use_case_set(ah->ucm.uc_mgr, "_enadev", devices[i]) < 0)
+ if (snd_use_case_set(ah->ucm.uc_mgr, "_enadev", devices[i]) < 0)
AUDIO_LOG_ERROR("Enable %s device failed", devices[i]);
}
/* enable modifiers */
for (i = 0; i < mod_count; i++) {
AUDIO_LOG_DEBUG("Enable modifier : %s", modifiers[i]);
- if(snd_use_case_set(ah->ucm.uc_mgr, "_enamod", modifiers[i]) < 0)
+ if (snd_use_case_set(ah->ucm.uc_mgr, "_enamod", modifiers[i]) < 0)
AUDIO_LOG_ERROR("Enable %s modifier failed", modifiers[i]);
}
}
@@ -406,8 +402,7 @@ exit:
snd_use_case_get(ah->ucm.uc_mgr, "_verb", &new_verb);
new_dev_count = snd_use_case_get_list(ah->ucm.uc_mgr, "_enadevs", &new_dev_list);
new_mod_count = snd_use_case_get_list(ah->ucm.uc_mgr, "_enamods", &new_mod_list);
- __dump_use_case(new_verb, new_dev_list, new_dev_count, new_mod_list, new_mod_count, &dump_str[0]);
- AUDIO_LOG_INFO("<<< UCM changed %s", dump_str);
+ __dump_use_case(UCM_PREFIX_CHANGED, new_verb, new_dev_list, new_dev_count, new_mod_list, new_mod_count);
if (new_verb)
free((void *)new_verb);
@@ -429,7 +424,6 @@ audio_return_t _audio_ucm_set_devices(audio_hal_t *ah, const char *verb, const c
const char **dis_dev_list = NULL, **ena_dev_list = NULL;
int dis_dev_count = 0, ena_dev_count = 0;
int i = 0, j = 0;
- char dump_str[512];
AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
AUDIO_RETURN_VAL_IF_FAIL(ah->ucm.uc_mgr, AUDIO_ERR_PARAMETER);
@@ -438,15 +432,13 @@ audio_return_t _audio_ucm_set_devices(audio_hal_t *ah, const char *verb, const c
snd_use_case_get(ah->ucm.uc_mgr, "_verb", &old_verb);
old_dev_count = snd_use_case_get_list(ah->ucm.uc_mgr, "_enadevs", &old_dev_list);
- __dump_use_case(old_verb, old_dev_list, old_dev_count, NULL, 0, &dump_str[0]);
- AUDIO_LOG_INFO(">>> UCM current %s", dump_str);
+ __dump_use_case(UCM_PREFIX_CURRENT, old_verb, old_dev_list, old_dev_count, NULL, 0);
if (devices) {
for (dev_count = 0; devices[dev_count]; dev_count++);
}
- __dump_use_case(verb, devices, dev_count, NULL, 0, &dump_str[0]);
- AUDIO_LOG_INFO("> UCM requested %s", dump_str);
+ __dump_use_case(UCM_PREFIX_REQUESTED, verb, devices, dev_count, NULL, 0);
if (old_verb && streq(verb, old_verb)) {
AUDIO_LOG_DEBUG("current verb and new verb is same. No need to change verb, disable devices explicitely");
@@ -525,7 +517,7 @@ audio_return_t _audio_ucm_set_devices(audio_hal_t *ah, const char *verb, const c
/* enable devices */
for (i = 0; i < dev_count; i++) {
AUDIO_LOG_DEBUG("Enable device : %s", devices[i]);
- if(snd_use_case_set(ah->ucm.uc_mgr, "_enadev", devices[i]) < 0)
+ if (snd_use_case_set(ah->ucm.uc_mgr, "_enadev", devices[i]) < 0)
AUDIO_LOG_ERROR("Enable %s device failed", devices[i]);
}
}
@@ -546,8 +538,7 @@ exit:
snd_use_case_get(ah->ucm.uc_mgr, "_verb", &new_verb);
new_dev_count = snd_use_case_get_list(ah->ucm.uc_mgr, "_enadevs", &new_dev_list);
- __dump_use_case(new_verb, new_dev_list, new_dev_count, NULL, 0, &dump_str[0]);
- AUDIO_LOG_INFO("<<< UCM changed %s", dump_str);
+ __dump_use_case(UCM_PREFIX_CHANGED, new_verb, new_dev_list, new_dev_count, NULL, 0);
if (new_verb)
free((void *)new_verb);
@@ -568,7 +559,6 @@ audio_return_t _audio_ucm_set_modifiers(audio_hal_t *ah, const char *verb, const
const char **dis_mod_list = NULL, **ena_mod_list = NULL;
int dis_mod_count = 0, ena_mod_count = 0;
int i = 0, j = 0;
- char dump_str[512];
AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
AUDIO_RETURN_VAL_IF_FAIL(ah->ucm.uc_mgr, AUDIO_ERR_PARAMETER);
@@ -577,15 +567,13 @@ audio_return_t _audio_ucm_set_modifiers(audio_hal_t *ah, const char *verb, const
snd_use_case_get(ah->ucm.uc_mgr, "_verb", &old_verb);
old_mod_count = snd_use_case_get_list(ah->ucm.uc_mgr, "_enamods", &old_mod_list);
- __dump_use_case(old_verb, NULL, 0, old_mod_list, old_mod_count, &dump_str[0]);
- AUDIO_LOG_INFO(">>> UCM current %s", dump_str);
+ __dump_use_case(UCM_PREFIX_CURRENT, old_verb, NULL, 0, old_mod_list, old_mod_count);
if (modifiers) {
for (mod_count = 0; modifiers[mod_count]; mod_count++);
}
- __dump_use_case(verb, NULL, 0, modifiers, mod_count, &dump_str[0]);
- AUDIO_LOG_INFO("> UCM requested %s", dump_str);
+ __dump_use_case(UCM_PREFIX_REQUESTED, verb, NULL, 0, modifiers, mod_count);
if (old_verb && streq(verb, old_verb)) {
AUDIO_LOG_DEBUG("current verb and new verb is same. No need to change verb, disable devices explicitely");
@@ -663,7 +651,7 @@ audio_return_t _audio_ucm_set_modifiers(audio_hal_t *ah, const char *verb, const
/* enable modifiers */
for (i = 0; i < mod_count; i++) {
AUDIO_LOG_DEBUG("Enable modifier : %s", modifiers[i]);
- if(snd_use_case_set(ah->ucm.uc_mgr, "_enamod", modifiers[i]) < 0)
+ if (snd_use_case_set(ah->ucm.uc_mgr, "_enamod", modifiers[i]) < 0)
AUDIO_LOG_ERROR("Enable %s modifier failed", modifiers[i]);
}
}
@@ -684,8 +672,7 @@ exit:
snd_use_case_get(ah->ucm.uc_mgr, "_verb", &new_verb);
new_mod_count = snd_use_case_get_list(ah->ucm.uc_mgr, "_enamods", &new_mod_list);
- __dump_use_case(new_verb, NULL, 0, new_mod_list, new_mod_count, &dump_str[0]);
- AUDIO_LOG_INFO("<<< UCM changed %s", dump_str);
+ __dump_use_case(UCM_PREFIX_CHANGED, new_verb, NULL, 0, new_mod_list, new_mod_count);
if (new_verb)
free((void *)new_verb);
diff --git a/tizen-audio-util.c b/tizen-audio-util.c
index 00b09ce..4e06923 100644
--- a/tizen-audio-util.c
+++ b/tizen-audio-util.c
@@ -99,7 +99,7 @@ audio_return_t _audio_mixer_control_get_value(audio_hal_t *ah, const char *ctl_n
ret = snd_ctl_open(&handle, ALSA_DEFAULT_CARD, 0);
if (ret < 0) {
- AUDIO_LOG_ERROR ("snd_ctl_open error, %s\n", snd_strerror(ret));
+ AUDIO_LOG_ERROR("snd_ctl_open error, %s\n", snd_strerror(ret));
pthread_mutex_unlock(&(ah->mixer.mutex));
return AUDIO_ERR_IOCTL;
}
@@ -114,8 +114,8 @@ audio_return_t _audio_mixer_control_get_value(audio_hal_t *ah, const char *ctl_n
snd_ctl_elem_id_set_name(id, ctl_name);
snd_ctl_elem_info_set_id(info, id);
- if(snd_ctl_elem_info(handle, info) < 0 ) {
- AUDIO_LOG_ERROR ("Cannot find control element: %s\n", ctl_name);
+ if (snd_ctl_elem_info(handle, info) < 0) {
+ AUDIO_LOG_ERROR("Cannot find control element: %s\n", ctl_name);
goto close;
}
snd_ctl_elem_info_get_id(info, id);
@@ -125,8 +125,8 @@ audio_return_t _audio_mixer_control_get_value(audio_hal_t *ah, const char *ctl_n
snd_ctl_elem_value_set_id(control, id);
- if(snd_ctl_elem_read(handle, control) < 0) {
- AUDIO_LOG_ERROR ("snd_ctl_elem_read failed \n");
+ if (snd_ctl_elem_read(handle, control) < 0) {
+ AUDIO_LOG_ERROR("snd_ctl_elem_read failed \n");
goto close;
}
@@ -143,7 +143,7 @@ audio_return_t _audio_mixer_control_get_value(audio_hal_t *ah, const char *ctl_n
*val = snd_ctl_elem_value_get_enumerated(control, i);
break;
default:
- AUDIO_LOG_WARN ("unsupported control element type\n");
+ AUDIO_LOG_WARN("unsupported control element type\n");
goto close;
}
@@ -157,7 +157,7 @@ audio_return_t _audio_mixer_control_get_value(audio_hal_t *ah, const char *ctl_n
return AUDIO_RET_OK;
close:
- AUDIO_LOG_ERROR ("Error\n");
+ AUDIO_LOG_ERROR("Error\n");
snd_ctl_close(handle);
pthread_mutex_unlock(&(ah->mixer.mutex));
return AUDIO_ERR_UNDEFINED;
@@ -196,7 +196,7 @@ audio_return_t _audio_mixer_control_set_value(audio_hal_t *ah, const char *ctl_n
snd_ctl_elem_id_set_name(id, ctl_name);
snd_ctl_elem_info_set_id(info, id);
- if(snd_ctl_elem_info(handle, info) < 0 ) {
+ if (snd_ctl_elem_info(handle, info) < 0) {
AUDIO_LOG_ERROR("Cannot find control element: %s", ctl_name);
goto close;
}
@@ -216,11 +216,11 @@ audio_return_t _audio_mixer_control_set_value(audio_hal_t *ah, const char *ctl_n
break;
case SND_CTL_ELEM_TYPE_INTEGER:
for (i = 0; i < count; i++)
- snd_ctl_elem_value_set_integer(control, i,val);
+ snd_ctl_elem_value_set_integer(control, i, val);
break;
case SND_CTL_ELEM_TYPE_ENUMERATED:
for (i = 0; i < count; i++)
- snd_ctl_elem_value_set_enumerated(control, i,val);
+ snd_ctl_elem_value_set_enumerated(control, i, val);
break;
default:
@@ -321,7 +321,7 @@ audio_return_t _audio_pcm_set_hw_params(snd_pcm_t *pcm, audio_pcm_sample_spec_t
snd_pcm_hw_params_alloca(&hwparams);
/* Fill it in with default values. */
- if(snd_pcm_hw_params_any(pcm, hwparams) < 0) {
+ if (snd_pcm_hw_params_any(pcm, hwparams) < 0) {
AUDIO_LOG_ERROR("snd_pcm_hw_params_any() : failed! - %s\n", snd_strerror(err));
goto error;
}
@@ -413,7 +413,7 @@ audio_return_t _audio_pcm_set_sw_params(snd_pcm_t *pcm, snd_pcm_uframes_t avail_
snd_pcm_sw_params_alloca(&swparams);
- if ((err = snd_pcm_sw_params_current(pcm, swparams) < 0)) {
+ if ((err = snd_pcm_sw_params_current(pcm, swparams)) < 0) {
AUDIO_LOG_WARN("Unable to determine current swparams: %s\n", snd_strerror(err));
goto error;
}
@@ -449,3 +449,55 @@ audio_return_t _audio_pcm_set_sw_params(snd_pcm_t *pcm, snd_pcm_uframes_t avail_
error:
return err;
}
+
+/* ------ dump helper -------- */
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+
+dump_data_t* dump_new(int length)
+{
+ dump_data_t* dump = NULL;
+
+ if ((dump = malloc(sizeof(dump_data_t)))) {
+ memset(dump, 0, sizeof(dump_data_t));
+ if ((dump->strbuf = malloc(length))) {
+ dump->p = &dump->strbuf[0];
+ dump->left = length;
+ } else {
+ free(dump);
+ dump = NULL;
+ }
+ }
+
+ return dump;
+}
+
+void dump_add_str(dump_data_t *dump, const char *fmt, ...)
+{
+ int len;
+ va_list ap;
+
+ if (!dump)
+ return;
+
+ va_start(ap, fmt);
+ len = vsnprintf(dump->p, dump->left, fmt, ap);
+ va_end(ap);
+
+ dump->p += MAX(0, len);
+ dump->left -= MAX(0, len);
+}
+
+char* dump_get_str(dump_data_t *dump)
+{
+ return (dump) ? dump->strbuf : NULL;
+}
+
+void dump_free(dump_data_t *dump)
+{
+ if (dump) {
+ if (dump->strbuf)
+ free(dump->strbuf);
+ free(dump);
+ }
+}
+/* ------ dump helper -------- */
diff --git a/tizen-audio-volume.c b/tizen-audio-volume.c
index a7611db..c8f9a42 100644
--- a/tizen-audio-volume.c
+++ b/tizen-audio-volume.c
@@ -209,7 +209,7 @@ static audio_return_t __load_volume_value_table_from_ini(audio_hal_t *ah)
while (token) {
/* convert dB volume to linear volume */
double vol_value = 0.0f;
- if(strncmp(token, "0", strlen(token)))
+ if (strncmp(token, "0", strlen(token)))
vol_value = pow(10.0, (atof(token) - 100) / 20.0);
volume_value_table->volume[vol_type_idx][volume_value_table->volume_level_max[vol_type_idx]++] = vol_value;
token = strtok_r(NULL, delimiter, &ptr);
@@ -267,7 +267,7 @@ audio_return_t _audio_volume_init(audio_hal_t *ah)
for (i = 0; i < AUDIO_VOLUME_TYPE_MAX; i++) {
/* Get volume value string from VCONF */
- if(vconf_get_int(g_volume_vconf[i], &val) < 0) {
+ if (vconf_get_int(g_volume_vconf[i], &val) < 0) {
AUDIO_LOG_ERROR("vconf_get_int(%s) failed", g_volume_vconf[i]);
continue;
}
@@ -282,7 +282,7 @@ audio_return_t _audio_volume_init(audio_hal_t *ah)
}
audio_ret = __load_volume_value_table_from_ini(ah);
- if(audio_ret != AUDIO_RET_OK) {
+ if (audio_ret != AUDIO_RET_OK) {
AUDIO_LOG_ERROR("gain table load error");
return AUDIO_ERR_UNDEFINED;
}
diff --git a/tizen-audio.c b/tizen-audio.c
index cad4284..882a9b4 100644
--- a/tizen-audio.c
+++ b/tizen-audio.c
@@ -29,7 +29,7 @@ static const char* AUDIO_LATENCY_MID = "mid";
static const char* AUDIO_LATENCY_HIGH = "high";
static const char* AUDIO_LATENCY_VOIP = "voip";
-audio_return_t audio_init (void **audio_handle)
+audio_return_t audio_init(void **audio_handle)
{
audio_hal_t *ah;
audio_return_t ret = AUDIO_RET_OK;
@@ -67,7 +67,7 @@ error_exit:
return ret;
}
-audio_return_t audio_deinit (void *audio_handle)
+audio_return_t audio_deinit(void *audio_handle)
{
audio_hal_t *ah = (audio_hal_t *)audio_handle;