hal-interface: Use hal audio api 62/252162/10 accepted/tizen/unified/20210204.134540 submit/tizen/20210203.005915 submit/tizen/20210204.010649
authorJaechul Lee <jcsing.lee@samsung.com>
Mon, 25 Jan 2021 05:25:32 +0000 (14:25 +0900)
committerJaechul Lee <jcsing.lee@samsung.com>
Mon, 1 Feb 2021 02:04:18 +0000 (11:04 +0900)
+ remove minor build warning

[Version] 13.0.46
[Issue Type] Enhancement

Change-Id: Iac9337a9c6f654723eb956f7f7a6b2a85deef8d6
Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
Makefile.am
configure.ac
packaging/pulseaudio-modules-tizen.spec
src/hal-interface.c
src/hal-interface.h
src/module-tizenaudio-policy.c
src/stream-manager.c

index e529cae59997afe56d306ab058d63e40f82a0eb6..e66660bc1aa135e2fcbb0062312adadf61204a02 100644 (file)
@@ -53,8 +53,8 @@ endif
 libhal_interface_la_SOURCES = \
           src/hal-interface.c   src/hal-interface.h
 libhal_interface_la_LDFLAGS = $(AM_LDFLAGS) $(PA_LDFLAGS) -avoid-version
-libhal_interface_la_LIBADD = $(AM_LIBADD) $(PACORE_LIBS) $(PA_LIBS)
-libhal_interface_la_CFLAGS = $(AM_CFLAGS) $(PACORE_CFLAGS) $(PA_CFLAGS)
+libhal_interface_la_LIBADD = $(AM_LIBADD) $(PACORE_LIBS) $(PA_LIBS) $(HALAPIAUDIO_LIBS)
+libhal_interface_la_CFLAGS = $(AM_CFLAGS) $(PACORE_CFLAGS) $(PA_CFLAGS) $(HALAPIAUDIO_CFLAGS)
 
 libcommunicator_la_SOURCES = \
           src/communicator.c   src/communicator.h
index 8557992b782b2bf6cec159c8ae31ec2fe559bf37..ac631fa1176213b6cbf1a5cfe8aa965fa43f0d14 100644 (file)
@@ -365,6 +365,10 @@ PKG_CHECK_MODULES(DNSSD, dns_sd)
 AC_SUBST(DNSSD_CFLAGS)
 AC_SUBST(DNSSD_LIBS)
 
+PKG_CHECK_MODULES(HALAPIAUDIO, hal-api-audio)
+AC_SUBST(HALAPIAUDIO_CFLAGS)
+AC_SUBST(HALAPIAUDIO_LIBS)
+
 dnl use hal tc ------------------------------------------------------------
 AC_ARG_ENABLE(haltc, AC_HELP_STRING([--enable-haltc], [using haltc]),
 [
index a88cd4f436770bda4c84d28dfb72135d72936c27..0b5626f91f6532cc9798b71780158fe7d6095513 100644 (file)
@@ -1,6 +1,6 @@
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          13.0.45
+Version:          13.0.46
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
@@ -16,11 +16,11 @@ BuildRequires:    pkgconfig(vconf)
 %if "%{tizen_profile_name}" == "tv"
 BuildRequires:    pkgconfig(glib-2.0)
 %endif
-BuildRequires:    mm-hal-interface-devel
 BuildRequires:    pkgconfig(libpulse)
 BuildRequires:    pkgconfig(pulsecore)
 BuildRequires:    pkgconfig(libsystemd)
 BuildRequires:    pkgconfig(dns_sd)
+BuildRequires:    pkgconfig(hal-api-audio)
 BuildRequires:    pulseaudio
 BuildRequires:    m4
 Requires(post):   /sbin/ldconfig
@@ -40,7 +40,7 @@ PulseAudio module-acm-sink for sending PCM data to ACM core.
 %setup -q
 
 %build
-export CFLAGS="%{optflags} -fno-strict-aliasing -D__TIZEN__ -DSYSCONFDIR=\\\"%{_sysconfdir}\\\" -DAUDIOHALDIR=\\\"%{_libdir}\\\""
+export CFLAGS="%{optflags} -fno-strict-aliasing -D__TIZEN__ -DSYSCONFDIR=\\\"%{_sysconfdir}\\\" "
 
 export LD_AS_NEEDED=0
 %reconfigure --prefix=%{_prefix} \
index 26ee345118de00d78c1dcbc7e34f3e07783f4bb1..e108f38406c08680f9db3f0143439dd7f113e8db 100644 (file)
 #endif
 
 #include "hal-interface.h"
-#include <tizen-audio.h>
+
+#include <hal-audio.h>
+#include <hal-audio-interface.h>
+
 #include <pulsecore/shared.h>
 
 #define SHARED_HAL_INTF "tizen-hal-interface"
 
-/* Audio HAL library */
-#define LIB_TIZEN_AUDIO AUDIOHALDIR"/libtizen-audio.so"
-
 struct _pa_hal_interface {
     PA_REFCNT_DECLARE;
 
     pa_core *core;
-    void *dl_handle;
-    void *ah_handle;
-    audio_interface_t intf;
+    void *audio_handle;
 };
 
 pa_hal_interface* pa_hal_interface_get(pa_core *core) {
     pa_hal_interface *h;
+    audio_return_e hal_ret = AUDIO_RET_OK;
 
     pa_assert(core);
 
@@ -53,49 +52,12 @@ pa_hal_interface* pa_hal_interface_get(pa_core *core) {
     PA_REFCNT_INIT(h);
     h->core = core;
 
-    /* Load library & init HAL interface */
-    h->dl_handle = dlopen(LIB_TIZEN_AUDIO, RTLD_NOW);
-    if (h->dl_handle) {
-        h->intf.init = dlsym(h->dl_handle, "audio_init");
-        h->intf.deinit = dlsym(h->dl_handle, "audio_deinit");
-        h->intf.get_volume_level_max = dlsym(h->dl_handle, "audio_get_volume_level_max");
-        h->intf.get_volume_level = dlsym(h->dl_handle, "audio_get_volume_level");
-        h->intf.set_volume_level = dlsym(h->dl_handle, "audio_set_volume_level");
-        h->intf.get_volume_value = dlsym(h->dl_handle, "audio_get_volume_value");
-        h->intf.get_volume_mute = dlsym(h->dl_handle, "audio_get_volume_mute");
-        h->intf.set_volume_mute = dlsym(h->dl_handle, "audio_set_volume_mute");
-        h->intf.set_volume_ratio = dlsym(h->dl_handle, "audio_set_volume_ratio");
-        h->intf.notify_ducking_activation_changed = dlsym(h->dl_handle, "audio_notify_ducking_activation_changed");
-        h->intf.update_route = dlsym(h->dl_handle, "audio_update_route");
-        h->intf.update_route_option = dlsym(h->dl_handle, "audio_update_route_option");
-        h->intf.notify_stream_connection_changed = dlsym(h->dl_handle, "audio_notify_stream_connection_changed");
-        h->intf.pcm_open = dlsym(h->dl_handle, "audio_pcm_open");
-        h->intf.pcm_start = dlsym(h->dl_handle, "audio_pcm_start");
-        h->intf.pcm_stop = dlsym(h->dl_handle, "audio_pcm_stop");
-        h->intf.pcm_close = dlsym(h->dl_handle, "audio_pcm_close");
-        h->intf.pcm_avail = dlsym(h->dl_handle, "audio_pcm_avail");
-        h->intf.pcm_write = dlsym(h->dl_handle, "audio_pcm_write");
-        h->intf.pcm_read = dlsym(h->dl_handle, "audio_pcm_read");
-        h->intf.pcm_get_fd = dlsym(h->dl_handle, "audio_pcm_get_fd");
-        h->intf.pcm_recover = dlsym(h->dl_handle, "audio_pcm_recover");
-        h->intf.pcm_get_params = dlsym(h->dl_handle, "audio_pcm_get_params");
-        h->intf.pcm_set_params = dlsym(h->dl_handle, "audio_pcm_set_params");
-        h->intf.add_message_cb = dlsym(h->dl_handle, "audio_add_message_cb");
-        h->intf.remove_message_cb = dlsym(h->dl_handle, "audio_remove_message_cb");
-        if (h->intf.init) {
-            if (h->intf.init(&h->ah_handle) != AUDIO_RET_OK) {
-                pa_log_error("hal_interface init failed");
-                dlclose(h->dl_handle);
-                pa_xfree(h);
-                return NULL;
-            }
-        }
-
-     } else {
-         pa_log_error("open hal_interface failed :%s", dlerror());
-         pa_xfree(h);
-         return NULL;
-     }
+    hal_ret = hal_audio_init(&h->audio_handle);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_init error:0x%x", hal_ret);
+        pa_xfree(h);
+        return NULL;
+    }
 
     pa_shared_set(core, SHARED_HAL_INTF, h);
 
@@ -112,20 +74,17 @@ pa_hal_interface* pa_hal_interface_ref(pa_hal_interface *h) {
 }
 
 void pa_hal_interface_unref(pa_hal_interface *h) {
+    audio_return_e hal_ret = AUDIO_RET_OK;
+
     pa_assert(h);
     pa_assert(PA_REFCNT_VALUE(h) > 0);
 
     if (PA_REFCNT_DEC(h) > 0)
         return;
 
-    /* Deinit HAL manager & unload library */
-    if (h->intf.deinit) {
-        if (h->intf.deinit(h->ah_handle) != AUDIO_RET_OK) {
-            pa_log_error("hal_interface deinit failed");
-        }
-    }
-    if (h->dl_handle)
-        dlclose(h->dl_handle);
+    hal_ret = hal_audio_deinit(h->audio_handle);
+    if (hal_ret != AUDIO_RET_OK)
+        pa_log_error("hal_audio_deinit error:0x%x", hal_ret);
 
     if (h->core)
         pa_shared_remove(h->core, SHARED_HAL_INTF);
@@ -133,88 +92,82 @@ void pa_hal_interface_unref(pa_hal_interface *h) {
     pa_xfree(h);
 }
 
-int32_t pa_hal_interface_get_volume_level_max(pa_hal_interface *h, const char *volume_type, io_direction_t direction, uint32_t *level) {
-    int32_t ret = 0;
-    audio_return_t hal_ret = AUDIO_RET_OK;
-    audio_volume_info_t info = {NULL, NULL, 0};
+int32_t pa_hal_interface_get_volume_level_max(pa_hal_interface *h, const char *volume_type,
+                                            io_direction_t direction, uint32_t *level) {
+    audio_return_e hal_ret = AUDIO_RET_OK;
+    audio_volume_info_s info = { volume_type, NULL, direction };
 
     pa_assert(h);
     pa_assert(volume_type);
     pa_assert(level);
 
-    info.type = volume_type;
-    info.direction = direction;
-
-    if (AUDIO_RET_OK != (hal_ret = h->intf.get_volume_level_max(h->ah_handle, &info, level))) {
-        pa_log_error("get_volume_level_max returns error:0x%x", hal_ret);
-        ret = -1;
+    hal_ret = hal_audio_get_volume_level_max(h->audio_handle, &info, level);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_get_volume_level_max error:0x%x", hal_ret);
+        return -1;
     }
-    return ret;
+
+    return 0;
 }
 
-int32_t pa_hal_interface_get_volume_level(pa_hal_interface *h, const char *volume_type, io_direction_t direction, uint32_t *level) {
-    int32_t ret = 0;
-    audio_return_t hal_ret = AUDIO_RET_OK;
-    audio_volume_info_t info = {NULL, NULL, 0};
+int32_t pa_hal_interface_get_volume_level(pa_hal_interface *h, const char *volume_type,
+                                        io_direction_t direction, uint32_t *level) {
+    audio_return_e hal_ret = AUDIO_RET_OK;
+    audio_volume_info_s info = { volume_type, NULL, direction };
 
     pa_assert(h);
     pa_assert(volume_type);
     pa_assert(level);
 
-    info.type = volume_type;
-    info.direction = direction;
-
-    if (AUDIO_RET_OK != (hal_ret = h->intf.get_volume_level(h->ah_handle, &info, level))) {
-        pa_log_error("get_volume_level returns error:0x%x", hal_ret);
-        ret = -1;
+    hal_ret = hal_audio_get_volume_level(h->audio_handle, &info, level);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_get_volume_level error:0x%x", hal_ret);
+        return -1;
     }
-    return ret;
+
+    return 0;
 }
 
-int32_t pa_hal_interface_set_volume_level(pa_hal_interface *h, const char *volume_type, io_direction_t direction, uint32_t level) {
-    int32_t ret = 0;
-    audio_return_t hal_ret = AUDIO_RET_OK;
-    audio_volume_info_t info = {NULL, NULL, 0};
+int32_t pa_hal_interface_set_volume_level(pa_hal_interface *h, const char *volume_type,
+                                        io_direction_t direction, uint32_t level) {
+    audio_return_e hal_ret = AUDIO_RET_OK;
+    audio_volume_info_s info = { volume_type, NULL, direction };
 
     pa_assert(h);
     pa_assert(volume_type);
 
-    info.type = volume_type;
-    info.direction = direction;
-
-    if (AUDIO_RET_OK != (hal_ret = h->intf.set_volume_level(h->ah_handle, &info, level))) {
-        pa_log_error("set_volume_level returns error:0x%x", hal_ret);
-        ret = -1;
+    hal_ret = hal_audio_set_volume_level(h->audio_handle, &info, level);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_set_volume_level error:0x%x", hal_ret);
+        return -1;
     }
 
-    return ret;
+    return 0;
 }
 
-int32_t pa_hal_interface_get_volume_value(pa_hal_interface *h, const char *volume_type, const char *gain_type, io_direction_t direction, uint32_t level, double *value) {
-    int32_t ret = 0;
-    audio_return_t hal_ret = AUDIO_RET_OK;
-    audio_volume_info_t info = {NULL, NULL, 0};
+int32_t pa_hal_interface_get_volume_value(pa_hal_interface *h, const char *volume_type,
+                                        const char *gain_type, io_direction_t direction,
+                                        uint32_t level, double *value) {
+    audio_return_e hal_ret = AUDIO_RET_OK;
+    audio_volume_info_s info = { volume_type, gain_type, direction };
 
     pa_assert(h);
     pa_assert(volume_type);
     pa_assert(value);
 
-    info.type = volume_type;
-    info.gain = gain_type;
-    info.direction = direction;
-
-    if (AUDIO_RET_OK != (hal_ret = h->intf.get_volume_value(h->ah_handle, &info, level, value))) {
-        pa_log_error("get_volume_value returns error:0x%x", hal_ret);
-        ret = -1;
+    hal_ret = hal_audio_get_volume_value(h->audio_handle, &info, level, value);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_get_volume_value error:0x%x", hal_ret);
+        return -1;
     }
 
-    return ret;
+    return 0;
 }
 
-int32_t pa_hal_interface_get_volume_mute(pa_hal_interface *h, const char *volume_type, io_direction_t direction, uint32_t *mute) {
-    int32_t ret = 0;
-    audio_return_t hal_ret = AUDIO_RET_OK;
-    audio_volume_info_t info = {NULL, NULL, 0};
+int32_t pa_hal_interface_get_volume_mute(pa_hal_interface *h, const char *volume_type,
+                                        io_direction_t direction, uint32_t *mute) {
+    audio_return_e hal_ret = AUDIO_RET_OK;
+    audio_volume_info_s info = { volume_type, NULL, direction };
 
     pa_assert(h);
     pa_assert(volume_type);
@@ -223,73 +176,63 @@ int32_t pa_hal_interface_get_volume_mute(pa_hal_interface *h, const char *volume
     info.type = volume_type;
     info.direction = direction;
 
-    if (AUDIO_RET_OK != (hal_ret = h->intf.get_volume_mute(h->ah_handle, &info, mute))) {
-        pa_log_error("get_mute returns error:0x%x", hal_ret);
-        ret = -1;
+    hal_ret = hal_audio_get_volume_mute(h->audio_handle, &info, mute);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_get_volume_mute error:0x%x", hal_ret);
+        return -1;
     }
-    return ret;
+
+    return 0;
 }
 
-int32_t pa_hal_interface_set_volume_mute(pa_hal_interface *h, const char *volume_type, io_direction_t direction, uint32_t mute) {
-    int32_t ret = 0;
-    audio_return_t hal_ret = AUDIO_RET_OK;
-    audio_volume_info_t info = {NULL, NULL, 0};
+int32_t pa_hal_interface_set_volume_mute(pa_hal_interface *h, const char *volume_type,
+                                        io_direction_t direction, uint32_t mute) {
+    audio_return_e hal_ret = AUDIO_RET_OK;
+    audio_volume_info_s info = { volume_type, NULL, direction };
 
     pa_assert(h);
     pa_assert(volume_type);
 
-    info.type = volume_type;
-    info.direction = direction;
-
-    if (AUDIO_RET_OK != (hal_ret = h->intf.set_volume_mute(h->ah_handle, &info, mute))) {
-        pa_log_error("set_mute returns error:0x%x", hal_ret);
-        ret = -1;
+    hal_ret = hal_audio_set_volume_mute(h->audio_handle, &info, mute);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_set_volume_mute error:0x%x", hal_ret);
+        return -1;
     }
-    return ret;
+
+    return 0;
 }
 
-int32_t pa_hal_interface_set_volume_ratio(pa_hal_interface *h, const char *stream_role, io_direction_t direction, uint32_t idx, double ratio) {
-    int32_t ret = 0;
-    audio_return_t hal_ret = AUDIO_RET_OK;
-    audio_stream_info_t info = {NULL, 0, 0};
+int32_t pa_hal_interface_set_volume_ratio(pa_hal_interface *h, const char *stream_role,
+                                        io_direction_t direction, uint32_t idx, double ratio) {
+    audio_return_e hal_ret = AUDIO_RET_OK;
+    audio_stream_info_s info = { stream_role, direction, idx };
 
     pa_assert(h);
     pa_assert(stream_role);
 
-    if (h->intf.set_volume_ratio == NULL) {
-        pa_log_warn("there is no set_volume_ratio symbol in this audio hal, skip it");
+    hal_ret = hal_audio_set_volume_ratio(h->audio_handle, &info, ratio);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_set_volume_ratio error:0x%x", hal_ret);
         return -1;
     }
 
-    info.role = stream_role;
-    info.direction = direction;
-    info.idx = idx;
-
-    if (AUDIO_RET_OK != (hal_ret = h->intf.set_volume_ratio(h->ah_handle, &info, ratio))) {
-        pa_log_error("set_volume_ratio returns error:0x%x", hal_ret);
-        ret = -1;
-    }
-    return ret;
+    return 0;
 }
 
 int32_t pa_hal_interface_notify_ducking_activation_changed(pa_hal_interface *h, hal_ducking_activation_info *info) {
-    audio_return_t hal_ret = AUDIO_RET_OK;
-    audio_ducking_info_t hal_info;
+    audio_return_e hal_ret = AUDIO_RET_OK;
+    audio_ducking_info_s hal_info = { 0, };
 
     pa_assert(h);
     pa_assert(info);
 
-    if (!h->intf.notify_ducking_activation_changed) {
-        pa_log_warn("not implemented");
-        return -2;
-    }
-
     hal_info.target_role = info->target_role;
     hal_info.duration = info->duration;
     hal_info.ratio = info->ratio;
 
-    if (AUDIO_RET_OK != (hal_ret = h->intf.notify_ducking_activation_changed(h->ah_handle, &hal_info, (uint32_t)info->is_activated))) {
-        pa_log_error("notify_ducking_activation_changed returns error:0x%x", hal_ret);
+    hal_ret = hal_audio_notify_ducking_activation_changed(h->audio_handle, &hal_info, (uint32_t)info->is_activated);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_notify_ducking_activation_changed error:0x%x", hal_ret);
         return -1;
     }
 
@@ -297,37 +240,38 @@ int32_t pa_hal_interface_notify_ducking_activation_changed(pa_hal_interface *h,
 }
 
 int32_t pa_hal_interface_update_route(pa_hal_interface *h, hal_route_info *info) {
-    int32_t ret = 0;
-    audio_return_t hal_ret = AUDIO_RET_OK;
+    audio_return_e hal_ret = AUDIO_RET_OK;
 
     pa_assert(h);
     pa_assert(info);
 
-    if (AUDIO_RET_OK != (hal_ret = h->intf.update_route(h->ah_handle, (audio_route_info_t*)info))) {
-        pa_log_error("update_route returns error:0x%x", hal_ret);
-        ret = -1;
+    hal_ret = hal_audio_update_route(h->audio_handle, (audio_route_info_s*)info);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_update_route error:0x%x", hal_ret);
+        return -1;
     }
-    return ret;
+
+    return 0;
 }
 
 int32_t pa_hal_interface_update_route_option(pa_hal_interface *h, hal_route_option *option) {
-    int32_t ret = 0;
-    audio_return_t hal_ret = AUDIO_RET_OK;
+    audio_return_e hal_ret = AUDIO_RET_OK;
 
     pa_assert(h);
     pa_assert(option);
 
-    if (AUDIO_RET_OK != (hal_ret = h->intf.update_route_option(h->ah_handle, (audio_route_option_t*)option))) {
-        pa_log_error("update_route_option returns error:0x%x", hal_ret);
-        ret = -1;
+    hal_ret = hal_audio_update_route_option(h->audio_handle, (audio_route_option_s*)option);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_update_route_option error:0x%x", hal_ret);
+        return -1;
     }
-    return ret;
+
+    return 0;
 }
 
 int32_t pa_hal_interface_notify_stream_connection_changed(pa_hal_interface *h, hal_stream_connection_info *info) {
-    int32_t ret = 0;
-    audio_return_t hal_ret = AUDIO_RET_OK;
-    audio_stream_info_t hal_info;
+    audio_return_e hal_ret = AUDIO_RET_OK;
+    audio_stream_info_s hal_info = { 0, };
 
     pa_assert(h);
     pa_assert(info);
@@ -336,17 +280,18 @@ int32_t pa_hal_interface_notify_stream_connection_changed(pa_hal_interface *h, h
     hal_info.direction = info->direction;
     hal_info.idx = info->idx;
 
-    if (AUDIO_RET_OK != (hal_ret = h->intf.notify_stream_connection_changed(h->ah_handle, &hal_info, (uint32_t)info->is_connected))) {
-        pa_log_error("notify_tream_connection_changed returns error:0x%x", hal_ret);
-        ret = -1;
+    hal_ret = hal_audio_notify_stream_connection_changed(h->audio_handle, &hal_info, (uint32_t)info->is_connected);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_notify_stream_connection_changed error:0x%x", hal_ret);
+        return -1;
     }
-    return ret;
+
+    return 0;
 }
 
 int32_t pa_hal_interface_pcm_open(pa_hal_interface *h, const char *card, const char *device, io_direction_t direction,
                                   pa_sample_spec *sample_spec, uint32_t period_size, uint32_t periods, pcm_handle *pcm_h) {
-    int32_t ret = 0;
-    audio_return_t hal_ret = AUDIO_RET_OK;
+    audio_return_e hal_ret = AUDIO_RET_OK;
 
     pa_assert(h);
     pa_assert(pcm_h);
@@ -354,191 +299,199 @@ int32_t pa_hal_interface_pcm_open(pa_hal_interface *h, const char *card, const c
     pa_assert(device);
     pa_assert(sample_spec);
 
-    if (AUDIO_RET_OK != (hal_ret = h->intf.pcm_open(h->ah_handle, card, device, direction, sample_spec, period_size, periods, pcm_h))) {
-        pa_log_error("pcm_open returns error:0x%x", hal_ret);
-        ret = -1;
+    hal_ret = hal_audio_pcm_open(h->audio_handle, card, device, direction, sample_spec, period_size, periods, pcm_h);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_pcm_open error:0x%x", hal_ret);
+        return -1;
     }
-    return ret;
+
+    return 0;
 }
 
 int32_t pa_hal_interface_pcm_start(pa_hal_interface *h, pcm_handle pcm_h) {
-    int32_t ret = 0;
-    audio_return_t hal_ret = AUDIO_RET_OK;
+    audio_return_e hal_ret = AUDIO_RET_OK;
 
     pa_assert(h);
     pa_assert(pcm_h);
 
-    if (AUDIO_RET_OK != (hal_ret = h->intf.pcm_start(h->ah_handle, pcm_h))) {
-        pa_log_error("pcm_start returns error:0x%x", hal_ret);
-        ret = -1;
+    hal_ret = hal_audio_pcm_start(h->audio_handle, pcm_h);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_pcm_start error:0x%x", hal_ret);
+        return -1;
     }
-    return ret;
+
+    return 0;
 }
 
 int32_t pa_hal_interface_pcm_stop(pa_hal_interface *h, pcm_handle pcm_h) {
-    int32_t ret = 0;
-    audio_return_t hal_ret = AUDIO_RET_OK;
+    audio_return_e hal_ret = AUDIO_RET_OK;
 
     pa_assert(h);
     pa_assert(pcm_h);
 
-    if (AUDIO_RET_OK != (hal_ret = h->intf.pcm_stop(h->ah_handle, pcm_h))) {
-        pa_log_error("pcm_stop returns error:0x%x", hal_ret);
-        ret = -1;
+    hal_ret = hal_audio_pcm_stop(h->audio_handle, pcm_h);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_pcm_stop error:0x%x", hal_ret);
+        return -1;
     }
-    return ret;
+
+    return 0;
 }
 
 int32_t pa_hal_interface_pcm_close(pa_hal_interface *h, pcm_handle pcm_h) {
-    int32_t ret = 0;
-    audio_return_t hal_ret = AUDIO_RET_OK;
+    audio_return_e hal_ret = AUDIO_RET_OK;
 
     pa_assert(h);
     pa_assert(pcm_h);
 
-    if (AUDIO_RET_OK != (hal_ret = h->intf.pcm_close(h->ah_handle, pcm_h))) {
-        pa_log_error("pcm_close returns error:0x%x", hal_ret);
-        ret = -1;
+    hal_ret = hal_audio_pcm_close(h->audio_handle, pcm_h);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_pcm_close error:0x%x", hal_ret);
+        return -1;
     }
-    return ret;
+
+    return 0;
 }
 
 int32_t pa_hal_interface_pcm_available(pa_hal_interface *h, pcm_handle pcm_h, uint32_t *available) {
-    int32_t ret = 0;
-    audio_return_t hal_ret = AUDIO_RET_OK;
+    audio_return_e hal_ret = AUDIO_RET_OK;
 
     pa_assert(h);
     pa_assert(pcm_h);
     pa_assert(available);
 
-    if (AUDIO_RET_OK != (hal_ret = h->intf.pcm_avail(h->ah_handle, pcm_h, available))) {
-        pa_log_error("pcm_avail returns error:0x%x", hal_ret);
-        ret = -1;
+    hal_ret = hal_audio_pcm_avail(h->audio_handle, pcm_h, available);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_pcm_avail error:0x%x", hal_ret);
+        return -1;
     }
-    return ret;
+
+    return 0;
 }
 
 int32_t pa_hal_interface_pcm_write(pa_hal_interface *h, pcm_handle pcm_h, const void *buffer, uint32_t frames) {
-    int32_t ret = 0;
-    audio_return_t hal_ret = AUDIO_RET_OK;
+    audio_return_e hal_ret = AUDIO_RET_OK;
 
     pa_assert(h);
     pa_assert(pcm_h);
     pa_assert(buffer);
 
-    if (AUDIO_RET_OK != (hal_ret = h->intf.pcm_write(h->ah_handle, pcm_h, buffer, frames))) {
-        pa_log_error("pcm_write returns error:0x%x", hal_ret);
-        ret = -1;
+    hal_ret = hal_audio_pcm_write(h->audio_handle, pcm_h, buffer, frames);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_pcm_write error:0x%x", hal_ret);
+        return -1;
     }
-    return ret;
+
+    return 0;
 }
 
 int32_t pa_hal_interface_pcm_read(pa_hal_interface *h, pcm_handle pcm_h, void *buffer, uint32_t frames) {
-    int32_t ret = 0;
-    audio_return_t hal_ret = AUDIO_RET_OK;
+    audio_return_e hal_ret = AUDIO_RET_OK;
 
     pa_assert(h);
     pa_assert(pcm_h);
     pa_assert(buffer);
 
-    if (AUDIO_RET_OK != (hal_ret = h->intf.pcm_read(h->ah_handle, pcm_h, buffer, frames))) {
-        pa_log_error("pcm_read returns error:0x%x", hal_ret);
-        ret = -1;
+    hal_ret = hal_audio_pcm_read(h->audio_handle, pcm_h, buffer, frames);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_pcm_read error:0x%x", hal_ret);
+        return -1;
     }
-    return ret;
+
+    return 0;
 }
 
 int32_t pa_hal_interface_pcm_get_fd(pa_hal_interface *h, pcm_handle pcm_h, int *fd) {
-    int32_t ret = 0;
-    audio_return_t hal_ret = AUDIO_RET_OK;
+    audio_return_e hal_ret = AUDIO_RET_OK;
 
     pa_assert(h);
     pa_assert(pcm_h);
     pa_assert(fd);
 
-    if (AUDIO_RET_OK != (hal_ret = h->intf.pcm_get_fd(h->ah_handle, pcm_h, fd))) {
-        pa_log_error("pcm_get_fd returns error:0x%x", hal_ret);
-        ret = -1;
+    hal_ret = hal_audio_pcm_get_fd(h->audio_handle, pcm_h, fd);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_pcm_get_fd error:0x%x", hal_ret);
+        return -1;
     }
-    return ret;
+
+    return 0;
 }
 
 int32_t pa_hal_interface_pcm_recover(pa_hal_interface *h, pcm_handle pcm_h, int err) {
-    int32_t ret = 0;
-    audio_return_t hal_ret = AUDIO_RET_OK;
+    audio_return_e hal_ret = AUDIO_RET_OK;
 
     pa_assert(h);
     pa_assert(pcm_h);
 
-    if (AUDIO_RET_OK != (hal_ret = h->intf.pcm_recover(h->ah_handle, pcm_h, err))) {
-        pa_log_error("pcm_recover returns error:0x%x", hal_ret);
-        ret = -1;
+    hal_ret = hal_audio_pcm_recover(h->audio_handle, pcm_h, err);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_pcm_recover error:0x%x", hal_ret);
+        return -1;
     }
-    return ret;
+
+    return 0;
 }
 
-int32_t pa_hal_interface_pcm_get_params(pa_hal_interface *h, pcm_handle pcm_h, uint32_t direction, void **sample_spec, uint32_t *period_size, uint32_t *periods) {
-    int32_t ret = 0;
-    audio_return_t hal_ret = AUDIO_RET_OK;
+int32_t pa_hal_interface_pcm_get_params(pa_hal_interface *h, pcm_handle pcm_h, uint32_t direction,
+                                       void **sample_spec, uint32_t *period_size, uint32_t *periods) {
+    audio_return_e hal_ret = AUDIO_RET_OK;
 
     pa_assert(h);
     pa_assert(*sample_spec);
     pa_assert(period_size);
     pa_assert(periods);
 
-    if (AUDIO_RET_OK != (hal_ret = h->intf.pcm_get_params(h->ah_handle, pcm_h, direction, sample_spec, period_size, periods))) {
-        pa_log_error("pcm_get_params returns error:0x%x", hal_ret);
-        ret = -1;
+    hal_ret = hal_audio_pcm_get_params(h->audio_handle, pcm_h, direction, sample_spec, period_size, periods);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_pcm_get_params error:0x%x", hal_ret);
+        return -1;
     }
-    return ret;
+
+    return 0;
 }
 
-int32_t pa_hal_interface_pcm_set_params(pa_hal_interface *h, pcm_handle pcm_h, uint32_t direction, void *sample_spec, uint32_t period_size, uint32_t periods) {
-    int32_t ret = 0;
-    audio_return_t hal_ret = AUDIO_RET_OK;
+int32_t pa_hal_interface_pcm_set_params(pa_hal_interface *h, pcm_handle pcm_h, uint32_t direction,
+                                        void *sample_spec, uint32_t period_size, uint32_t periods) {
+    audio_return_e hal_ret = AUDIO_RET_OK;
 
     pa_assert(h);
     pa_assert(sample_spec);
 
-    if (AUDIO_RET_OK != (hal_ret = h->intf.pcm_set_params(h->ah_handle, pcm_h, direction, sample_spec, period_size, periods))) {
-        pa_log_error("pcm_set_params returns error:0x%x", hal_ret);
-        ret = -1;
+    hal_ret = hal_audio_pcm_set_params(h->audio_handle, pcm_h, direction, sample_spec, period_size, periods);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_pcm_set_params error:0x%x", hal_ret);
+        return -1;
     }
-    return ret;
+
+    return 0;
 }
 
 int32_t pa_hal_interface_add_message_callback(pa_hal_interface *h, hal_message_callback callback, void *user_data) {
-    int32_t ret = 0;
-    audio_return_t hal_ret = AUDIO_RET_OK;
+    audio_return_e hal_ret = AUDIO_RET_OK;
 
     pa_assert(h);
     pa_assert(callback);
 
-    if (h->intf.add_message_cb == NULL) {
-        pa_log_error("there is no add_message_cb symbol in this audio hal");
-        ret = -1;
-    } else if (AUDIO_RET_OK != (hal_ret = h->intf.add_message_cb(h->ah_handle, (message_cb)callback, user_data))) {
-        pa_log_error("add_message_cb returns error:0x%x", hal_ret);
-        ret = -1;
+    hal_ret = hal_audio_add_message_cb(h->audio_handle, (message_cb)callback, user_data);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_add_message_cb error:0x%x", hal_ret);
+        return -1;
     }
 
-    return ret;
+    return 0;
 }
 
 int32_t pa_hal_interface_remove_message_callback(pa_hal_interface *h, hal_message_callback callback) {
-    int32_t ret = 0;
-    audio_return_t hal_ret = AUDIO_RET_OK;
+    audio_return_e hal_ret = AUDIO_RET_OK;
 
     pa_assert(h);
     pa_assert(callback);
 
-    if (h->intf.remove_message_cb == NULL) {
-        pa_log_error("there is no remove_message_cb symbol in this audio hal");
-        ret = -1;
-    } else if (AUDIO_RET_OK != (hal_ret = h->intf.remove_message_cb(h->ah_handle, (message_cb)callback))) {
-        pa_log_error("remove_message_cb returns error:0x%x", hal_ret);
-        ret = -1;
+    hal_ret = hal_audio_remove_message_cb(h->audio_handle, (message_cb)callback);
+    if (hal_ret != AUDIO_RET_OK) {
+        pa_log_error("hal_audio_remove_message_cb error:0x%x", hal_ret);
+        return -1;
     }
 
-    return ret;
+    return 0;
 }
index 2351701f2dd8d9311932331cdbe8f2cef054d2fe..ebfca2f7abf2f224ca2298d40b54f479d616cb58 100644 (file)
@@ -65,10 +65,10 @@ typedef struct _hal_stream_info {
 } hal_stream_info;
 
 typedef struct _hal_ducking_activation_info {
-       const char *target_role;
-       uint32_t duration;
-       double ratio;
-       bool is_activated;
+    const char *target_role;
+    uint32_t duration;
+    double ratio;
+    bool is_activated;
 } hal_ducking_activation_info;
 
 typedef void* pcm_handle;
index a6c1075a6ba6ba8535829544d12bd6e927a3cfe4..09759e33fc193a2f561a535b93c790dd1780a7b5 100644 (file)
@@ -1047,7 +1047,7 @@ static void reset_route(struct userdata *u, stream_type_t stream_type) {
 
     /* unload combine sink */
     if (stream_type == STREAM_SINK_INPUT) {
-        if (null_sink = (pa_sink*)pa_namereg_get(u->core, SINK_NAME_NULL, PA_NAMEREG_SINK))
+        if ((null_sink = (pa_sink*)pa_namereg_get(u->core, SINK_NAME_NULL, PA_NAMEREG_SINK)))
             unload_combine_sink_module(u, SINK_NAME_COMBINED, null_sink);
     }
 
index 0ce45e272cb30b97fd7ec9b3b34fcce86ca7f247..d611844ff4ae053026aee3f5f149a4c4e6b0df8e 100644 (file)
@@ -3632,7 +3632,7 @@ static void subscribe_cb(pa_core *core, pa_subscription_event_type_t t, uint32_t
 }
 
 /* Message callback from HAL interface */
-static void message_cb(const char *name, int value, void *user_data) {
+static void message_cb_func(const char *name, int value, void *user_data) {
     pa_stream_manager *m;
     pa_stream_manager_hook_data_for_update_info hook_call_data;
 
@@ -3760,7 +3760,7 @@ pa_stream_manager* pa_stream_manager_get(pa_core *c) {
     if (!(m->hal = pa_hal_interface_get(c)))
         goto fail;
 
-    if (pa_hal_interface_add_message_callback(m->hal, message_cb, m))
+    if (pa_hal_interface_add_message_callback(m->hal, message_cb_func, m))
         pa_log_warn("skip adding message callback");
     m->dm = pa_device_manager_get(c);
     m->subs_ob = pa_subscribe_observer_get(c);
@@ -3823,7 +3823,7 @@ fail:
     deinit_filters(m);
     deinit_ipc(m);
     if (m->hal) {
-        pa_hal_interface_remove_message_callback(m->hal, message_cb);
+        pa_hal_interface_remove_message_callback(m->hal, message_cb_func);
         pa_hal_interface_unref(m->hal);
     }
     if (m->dm)
@@ -3937,7 +3937,7 @@ void pa_stream_manager_unref(pa_stream_manager *m) {
         pa_device_manager_unref(m->dm);
 
     if (m->hal) {
-        pa_hal_interface_remove_message_callback(m->hal, message_cb);
+        pa_hal_interface_remove_message_callback(m->hal, message_cb_func);
         pa_hal_interface_unref(m->hal);
     }