tizen-audio-pcm.c \
tizen-audio-util.c \
tizen-audio-comm.c \
+ tizen-audio-ctrl.c \
tizen-audio-impl-pcm.c \
tizen-audio-impl-ctrl.c \
hal-backend-audio.c
if USE_TINYALSA
libhal_backend_audio_la_LIBADD += $(TINYALSA_LIBS)
libhal_backend_audio_la_CFLAGS += $(TINYALSA_CFLAGS) -D__USE_TINYALSA__
-endif
-
+endif
\ No newline at end of file
funcs->init = audio_init;
funcs->deinit = audio_deinit;
+
funcs->get_volume_level_max = audio_get_volume_level_max;
+ funcs->get_volume_level = audio_get_volume_level;
funcs->set_volume_level = audio_set_volume_level;
funcs->get_volume_value = audio_get_volume_value;
funcs->get_volume_mute = audio_get_volume_mute;
funcs->set_volume_mute = audio_set_volume_mute;
+ funcs->set_volume_ratio = audio_set_volume_ratio;
+ funcs->notify_ducking_activation_changed = audio_notify_ducking_activation_changed;
+
funcs->update_route = audio_update_route;
funcs->update_route_option = audio_update_route_option;
+
funcs->notify_stream_connection_changed = audio_notify_stream_connection_changed;
+
funcs->pcm_open = audio_pcm_open;
funcs->pcm_start = audio_pcm_start;
funcs->pcm_stop = audio_pcm_stop;
funcs->pcm_get_params = audio_pcm_get_params;
funcs->pcm_set_params = audio_pcm_set_params;
+ funcs->add_message_cb = audio_add_message_cb;
+ funcs->remove_message_cb = audio_remove_message_cb;
+
*data = (void *)funcs;
return 0;
Name: audio-hal-emul
Summary: TIZEN Audio HAL for Emulator
-Version: 0.1.14
+Version: 0.1.15
Release: 0
Group: System/Libraries
License: Apache-2.0
AUDIO_RETURN_VAL_IF_FAIL(name, AUDIO_ERR_PARAMETER);
AUDIO_LOG_DEBUG("send message : name(%s), value(%d)", name, value);
- if (ah->comm.msg_cb) {
+ if (ah->comm.msg_cb)
ah->comm.msg_cb(name, value, ah->comm.user_data);
- }
return audio_ret;
}
--- /dev/null
+/*
+ * audio-hal
+ *
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "tizen-audio-internal.h"
+#include "tizen-audio-impl.h"
+
+audio_return_e _audio_ctrl_init(audio_hal_s *ah)
+{
+ audio_return_e audio_ret = AUDIO_RET_OK;
+
+ AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
+
+ audio_ret = _mixer_control_init(ah);
+
+ return audio_ret;
+}
+
+audio_return_e _audio_ctrl_deinit(audio_hal_s *ah)
+{
+ audio_return_e audio_ret = AUDIO_RET_OK;
+
+ AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
+
+ audio_ret = _mixer_control_deinit(ah);
+
+ return audio_ret;
+}
#include "tizen-audio-internal.h"
-audio_return_e _control_init(audio_hal_s *ah)
+#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);
return AUDIO_RET_OK;
}
-audio_return_e _control_deinit(audio_hal_s *ah)
+audio_return_e _mixer_control_deinit(audio_hal_s *ah)
{
AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <stdbool.h>
#include "tizen-audio-internal.h"
#include "tizen-audio-impl.h"
audio_return_e _pcm_set_hw_params(snd_pcm_t *pcm, audio_pcm_sample_spec_s *sample_spec, uint8_t *use_mmap, snd_pcm_uframes_t *period_size, snd_pcm_uframes_t *buffer_size);
/* Control */
-audio_return_e _control_init(audio_hal_s *ah);
-audio_return_e _control_deinit(audio_hal_s *ah);
+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);
#endif
#define AUDIO_RETURN_IF_FAIL(expr) do { \
- if (!expr) { \
+ if (!(expr)) { \
AUDIO_LOG_ERROR("%s failed", #expr); \
return; \
} \
} while (0)
#define AUDIO_RETURN_VAL_IF_FAIL(expr, val) do { \
- if (!expr) { \
+ if (!(expr)) { \
AUDIO_LOG_ERROR("%s failed", #expr); \
return val; \
} \
} while (0)
#define AUDIO_RETURN_NULL_IF_FAIL(expr) do { \
- if (!expr) { \
+ if (!(expr)) { \
AUDIO_LOG_ERROR("%s failed", #expr); \
return NULL; \
} \
audio_hal_comm_s comm;
} audio_hal_s;
+audio_return_e _audio_ctrl_init(audio_hal_s *ah);
+audio_return_e _audio_ctrl_deinit(audio_hal_s *ah);
audio_return_e _audio_volume_init(audio_hal_s *ah);
audio_return_e _audio_volume_deinit(audio_hal_s *ah);
audio_return_e _audio_routing_init(audio_hal_s *ah);
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <stdbool.h>
#include "tizen-audio-internal.h"
#include "tizen-audio-impl.h"
#include <stdio.h>
#include <stdlib.h>
-#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <vconf.h>
#include <iniparser.h>
#include "tizen-audio-internal.h"
+#include "tizen-audio-impl.h"
#define VOLUME_INI_DEFAULT_PATH SYSCONFDIR"/multimedia/mmfw_audio_volume.ini" /* SYSCONFDIR is defined at .spec */
#define VOLUME_INI_TEMP_PATH "/opt/system/mmfw_audio_volume.ini"
int i;
int val = 0;
audio_return_e audio_ret = AUDIO_RET_OK;
- int init_value[AUDIO_VOLUME_TYPE_MAX] = {9, 11, 7, 11, 7, 4, 4, 7};
+ int init_value[AUDIO_VOLUME_TYPE_MAX] = { 9, 11, 7, 11, 7, 4, 4, 7 };
AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
ah->volume.volume_level[__get_volume_idx_by_string_type(info->type)] = level;
AUDIO_LOG_INFO("set [%s] volume_level: %d, direction(%d)", info->type, level, info->direction);
+ /* set mixer related to H/W volume if needed */
+
return audio_ret;
}
return audio_ret;
}
+
+audio_return_e audio_set_volume_ratio(void *audio_handle, audio_stream_info_s *info, double ratio)
+{
+ audio_return_e audio_ret = AUDIO_RET_OK;
+ audio_hal_s *ah = (audio_hal_s *)audio_handle;
+
+ AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
+ AUDIO_RETURN_VAL_IF_FAIL(info, AUDIO_ERR_PARAMETER);
+
+ AUDIO_LOG_INFO("set [%s] volume_ratio: %f, direction(%u), index(%u)", info->role, ratio, info->direction, info->idx);
+
+ /* TODO. Not implemented */
+
+ return audio_ret;
+}
+
+audio_return_e audio_notify_ducking_activation_changed(void *audio_handle, audio_ducking_info_s *info, uint32_t is_activated)
+{
+ audio_return_e audio_ret = AUDIO_RET_OK;
+ audio_hal_s *ah = (audio_hal_s *)audio_handle;
+
+ AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
+ AUDIO_RETURN_VAL_IF_FAIL(info, AUDIO_ERR_PARAMETER);
+ AUDIO_RETURN_VAL_IF_FAIL(info->target_role, AUDIO_ERR_PARAMETER);
+
+ AUDIO_LOG_INFO("role:%s, duration:%u, ratio:%lf, is_activated:%u", info->target_role, info->duration, info->ratio, is_activated);
+
+ /* TODO. Not implemented */
+
+ return audio_ret;
+}
AUDIO_RETURN_VAL_IF_FAIL(audio_handle, AUDIO_ERR_PARAMETER);
- if (!(ah = malloc(sizeof(audio_hal_s)))) {
- AUDIO_LOG_ERROR("failed to malloc()");
+ if (!(ah = calloc(1, sizeof(audio_hal_s)))) {
+ AUDIO_LOG_ERROR("failed to alloc()");
return AUDIO_ERR_RESOURCE;
}
+
+ if ((ret = _audio_ctrl_init(ah))) {
+ AUDIO_LOG_ERROR("failed to _audio_ctrl_init(), ret(0x%x)", ret);
+ goto error_exit;
+ }
if ((ret = _audio_volume_init(ah))) {
AUDIO_LOG_ERROR("failed to _audio_volume_init(), ret(0x%x)", ret);
goto error_exit;
_audio_stream_deinit(ah);
_audio_pcm_deinit(ah);
_audio_comm_deinit(ah);
+ _audio_ctrl_deinit(ah);
+
free(ah);
ah = NULL;
return AUDIO_RET_OK;
-}
\ No newline at end of file
+}
audio_return_e audio_set_volume_mute(void *audio_handle, audio_volume_info_s *info, uint32_t mute);
/**
+ * @brief Sets the volume ratio specified for a particular volume information. (optional)
+ * @since_tizen 5.5
+ * @param[in] audio_handle The audio hal handle
+ * @param[in] info The audio volume information
+ * @param[in] ratio The volume ratio to be set (Min.:0.0 ~ Max.:1.0, default:1.0)
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #AUDIO_RET_OK Success
+ */
+audio_return_e audio_set_volume_ratio(void *audio_handle, audio_stream_info_s *info, double ratio);
+
+/**
+ * @brief Gets notified when a ducking is activated and deactivated.
+ * @since_tizen 5.5
+ * @param[in] audio_handle The audio hal handle
+ * @param[in] info The ducking information including target role, duration and ratio
+ * @param[in] is_activated The activation state (@c true = activated, @c false = deactivated)
+ *
+ * @remarks This information can be used for volume controls.
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #AUDIO_RET_OK Success
+ */
+audio_return_e audio_notify_ducking_activation_changed(void *audio_handle, audio_ducking_info_s *info, uint32_t is_activated);
+
+/**
* @brief Updates the audio routing according to audio route information.
* @since_tizen 3.0
* @param[in] audio_handle The audio hal handle