From 4052ef4b3086e16b1a761020b0e46abd6f5ac99e Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Wed, 17 Apr 2019 12:37:33 +0900 Subject: [PATCH] [audio] Add new API - audio_set_volume_ratio This new API is to set the individual volume ratio of each stream. The parameters of this API consist of stream role, direction, index and its ratio. Because the stream role can differ among the streams which have same volume type, this new API could be used where the H/W volume has to be set for a specific stream role with distinguishing it from others. [Version] 0.0.21 [Profile] Common [Issue Type] New API Change-Id: I394d9e46f959c27e8ad029f33cd615ba70ecf154 Signed-off-by: Sangchul Lee --- include/audio/audio_hal_interface.h | 1 + include/audio/tizen-audio.h | 1 + packaging/mm-hal-interface.spec | 2 +- src/audio/audio_hal_interface.c | 39 +++++++++++++++++++++++++++++++++---- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/include/audio/audio_hal_interface.h b/include/audio/audio_hal_interface.h index e7bb157..79b6f49 100644 --- a/include/audio/audio_hal_interface.h +++ b/include/audio/audio_hal_interface.h @@ -75,6 +75,7 @@ int32_t audio_hal_interface_get_volume_value(audio_hal_interface *h, const char io_direction_t direction, uint32_t level, double *value); int32_t audio_hal_interface_get_volume_mute(audio_hal_interface *h, const char *volume_type, io_direction_t direction, uint32_t *mute); int32_t audio_hal_interface_set_volume_mute(audio_hal_interface *h, const char *volume_type, io_direction_t direction, uint32_t mute); +int32_t audio_hal_interface_set_volume_ratio(audio_hal_interface *h, const char *stream_role, io_direction_t direction, uint32_t index, double ratio); int32_t audio_hal_interface_update_route(audio_hal_interface *h, hal_route_info *info); int32_t audio_hal_interface_update_route_option(audio_hal_interface *h, hal_route_option *option); int32_t audio_hal_interface_notify_stream_connection_changed(audio_hal_interface *h, hal_stream_connection_info *info); diff --git a/include/audio/tizen-audio.h b/include/audio/tizen-audio.h index b037cee..48754ba 100644 --- a/include/audio/tizen-audio.h +++ b/include/audio/tizen-audio.h @@ -134,6 +134,7 @@ typedef struct audio_interface { 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); /* optional */ /* 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); diff --git a/packaging/mm-hal-interface.spec b/packaging/mm-hal-interface.spec index 424cf14..eca2359 100755 --- a/packaging/mm-hal-interface.spec +++ b/packaging/mm-hal-interface.spec @@ -1,6 +1,6 @@ Name: mm-hal-interface Summary: Multimedia HAL Interface -Version: 0.0.20 +Version: 0.0.21 Release: 0 Group: Multimedia/Development License: Apache-2.0 diff --git a/src/audio/audio_hal_interface.c b/src/audio/audio_hal_interface.c index 816cf29..cef3cf7 100644 --- a/src/audio/audio_hal_interface.c +++ b/src/audio/audio_hal_interface.c @@ -74,6 +74,7 @@ int32_t audio_hal_interface_init(audio_hal_interface **h) tmp_h->intf.get_volume_value = dlsym(tmp_h->dl_handle, "audio_get_volume_value"); tmp_h->intf.get_volume_mute = dlsym(tmp_h->dl_handle, "audio_get_volume_mute"); tmp_h->intf.set_volume_mute = dlsym(tmp_h->dl_handle, "audio_set_volume_mute"); + tmp_h->intf.set_volume_ratio = dlsym(tmp_h->dl_handle, "audio_set_volume_ratio"); tmp_h->intf.update_route = dlsym(tmp_h->dl_handle, "audio_update_route"); tmp_h->intf.update_route_option = dlsym(tmp_h->dl_handle, "audio_update_route_option"); tmp_h->intf.notify_stream_connection_changed = dlsym(tmp_h->dl_handle, "audio_notify_stream_connection_changed"); @@ -306,6 +307,36 @@ int32_t audio_hal_interface_set_volume_mute(audio_hal_interface *h, return AUDIO_HAL_SUCCESS; } +int32_t audio_hal_interface_set_volume_ratio(audio_hal_interface *h, + const char *stream_role, + io_direction_t direction, + uint32_t index, + double ratio) +{ + audio_return_t ret = AUDIO_RET_OK; + audio_stream_info_t info = { NULL, 0, 0 }; + + assert(h); + assert(h->ah_handle); + + info.role = stream_role; + info.direction = direction; + info.idx = index; + + if (!h->intf.set_volume_ratio) { + LOGW("Not implemented....(optional)"); + return AUDIO_HAL_SUCCESS; + } + + ret = h->intf.set_volume_ratio(h->ah_handle, &info, ratio); + if (ret != AUDIO_RET_OK) { + LOGE("set_volume_ratio returns error:0x%x", ret); + return AUDIO_HAL_ERROR; + } + + return AUDIO_HAL_SUCCESS; +} + int32_t audio_hal_interface_update_route(audio_hal_interface *h, hal_route_info *info) { @@ -656,8 +687,8 @@ int32_t audio_hal_interface_add_message_callback(audio_hal_interface *h, assert(h->ah_handle); if (!h->intf.add_message_cb) { - LOGE("Not implemented...."); - return AUDIO_HAL_ERROR; + LOGW("Not implemented....(optional)"); + return AUDIO_HAL_SUCCESS; } ret = h->intf.add_message_cb(h->ah_handle, (message_cb)callback, user_data); @@ -678,8 +709,8 @@ int32_t audio_hal_interface_remove_message_callback(audio_hal_interface *h, assert(h->ah_handle); if (!h->intf.remove_message_cb) { - LOGE("Not implemented...."); - return AUDIO_HAL_ERROR; + LOGW("Not implemented....(optional)"); + return AUDIO_HAL_SUCCESS; } ret = h->intf.remove_message_cb(h->ah_handle, (message_cb)callback); -- 2.7.4