[audio] Add new API - audio_set_volume_ratio 89/203689/2 accepted/tizen/unified/20190425.014634 submit/tizen/20190422.044155 submit/tizen/20190423.020435
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 17 Apr 2019 03:37:33 +0000 (12:37 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Wed, 17 Apr 2019 07:47:11 +0000 (16:47 +0900)
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 <sc11.lee@samsung.com>
include/audio/audio_hal_interface.h
include/audio/tizen-audio.h
packaging/mm-hal-interface.spec
src/audio/audio_hal_interface.c

index e7bb157..79b6f49 100644 (file)
@@ -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);
index b037cee..48754ba 100644 (file)
@@ -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);
index 424cf14..eca2359 100755 (executable)
@@ -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
index 816cf29..cef3cf7 100644 (file)
@@ -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);