diff options
-rw-r--r-- | packaging/hal-backend-audio-alsa.spec | 2 | ||||
-rw-r--r-- | tizen-audio-impl-ctrl.c | 212 | ||||
-rw-r--r-- | tizen-audio-impl.h | 5 | ||||
-rw-r--r-- | tizen-audio-internal.h | 1 |
4 files changed, 4 insertions, 216 deletions
diff --git a/packaging/hal-backend-audio-alsa.spec b/packaging/hal-backend-audio-alsa.spec index 819b285..8f29c83 100644 --- a/packaging/hal-backend-audio-alsa.spec +++ b/packaging/hal-backend-audio-alsa.spec @@ -1,6 +1,6 @@ Name: hal-backend-audio-alsa Summary: TIZEN Audio HAL using ALSA -Version: 0.0.6 +Version: 0.0.7 Release: 0 Group: System/Libraries License: Apache-2.0 diff --git a/tizen-audio-impl-ctrl.c b/tizen-audio-impl-ctrl.c index cf4b4ce..7af075e 100644 --- a/tizen-audio-impl-ctrl.c +++ b/tizen-audio-impl-ctrl.c @@ -28,227 +28,21 @@ #include "tizen-audio-internal.h" -#ifdef __MIXER_PARAM_DUMP -static void __dump_mixer_param(char *dump, long *param, int size) -{ - int i, len; - - for (i = 0; i < size; i++) { - len = sprintf(dump, "%ld", *param); - if (len > 0) - dump += len; - if (i != size -1) - *dump++ = ','; - - param++; - } - *dump = '\0'; -} -#endif - audio_return_e _mixer_control_init(audio_hal_s *ah) { AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER); - pthread_mutex_init(&(ah->mixer.mutex), NULL); - return AUDIO_RET_OK; -} - -audio_return_e _mixer_control_deinit(audio_hal_s *ah) -{ - AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER); - - pthread_mutex_destroy(&(ah->mixer.mutex)); - return AUDIO_RET_OK; -} - -audio_return_e _mixer_control_set_param(audio_hal_s *ah, const char* ctl_name, snd_ctl_elem_value_t* param, int size) -{ - AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER); + AUDIO_LOG_INFO("mixer init"); - /* TODO. */ return AUDIO_RET_OK; } -audio_return_e _mixer_control_get_value(audio_hal_s *ah, const char *card, const char *ctl_name, int *val) -{ - snd_ctl_t *handle; - snd_ctl_elem_value_t *control; - snd_ctl_elem_id_t *id; - snd_ctl_elem_info_t *info; - snd_ctl_elem_type_t type; - - int ret = 0, count = 0, i = 0; - - AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER); - AUDIO_RETURN_VAL_IF_FAIL(card, AUDIO_ERR_PARAMETER); - AUDIO_RETURN_VAL_IF_FAIL(ctl_name, AUDIO_ERR_PARAMETER); - AUDIO_RETURN_VAL_IF_FAIL(val, AUDIO_ERR_PARAMETER); - - pthread_mutex_lock(&(ah->mixer.mutex)); - - ret = snd_ctl_open(&handle, card, 0); - if (ret < 0) { - AUDIO_LOG_ERROR("snd_ctl_open error, %s\n", snd_strerror(ret)); - pthread_mutex_unlock(&(ah->mixer.mutex)); - return AUDIO_ERR_IOCTL; - } - - // Get Element Info - - snd_ctl_elem_id_alloca(&id); - snd_ctl_elem_info_alloca(&info); - snd_ctl_elem_value_alloca(&control); - - snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER); - 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); - goto close; - } - snd_ctl_elem_info_get_id(info, id); - - type = snd_ctl_elem_info_get_type(info); - count = snd_ctl_elem_info_get_count(info); - - 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"); - goto close; -} - - switch (type) { - case SND_CTL_ELEM_TYPE_BOOLEAN: - *val = snd_ctl_elem_value_get_boolean(control, i); - break; - case SND_CTL_ELEM_TYPE_INTEGER: - for (i = 0; i < count; i++) - *val = snd_ctl_elem_value_get_integer(control, i); - break; - case SND_CTL_ELEM_TYPE_ENUMERATED: - for (i = 0; i < count; i++) - *val = snd_ctl_elem_value_get_enumerated(control, i); - break; - default: - AUDIO_LOG_WARN("unsupported control element type\n"); - goto close; - } - - snd_ctl_close(handle); - -#ifdef AUDIO_DEBUG - AUDIO_LOG_INFO("get mixer(%s) = %d success", ctl_name, *val); -#endif - - pthread_mutex_unlock(&(ah->mixer.mutex)); - return AUDIO_RET_OK; - -close: - AUDIO_LOG_ERROR("Error\n"); - snd_ctl_close(handle); - pthread_mutex_unlock(&(ah->mixer.mutex)); - return AUDIO_ERR_UNDEFINED; -} - -audio_return_e _mixer_control_set_value(audio_hal_s *ah, const char *card, const char *ctl_name, int val) +audio_return_e _mixer_control_deinit(audio_hal_s *ah) { - snd_ctl_t *handle; - snd_ctl_elem_value_t *control; - snd_ctl_elem_id_t *id; - snd_ctl_elem_info_t *info; - snd_ctl_elem_type_t type; - int ret = 0, count = 0, i = 0; - AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER); - AUDIO_RETURN_VAL_IF_FAIL(card, AUDIO_ERR_PARAMETER); - AUDIO_RETURN_VAL_IF_FAIL(ctl_name, AUDIO_ERR_PARAMETER); - - pthread_mutex_lock(&(ah->mixer.mutex)); - - ret = snd_ctl_open(&handle, card, 0); - if (ret < 0) { - AUDIO_LOG_ERROR("snd_ctl_open error, card: %s: %s", card, snd_strerror(ret)); - pthread_mutex_unlock(&(ah->mixer.mutex)); - return AUDIO_ERR_IOCTL; - } - - // Get Element Info - - snd_ctl_elem_id_alloca(&id); - snd_ctl_elem_info_alloca(&info); - snd_ctl_elem_value_alloca(&control); - - snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER); - 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", ctl_name); - goto close; - } - snd_ctl_elem_info_get_id(info, id); - - type = snd_ctl_elem_info_get_type(info); - count = snd_ctl_elem_info_get_count(info); - - snd_ctl_elem_value_set_id(control, id); - - snd_ctl_elem_read(handle, control); - switch (type) { - case SND_CTL_ELEM_TYPE_BOOLEAN: - for (i = 0; i < count; i++) - snd_ctl_elem_value_set_boolean(control, i, val); - break; - case SND_CTL_ELEM_TYPE_INTEGER: - for (i = 0; i < count; i++) - 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); - break; + AUDIO_LOG_INFO("mixer deinit"); - default: - AUDIO_LOG_WARN("unsupported control element type"); - goto close; - } - - snd_ctl_elem_write(handle, control); - - snd_ctl_close(handle); - - AUDIO_LOG_INFO("set mixer(%s) = %d success", ctl_name, val); - - pthread_mutex_unlock(&(ah->mixer.mutex)); return AUDIO_RET_OK; - -close: - AUDIO_LOG_ERROR("Error"); - snd_ctl_close(handle); - pthread_mutex_unlock(&(ah->mixer.mutex)); - return AUDIO_ERR_UNDEFINED; } -audio_return_e _mixer_control_set_value_string(audio_hal_s *ah, const char* ctl_name, const char* value) -{ - AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER); - AUDIO_RETURN_VAL_IF_FAIL(ctl_name, AUDIO_ERR_PARAMETER); - - /* TODO. */ - return AUDIO_RET_OK; -} - - -audio_return_e _mixer_control_get_element(audio_hal_s *ah, const char *ctl_name, snd_hctl_elem_t **elem) -{ - AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER); - AUDIO_RETURN_VAL_IF_FAIL(ctl_name, AUDIO_ERR_PARAMETER); - AUDIO_RETURN_VAL_IF_FAIL(elem, AUDIO_ERR_PARAMETER); - - /* TODO. */ - return AUDIO_RET_OK; -} diff --git a/tizen-audio-impl.h b/tizen-audio-impl.h index 68c6448..9f14f21 100644 --- a/tizen-audio-impl.h +++ b/tizen-audio-impl.h @@ -38,10 +38,5 @@ audio_return_e _pcm_set_hw_params(snd_pcm_t *pcm, audio_pcm_sample_spec_s *sampl /* Control */ audio_return_e _mixer_control_init(audio_hal_s *ah); audio_return_e _mixer_control_deinit(audio_hal_s *ah); -audio_return_e _mixer_control_set_param(audio_hal_s *ah, const char* ctl_name, snd_ctl_elem_value_t* value, int size); -audio_return_e _mixer_control_set_value(audio_hal_s *ah, const char* card, const char *ctl_name, int val); -audio_return_e _mixer_control_set_value_string(audio_hal_s *ah, const char* ctl_name, const char* value); -audio_return_e _mixer_control_get_value(audio_hal_s *ah, const char *card, const char *ctl_name, int *val); -audio_return_e _mixer_control_get_element(audio_hal_s *ah, const char *ctl_name, snd_hctl_elem_t **elem); #endif diff --git a/tizen-audio-internal.h b/tizen-audio-internal.h index 3872447..ee7fa49 100644 --- a/tizen-audio-internal.h +++ b/tizen-audio-internal.h @@ -184,7 +184,6 @@ typedef struct audio_hal_volume { /* Mixer */ typedef struct audio_hal_mixer { snd_mixer_t *mixer; - pthread_mutex_t mutex; struct { snd_ctl_elem_value_t *value; snd_ctl_elem_id_t *id; |