tizen-audio-stream.c \
tizen-audio-pcm.c \
tizen-audio-util.c \
+ tizen-audio-ctrl.c \
tizen-audio-impl-pcm.c \
tizen-audio-impl-ucm.c \
tizen-audio-impl-ctrl.c
Name: audio-hal-bcm2837
Summary: TIZEN Audio HAL for BCM2837
-Version: 0.1.3
+Version: 0.1.4
Release: 0
Group: System/Libraries
License: Apache-2.0
--- /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_t _audio_ctrl_init(audio_hal_t *ah)
+{
+ audio_return_t 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_t _audio_ctrl_deinit(audio_hal_t *ah)
+{
+ audio_return_t audio_ret = AUDIO_RET_OK;
+
+ AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
+
+ audio_ret = _mixer_control_deinit(ah);
+
+ return audio_ret;
+}
}
#endif
-audio_return_t _control_init(audio_hal_t *ah)
+audio_return_t _mixer_control_init(audio_hal_t *ah)
{
AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
return AUDIO_RET_OK;
}
-audio_return_t _control_deinit(audio_hal_t *ah)
+audio_return_t _mixer_control_deinit(audio_hal_t *ah)
{
AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
/* TODO. */
return AUDIO_RET_OK;
-}
\ No newline at end of file
+}
audio_return_t _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);
/* Control */
-audio_return_t _control_init(audio_hal_t *ah);
-audio_return_t _control_deinit(audio_hal_t *ah);
+audio_return_t _mixer_control_init(audio_hal_t *ah);
+audio_return_t _mixer_control_deinit(audio_hal_t *ah);
audio_return_t _mixer_control_set_param(audio_hal_t *ah, const char* ctl_name, snd_ctl_elem_value_t* value, int size);
audio_return_t _mixer_control_set_value(audio_hal_t *ah, const char *ctl_name, int val);
audio_return_t _mixer_control_set_value_string(audio_hal_t *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_mixer_t mixer;
} audio_hal_t;
+audio_return_t _audio_ctrl_init(audio_hal_t *ah);
+audio_return_t _audio_ctrl_deinit(audio_hal_t *ah);
audio_return_t _audio_volume_init(audio_hal_t *ah);
audio_return_t _audio_volume_deinit(audio_hal_t *ah);
audio_return_t _audio_routing_init(audio_hal_t *ah);
/* #define DEBUG_TIMING */
static device_type_t outDeviceTypes[] = {
+ { AUDIO_DEVICE_OUT_SPEAKER, "Speaker" },
{ AUDIO_DEVICE_OUT_BT_SCO, "Bluetooth" },
{ AUDIO_DEVICE_OUT_AUX, "Line" },
{ AUDIO_DEVICE_OUT_HDMI, "HDMI" },
#define VOLUME_VALUE_MAX (1.0f)
#define GAIN_VALUE_MAX (1.0f)
+uint32_t g_master_volume_level = 100;
+
static const char *g_volume_vconf[AUDIO_VOLUME_TYPE_MAX] = {
"file/private/sound/volume/system", /* AUDIO_VOLUME_TYPE_SYSTEM */
"file/private/sound/volume/notification", /* AUDIO_VOLUME_TYPE_NOTIFICATION */
audio_volume_value_table_t *volume_value_table = ah->volume.volume_value_table;
int size = 0;
- dict = iniparser_load(VOLUME_INI_TEMP_PATH);
+ if (access(VOLUME_INI_TEMP_PATH, F_OK) == 0)
+ dict = iniparser_load(VOLUME_INI_TEMP_PATH);
if (!dict) {
AUDIO_LOG_DEBUG("Use default volume&gain ini file");
dict = iniparser_load(VOLUME_INI_DEFAULT_PATH);
AUDIO_RETURN_VAL_IF_FAIL(info, AUDIO_ERR_PARAMETER);
AUDIO_RETURN_VAL_IF_FAIL(level, AUDIO_ERR_PARAMETER);
+ if (!strncmp(info->type, "master", strlen("master"))) {
+ *level = g_master_volume_level;
+ return AUDIO_RET_OK;
+ }
+
*level = ah->volume.volume_level[__get_volume_idx_by_string_type(info->type)];
AUDIO_LOG_INFO("get [%s] volume_level: %d, direction(%d)", info->type, *level, info->direction);
AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
AUDIO_RETURN_VAL_IF_FAIL(info, AUDIO_ERR_PARAMETER);
+ if (!strncmp(info->type, "master", strlen("master"))) {
+ g_master_volume_level = level;
+ return AUDIO_RET_OK;
+ }
AUDIO_RETURN_VAL_IF_FAIL((ah->volume.volume_level_max[__get_volume_idx_by_string_type(info->type)] >= level), AUDIO_ERR_PARAMETER);
/* Update volume level */
return audio_ret;
}
+
+audio_return_t audio_set_volume_ratio(void *audio_handle, audio_stream_info_t *info, double ratio)
+{
+ audio_return_t audio_ret = AUDIO_RET_OK;
+ audio_hal_t *ah = (audio_hal_t *)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);
+
+ return audio_ret;
+}
AUDIO_LOG_ERROR("failed to malloc()");
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_routing_deinit(ah);
_audio_stream_deinit(ah);
_audio_pcm_deinit(ah);
+ _audio_ctrl_deinit(ah);
+
free(ah);
ah = NULL;
return AUDIO_RET_OK;
-}
\ No newline at end of file
+}
audio_return_t (*get_volume_value)(void *audio_handle, audio_volume_info_t *info, uint32_t level, double *value);
audio_return_t (*get_volume_mute)(void *audio_handle, audio_volume_info_t *info, uint32_t *mute);
audio_return_t (*set_volume_mute)(void *audio_handle, audio_volume_info_t *info, uint32_t mute);
+ audio_return_t (*set_volume_ratio)(void *audio_handle, audio_stream_info_t *info, double ratio);
/* Routing */
audio_return_t (*update_route)(void *audio_handle, audio_route_info_t *info);
audio_return_t (*update_route_option)(void *audio_handle, audio_route_option_t *option);