MODULE_LIBADD = $(AM_LIBADD) $(LIBLTDL)
pulsemodlibexec_LTLIBRARIES = \
- libhal-manager.la \
+ libhal-interface.la \
module-tizenaudio-sink.la \
module-tizenaudio-source.la \
module-sound-player.la \
# These are generated by an M4 script
SYMDEF_FILES = \
- libhal-manager-symdef.h \
+ libhal-interface-symdef.h \
module-tizenaudio-sink-symdef.h \
module-tizenaudio-source-symdef.h \
module-sound-player-symdef.h \
$(AM_V_at)$(MKDIR_P) .
$(AM_V_GEN)$(M4) -Dfname="$@" $< > $@
-libhal_manager_la_SOURCES = \
- src/hal-manager.c src/hal-manager.h
-libhal_manager_la_LDFLAGS = $(AM_LDFLAGS) $(PA_LDFLAGS) -avoid-version
-libhal_manager_la_LIBADD = $(AM_LIBADD) $(PACORE_LIBS) $(PA_LIBS)
-libhal_manager_la_CFLAGS = $(AM_CFLAGS) $(PACORE_CFLAGS) $(PA_CFLAGS)
+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)
module_tizenaudio_sink_la_SOURCES = src/module-tizenaudio-sink.c
module_tizenaudio_sink_la_LDFLAGS = $(PACORE_LDFLAGS) $(PA_LDFLAGS) $(MODULE_LDFLAGS)
-module_tizenaudio_sink_la_LIBADD = $(PACORE_LIBS) $(PA_LIBS) $(MODULE_LIBADD) libhal-manager.la
+module_tizenaudio_sink_la_LIBADD = $(PACORE_LIBS) $(PA_LIBS) $(MODULE_LIBADD) libhal-interface.la
module_tizenaudio_sink_la_CFLAGS = $(PACORE_CFLAGS) $(PA_CFLAGS) $(AM_CFLAGS)
module_tizenaudio_source_la_SOURCES = src/module-tizenaudio-source.c
module_tizenaudio_source_la_LDFLAGS = $(PACORE_LDFLAGS) $(PA_LDFLAGS) $(MODULE_LDFLAGS)
-module_tizenaudio_source_la_LIBADD = $(PACORE_LIBS) $(PA_LIBS) $(MODULE_LIBADD) libhal-manager.la
+module_tizenaudio_source_la_LIBADD = $(PACORE_LIBS) $(PA_LIBS) $(MODULE_LIBADD) libhal-interface.la
module_tizenaudio_source_la_CFLAGS = $(PACORE_CFLAGS) $(PA_CFLAGS) $(AM_CFLAGS)
module_sound_player_la_SOURCES = src/module-sound-player.c
src/device-manager.c src/device-manager.h \
src/subscribe-observer.c src/subscribe-observer.h
module_policy_la_LDFLAGS = $(MODULE_LDFLAGS) $(PACORE_LDFLAGS) $(PA_LDFLAGS) -L$(pulsemodlibexecdir)
-module_policy_la_LIBADD = $(AM_LIBADD) $(PACORE_LIBS) $(PA_LIBS) $(DBUS_LIBS) $(VCONF_LIBS) $(INIPARSER_LIBS) $(LIBJSON_LIBS) libhal-manager.la
+module_policy_la_LIBADD = $(AM_LIBADD) $(PACORE_LIBS) $(PA_LIBS) $(DBUS_LIBS) $(VCONF_LIBS) $(INIPARSER_LIBS) $(LIBJSON_LIBS) libhal-interface.la
module_policy_la_CFLAGS = $(AM_CFLAGS) $(PACORE_CFLAGS) $(PA_CFLAGS) $(DBUS_CFLAGS) $(VCONF_CFLAGS) $(INIPARSER_CFLAGS) $(LIBJSON_CFLAGS)
Name: pulseaudio-modules-tizen
Summary: Pulseaudio modules for Tizen
-Version: 5.0.49
+Version: 5.0.50
Release: 0
Group: Multimedia/Audio
License: LGPL-2.1+
%defattr(-,root,root,-)
%license LICENSE.LGPL-2.1+
%{_libdir}/pulse-5.0/modules/module-*.so
-%{_libdir}/pulse-5.0/modules/libhal-manager.so
+%{_libdir}/pulse-5.0/modules/libhal-interface.so
--- /dev/null
+/***
+ This file is part of PulseAudio.
+
+ Copyright 2015-2016 Sangchul Lee <sc11.lee@samsung.com>
+
+ PulseAudio is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License,
+ or (at your option) any later version.
+
+ PulseAudio is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with PulseAudio; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "hal-interface.h"
+#include "tizen-audio.h"
+#include <pulsecore/shared.h>
+
+#define SHARED_HAL_INTF "tizen-hal-interface"
+
+/* Audio HAL library */
+#define LIB_TIZEN_AUDIO "libtizen-audio.so"
+
+struct _pa_hal_interface {
+ PA_REFCNT_DECLARE;
+
+ pa_core *core;
+ void *dl_handle;
+ void *ah_handle;
+ audio_interface_t intf;
+};
+
+pa_hal_interface* pa_hal_interface_get(pa_core *core) {
+ pa_hal_interface *h;
+
+ pa_assert(core);
+
+ if ((h = pa_shared_get(core, SHARED_HAL_INTF)))
+ return pa_hal_interface_ref(h);
+
+ h = pa_xnew0(pa_hal_interface, 1);
+ 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.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.get_buffer_attr = dlsym(h->dl_handle, "audio_get_buffer_attr");
+ 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");
+ }
+
+ } else {
+ pa_log_error("open hal_interface failed :%s", dlerror());
+ return NULL;
+ }
+
+ pa_shared_set(core, SHARED_HAL_INTF, h);
+
+ return h;
+}
+
+pa_hal_interface* pa_hal_interface_ref(pa_hal_interface *h) {
+ pa_assert(h);
+ pa_assert(PA_REFCNT_VALUE(h) > 0);
+
+ PA_REFCNT_INC(h);
+
+ return h;
+}
+
+void pa_hal_interface_unref(pa_hal_interface *h) {
+ 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);
+ }
+
+ if (h->core)
+ pa_shared_remove(h->core, SHARED_HAL_INTF);
+
+ 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};
+
+ pa_assert(h);
+ pa_assert(volume_type);
+ pa_assert(level);
+
+ info.type = volume_type;
+ info.direction = direction;
+
+ if (AUDIO_IS_ERROR((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;
+ }
+ return ret;
+}
+
+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};
+
+ pa_assert(h);
+ pa_assert(volume_type);
+ pa_assert(level);
+
+ info.type = volume_type;
+ info.direction = direction;
+
+ if (AUDIO_IS_ERROR((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;
+ }
+ return ret;
+}
+
+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};
+
+ pa_assert(h);
+ pa_assert(volume_type);
+
+ info.type = volume_type;
+ info.direction = direction;
+
+ if (AUDIO_IS_ERROR((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;
+ }
+
+ return ret;
+}
+
+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};
+
+ pa_assert(h);
+ pa_assert(volume_type);
+ pa_assert(value);
+
+ info.type = volume_type;
+ info.gain = gain_type;
+ info.direction = direction;
+
+ if (AUDIO_IS_ERROR((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;
+ }
+
+ return ret;
+}
+
+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};
+
+ pa_assert(h);
+ pa_assert(volume_type);
+ pa_assert(mute);
+
+ info.type = volume_type;
+ info.direction = direction;
+
+ if (AUDIO_IS_ERROR((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;
+ }
+ return ret;
+}
+
+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};
+
+ pa_assert(h);
+ pa_assert(volume_type);
+
+ info.type = volume_type;
+ info.direction = direction;
+
+ if (AUDIO_IS_ERROR((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;
+ }
+ return ret;
+}
+
+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;
+
+ pa_assert(h);
+ pa_assert(info);
+
+ if (AUDIO_IS_ERROR((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;
+ }
+ return ret;
+}
+
+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;
+
+ pa_assert(h);
+ pa_assert(option);
+
+ if (AUDIO_IS_ERROR((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;
+ }
+ return ret;
+}
+
+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;
+
+ pa_assert(h);
+ pa_assert(info);
+
+ hal_info.role = info->role;
+ hal_info.direction = info->direction;
+ hal_info.idx = info->idx;
+
+ if (AUDIO_IS_ERROR((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;
+ }
+ return ret;
+}
+
+int32_t pa_hal_interface_get_buffer_attribute(pa_hal_interface *h, hal_stream_info *info,
+ uint32_t *maxlength, uint32_t *tlength, uint32_t *prebuf, uint32_t* minreq, uint32_t *fragsize) {
+ int32_t ret = 0;
+ audio_return_t hal_ret = AUDIO_RET_OK;
+
+ pa_assert(h);
+ pa_assert(info);
+
+ pa_log_info("latency:%s, rate:%u, format:%d, channels:%u",
+ info->latency, info->sample_spec->rate, info->sample_spec->format, info->sample_spec->channels);
+
+ if (AUDIO_IS_ERROR((hal_ret = h->intf.get_buffer_attr(h->ah_handle, info->direction, info->latency, info->sample_spec->rate, info->sample_spec->format,
+ info->sample_spec->channels, maxlength, tlength, prebuf, minreq, fragsize)))) {
+ pa_log_error("get_buffer_attr returns error:0x%x", hal_ret);
+ ret = -1;
+ } else
+ pa_log_info("maxlength:%d, tlength:%d, prebuf:%d, minreq:%d, fragsize:%d", *maxlength, *tlength, *prebuf, *minreq, *fragsize);
+
+ return ret;
+}
+
+int32_t pa_hal_interface_pcm_open(pa_hal_interface *h, pcm_handle *pcm_h, io_direction_t direction, pa_sample_spec *sample_spec, uint32_t period_size, uint32_t periods) {
+ int32_t ret = 0;
+ audio_return_t hal_ret = AUDIO_RET_OK;
+
+ pa_assert(h);
+ pa_assert(pcm_h);
+ pa_assert(sample_spec);
+
+ if (AUDIO_IS_ERROR((hal_ret = h->intf.pcm_open(h->ah_handle, pcm_h, direction, sample_spec, period_size, periods)))) {
+ pa_log_error("pcm_open returns error:0x%x", hal_ret);
+ ret = -1;
+ }
+ return ret;
+}
+
+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;
+
+ pa_assert(h);
+ pa_assert(pcm_h);
+
+ if (AUDIO_IS_ERROR((hal_ret = h->intf.pcm_start(h->ah_handle, pcm_h)))) {
+ pa_log_error("pcm_start returns error:0x%x", hal_ret);
+ ret = -1;
+ }
+ return ret;
+}
+
+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;
+
+ pa_assert(h);
+ pa_assert(pcm_h);
+
+ if (AUDIO_IS_ERROR((hal_ret = h->intf.pcm_stop(h->ah_handle, pcm_h)))) {
+ pa_log_error("pcm_stop returns error:0x%x", hal_ret);
+ ret = -1;
+ }
+ return ret;
+}
+
+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;
+
+ pa_assert(h);
+ pa_assert(pcm_h);
+
+ if (AUDIO_IS_ERROR((hal_ret = h->intf.pcm_close(h->ah_handle, pcm_h)))) {
+ pa_log_error("pcm_close returns error:0x%x", hal_ret);
+ ret = -1;
+ }
+ return ret;
+}
+
+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;
+
+ pa_assert(h);
+ pa_assert(pcm_h);
+ pa_assert(available);
+
+ if (AUDIO_IS_ERROR((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;
+ }
+ return ret;
+}
+
+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;
+
+ pa_assert(h);
+ pa_assert(pcm_h);
+ pa_assert(buffer);
+
+ if (AUDIO_IS_ERROR((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;
+ }
+ return ret;
+}
+
+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;
+
+ pa_assert(h);
+ pa_assert(pcm_h);
+ pa_assert(buffer);
+
+ if (AUDIO_IS_ERROR((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;
+ }
+ return ret;
+}
+
+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;
+
+ pa_assert(h);
+ pa_assert(pcm_h);
+ pa_assert(fd);
+
+ if (AUDIO_IS_ERROR((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;
+ }
+ return ret;
+}
+
+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;
+
+ pa_assert(h);
+ pa_assert(pcm_h);
+
+ if (AUDIO_IS_ERROR((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;
+ }
+ return ret;
+}
+
+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;
+
+ pa_assert(h);
+ pa_assert(*sample_spec);
+ pa_assert(period_size);
+ pa_assert(periods);
+
+ if (AUDIO_IS_ERROR((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;
+ }
+ return ret;
+}
+
+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;
+
+ pa_assert(h);
+ pa_assert(sample_spec);
+
+ if (AUDIO_IS_ERROR((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;
+ }
+ return ret;
+}
+
+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;
+
+ 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_IS_ERROR((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;
+ }
+
+ return ret;
+}
+
+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;
+
+ 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_IS_ERROR((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;
+ }
+
+ return ret;
+}
--- /dev/null
+#ifndef foohalinterfacefoo
+#define foohalinterfacefoo
+#include <dlfcn.h>
+#include <pulsecore/core.h>
+
+typedef struct _pa_hal_interface pa_hal_interface;
+
+typedef enum _io_direction {
+ DIRECTION_IN,
+ DIRECTION_OUT,
+} io_direction_t;
+
+typedef struct _hal_device_info {
+ const char *type;
+ uint32_t direction;
+ uint32_t id;
+} hal_device_info;
+
+typedef struct _hal_route_info {
+ const char *role;
+ hal_device_info *device_infos;
+ uint32_t num_of_devices;
+} hal_route_info;
+
+typedef struct _hal_route_option {
+ const char *role;
+ const char *name;
+ int32_t value;
+} hal_route_option;
+
+typedef struct _hal_stream_connection_info {
+ const char *role;
+ uint32_t direction;
+ uint32_t idx;
+ bool is_connected;
+} hal_stream_connection_info;
+
+typedef struct _hal_stream_info {
+ io_direction_t direction;
+ const char *latency;
+ pa_sample_spec *sample_spec;
+} hal_stream_info;
+
+typedef void* pcm_handle;
+
+#define MSG_FOR_LOOPBACK_ARG_LATENCY "loopback::latency"
+#define MSG_FOR_LOOPBACK_ARG_ADJUST_TIME "loopback::adjust_time"
+typedef void (*hal_message_callback)(const char *name, int value, void *user_data);
+
+pa_hal_interface* pa_hal_interface_get(pa_core *core);
+pa_hal_interface* pa_hal_interface_ref(pa_hal_interface *h);
+void pa_hal_interface_unref(pa_hal_interface *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 pa_hal_interface_get_volume_level(pa_hal_interface *h, const char *volume_type, io_direction_t direction, uint32_t *level);
+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 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 pa_hal_interface_get_volume_mute(pa_hal_interface *h, const char *volume_type, io_direction_t direction, uint32_t *mute);
+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 pa_hal_interface_update_route(pa_hal_interface *h, hal_route_info *info);
+int32_t pa_hal_interface_update_route_option(pa_hal_interface *h, hal_route_option *option);
+int32_t pa_hal_interface_notify_stream_connection_changed(pa_hal_interface *h, hal_stream_connection_info *info);
+int32_t pa_hal_interface_get_buffer_attribute(pa_hal_interface *h, hal_stream_info *info, uint32_t *maxlength, uint32_t *tlength, uint32_t *prebuf, uint32_t* minreq, uint32_t *fragsize);
+int32_t pa_hal_interface_pcm_open(pa_hal_interface *h, pcm_handle *pcm_h, io_direction_t direction, pa_sample_spec *sample_spec, uint32_t period_size, uint32_t periods);
+int32_t pa_hal_interface_pcm_start(pa_hal_interface *h, pcm_handle pcm_h);
+int32_t pa_hal_interface_pcm_stop(pa_hal_interface *h, pcm_handle pcm_h);
+int32_t pa_hal_interface_pcm_close(pa_hal_interface *h, pcm_handle pcm_h);
+int32_t pa_hal_interface_pcm_available(pa_hal_interface *h, pcm_handle pcm_h, uint32_t *available);
+int32_t pa_hal_interface_pcm_write(pa_hal_interface *h, pcm_handle pcm_h, const void *buffer, uint32_t frames);
+int32_t pa_hal_interface_pcm_read(pa_hal_interface *h, pcm_handle pcm_h, void *buffer, uint32_t frames);
+int32_t pa_hal_interface_pcm_get_fd(pa_hal_interface *h, pcm_handle pcm_h, int *fd);
+int32_t pa_hal_interface_pcm_recover(pa_hal_interface *h, pcm_handle pcm_h, int err);
+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 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 pa_hal_interface_add_message_callback(pa_hal_interface *h, hal_message_callback callback, void *user_data);
+int32_t pa_hal_interface_remove_message_callback(pa_hal_interface *h, hal_message_callback callback);
+
+#endif
+++ /dev/null
-/***
- This file is part of PulseAudio.
-
- Copyright 2015 Sangchul Lee <sc11.lee@samsung.com>
-
- PulseAudio is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License,
- or (at your option) any later version.
-
- PulseAudio is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with PulseAudio; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- USA.
-***/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "hal-manager.h"
-#include "tizen-audio.h"
-#include <pulsecore/shared.h>
-
-#define SHARED_HAL_MANAGER "tizen-hal-manager"
-
-/* Audio HAL library */
-#define LIB_TIZEN_AUDIO "libtizen-audio.so"
-
-struct _pa_hal_manager {
- PA_REFCNT_DECLARE;
-
- pa_core *core;
- void *dl_handle;
- void *ah_handle;
- audio_interface_t intf;
-};
-
-pa_hal_manager* pa_hal_manager_get(pa_core *core) {
- pa_hal_manager *h;
-
- pa_assert(core);
-
- if ((h = pa_shared_get(core, SHARED_HAL_MANAGER)))
- return pa_hal_manager_ref(h);
-
- h = pa_xnew0(pa_hal_manager, 1);
- PA_REFCNT_INIT(h);
- h->core = core;
-
- /* Load library & init HAL manager */
- 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.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.get_buffer_attr = dlsym(h->dl_handle, "audio_get_buffer_attr");
- 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_manager init failed");
- }
-
- } else {
- pa_log_error("open hal_manager failed :%s", dlerror());
- return NULL;
- }
-
- pa_shared_set(core, SHARED_HAL_MANAGER, h);
-
- return h;
-}
-
-pa_hal_manager* pa_hal_manager_ref(pa_hal_manager *h) {
- pa_assert(h);
- pa_assert(PA_REFCNT_VALUE(h) > 0);
-
- PA_REFCNT_INC(h);
-
- return h;
-}
-
-void pa_hal_manager_unref(pa_hal_manager *h) {
- 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_manager deinit failed");
- }
- }
- if (h->dl_handle) {
- dlclose(h->dl_handle);
- }
-
- if (h->core)
- pa_shared_remove(h->core, SHARED_HAL_MANAGER);
-
- pa_xfree(h);
-}
-
-int32_t pa_hal_manager_get_volume_level_max(pa_hal_manager *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};
-
- pa_assert(h);
- pa_assert(volume_type);
- pa_assert(level);
-
- info.type = volume_type;
- info.direction = direction;
-
- if (AUDIO_IS_ERROR((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;
- }
- return ret;
-}
-
-int32_t pa_hal_manager_get_volume_level(pa_hal_manager *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};
-
- pa_assert(h);
- pa_assert(volume_type);
- pa_assert(level);
-
- info.type = volume_type;
- info.direction = direction;
-
- if (AUDIO_IS_ERROR((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;
- }
- return ret;
-}
-
-int32_t pa_hal_manager_set_volume_level(pa_hal_manager *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};
-
- pa_assert(h);
- pa_assert(volume_type);
-
- info.type = volume_type;
- info.direction = direction;
-
- if (AUDIO_IS_ERROR((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;
- }
-
- return ret;
-}
-
-int32_t pa_hal_manager_get_volume_value(pa_hal_manager *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};
-
- pa_assert(h);
- pa_assert(volume_type);
- pa_assert(value);
-
- info.type = volume_type;
- info.gain = gain_type;
- info.direction = direction;
-
- if (AUDIO_IS_ERROR((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;
- }
-
- return ret;
-}
-
-int32_t pa_hal_manager_get_volume_mute(pa_hal_manager *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};
-
- pa_assert(h);
- pa_assert(volume_type);
- pa_assert(mute);
-
- info.type = volume_type;
- info.direction = direction;
-
- if (AUDIO_IS_ERROR((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;
- }
- return ret;
-}
-
-int32_t pa_hal_manager_set_volume_mute(pa_hal_manager *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};
-
- pa_assert(h);
- pa_assert(volume_type);
-
- info.type = volume_type;
- info.direction = direction;
-
- if (AUDIO_IS_ERROR((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;
- }
- return ret;
-}
-
-int32_t pa_hal_manager_update_route(pa_hal_manager *h, hal_route_info *info) {
- int32_t ret = 0;
- audio_return_t hal_ret = AUDIO_RET_OK;
-
- pa_assert(h);
- pa_assert(info);
-
- if (AUDIO_IS_ERROR((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;
- }
- return ret;
-}
-
-int32_t pa_hal_manager_update_route_option(pa_hal_manager *h, hal_route_option *option) {
- int32_t ret = 0;
- audio_return_t hal_ret = AUDIO_RET_OK;
-
- pa_assert(h);
- pa_assert(option);
-
- if (AUDIO_IS_ERROR((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;
- }
- return ret;
-}
-
-int32_t pa_hal_manager_notify_stream_connection_changed(pa_hal_manager *h, hal_stream_connection_info *info) {
- int32_t ret = 0;
- audio_return_t hal_ret = AUDIO_RET_OK;
- audio_stream_info_t hal_info;
-
- pa_assert(h);
- pa_assert(info);
-
- hal_info.role = info->role;
- hal_info.direction = info->direction;
- hal_info.idx = info->idx;
-
- if (AUDIO_IS_ERROR((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;
- }
- return ret;
-}
-
-int32_t pa_hal_manager_get_buffer_attribute(pa_hal_manager *h, hal_stream_info *info,
- uint32_t *maxlength, uint32_t *tlength, uint32_t *prebuf, uint32_t* minreq, uint32_t *fragsize) {
- int32_t ret = 0;
- audio_return_t hal_ret = AUDIO_RET_OK;
-
- pa_assert(h);
- pa_assert(info);
-
- pa_log_info("latency:%s, rate:%u, format:%d, channels:%u",
- info->latency, info->sample_spec->rate, info->sample_spec->format, info->sample_spec->channels);
-
- if (AUDIO_IS_ERROR((hal_ret = h->intf.get_buffer_attr(h->ah_handle, info->direction, info->latency, info->sample_spec->rate, info->sample_spec->format,
- info->sample_spec->channels, maxlength, tlength, prebuf, minreq, fragsize)))) {
- pa_log_error("get_buffer_attr returns error:0x%x", hal_ret);
- ret = -1;
- } else
- pa_log_info("maxlength:%d, tlength:%d, prebuf:%d, minreq:%d, fragsize:%d", *maxlength, *tlength, *prebuf, *minreq, *fragsize);
-
- return ret;
-}
-
-int32_t pa_hal_manager_pcm_open(pa_hal_manager *h, pcm_handle *pcm_h, io_direction_t direction, pa_sample_spec *sample_spec, uint32_t period_size, uint32_t periods) {
- int32_t ret = 0;
- audio_return_t hal_ret = AUDIO_RET_OK;
-
- pa_assert(h);
- pa_assert(pcm_h);
- pa_assert(sample_spec);
-
- if (AUDIO_IS_ERROR((hal_ret = h->intf.pcm_open(h->ah_handle, pcm_h, direction, sample_spec, period_size, periods)))) {
- pa_log_error("pcm_open returns error:0x%x", hal_ret);
- ret = -1;
- }
- return ret;
-}
-
-int32_t pa_hal_manager_pcm_start(pa_hal_manager *h, pcm_handle pcm_h) {
- int32_t ret = 0;
- audio_return_t hal_ret = AUDIO_RET_OK;
-
- pa_assert(h);
- pa_assert(pcm_h);
-
- if (AUDIO_IS_ERROR((hal_ret = h->intf.pcm_start(h->ah_handle, pcm_h)))) {
- pa_log_error("pcm_start returns error:0x%x", hal_ret);
- ret = -1;
- }
- return ret;
-}
-
-int32_t pa_hal_manager_pcm_stop(pa_hal_manager *h, pcm_handle pcm_h) {
- int32_t ret = 0;
- audio_return_t hal_ret = AUDIO_RET_OK;
-
- pa_assert(h);
- pa_assert(pcm_h);
-
- if (AUDIO_IS_ERROR((hal_ret = h->intf.pcm_stop(h->ah_handle, pcm_h)))) {
- pa_log_error("pcm_stop returns error:0x%x", hal_ret);
- ret = -1;
- }
- return ret;
-}
-
-int32_t pa_hal_manager_pcm_close(pa_hal_manager *h, pcm_handle pcm_h) {
- int32_t ret = 0;
- audio_return_t hal_ret = AUDIO_RET_OK;
-
- pa_assert(h);
- pa_assert(pcm_h);
-
- if (AUDIO_IS_ERROR((hal_ret = h->intf.pcm_close(h->ah_handle, pcm_h)))) {
- pa_log_error("pcm_close returns error:0x%x", hal_ret);
- ret = -1;
- }
- return ret;
-}
-
-int32_t pa_hal_manager_pcm_available(pa_hal_manager *h, pcm_handle pcm_h, uint32_t *available) {
- int32_t ret = 0;
- audio_return_t hal_ret = AUDIO_RET_OK;
-
- pa_assert(h);
- pa_assert(pcm_h);
- pa_assert(available);
-
- if (AUDIO_IS_ERROR((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;
- }
- return ret;
-}
-
-int32_t pa_hal_manager_pcm_write(pa_hal_manager *h, pcm_handle pcm_h, const void *buffer, uint32_t frames) {
- int32_t ret = 0;
- audio_return_t hal_ret = AUDIO_RET_OK;
-
- pa_assert(h);
- pa_assert(pcm_h);
- pa_assert(buffer);
-
- if (AUDIO_IS_ERROR((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;
- }
- return ret;
-}
-
-int32_t pa_hal_manager_pcm_read(pa_hal_manager *h, pcm_handle pcm_h, void *buffer, uint32_t frames) {
- int32_t ret = 0;
- audio_return_t hal_ret = AUDIO_RET_OK;
-
- pa_assert(h);
- pa_assert(pcm_h);
- pa_assert(buffer);
-
- if (AUDIO_IS_ERROR((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;
- }
- return ret;
-}
-
-int32_t pa_hal_manager_pcm_get_fd(pa_hal_manager *h, pcm_handle pcm_h, int *fd) {
- int32_t ret = 0;
- audio_return_t hal_ret = AUDIO_RET_OK;
-
- pa_assert(h);
- pa_assert(pcm_h);
- pa_assert(fd);
-
- if (AUDIO_IS_ERROR((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;
- }
- return ret;
-}
-
-int32_t pa_hal_manager_pcm_recover(pa_hal_manager *h, pcm_handle pcm_h, int err) {
- int32_t ret = 0;
- audio_return_t hal_ret = AUDIO_RET_OK;
-
- pa_assert(h);
- pa_assert(pcm_h);
-
- if (AUDIO_IS_ERROR((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;
- }
- return ret;
-}
-
-int32_t pa_hal_manager_pcm_get_params(pa_hal_manager *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;
-
- pa_assert(h);
- pa_assert(*sample_spec);
- pa_assert(period_size);
- pa_assert(periods);
-
- if (AUDIO_IS_ERROR((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;
- }
- return ret;
-}
-
-int32_t pa_hal_manager_pcm_set_params(pa_hal_manager *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;
-
- pa_assert(h);
- pa_assert(sample_spec);
-
- if (AUDIO_IS_ERROR((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;
- }
- return ret;
-}
-
-int32_t pa_hal_manager_add_message_callback(pa_hal_manager *h, hal_message_callback callback, void *user_data) {
- int32_t ret = 0;
- audio_return_t 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_IS_ERROR((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;
- }
-
- return ret;
-}
-
-int32_t pa_hal_manager_remove_message_callback(pa_hal_manager *h, hal_message_callback callback) {
- int32_t ret = 0;
- audio_return_t 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_IS_ERROR((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;
- }
-
- return ret;
-}
+++ /dev/null
-#ifndef foohalmanagerfoo
-#define foohalmanagerfoo
-#include <dlfcn.h>
-#include <pulsecore/core.h>
-
-typedef struct _pa_hal_manager pa_hal_manager;
-
-typedef enum _io_direction {
- DIRECTION_IN,
- DIRECTION_OUT,
-} io_direction_t;
-
-typedef struct _hal_device_info {
- const char *type;
- uint32_t direction;
- uint32_t id;
-} hal_device_info;
-
-typedef struct _hal_route_info {
- const char *role;
- hal_device_info *device_infos;
- uint32_t num_of_devices;
-} hal_route_info;
-
-typedef struct _hal_route_option {
- const char *role;
- const char *name;
- int32_t value;
-} hal_route_option;
-
-typedef struct _hal_stream_connection_info {
- const char *role;
- uint32_t direction;
- uint32_t idx;
- bool is_connected;
-} hal_stream_connection_info;
-
-typedef struct _hal_stream_info {
- io_direction_t direction;
- const char *latency;
- pa_sample_spec *sample_spec;
-} hal_stream_info;
-
-typedef void* pcm_handle;
-
-#define MSG_FOR_LOOPBACK_ARG_LATENCY "loopback::latency"
-#define MSG_FOR_LOOPBACK_ARG_ADJUST_TIME "loopback::adjust_time"
-typedef void (*hal_message_callback)(const char *name, int value, void *user_data);
-
-pa_hal_manager* pa_hal_manager_get(pa_core *core);
-pa_hal_manager* pa_hal_manager_ref(pa_hal_manager *h);
-void pa_hal_manager_unref(pa_hal_manager *h);
-int32_t pa_hal_manager_get_volume_level_max(pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t *level);
-int32_t pa_hal_manager_get_volume_level(pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t *level);
-int32_t pa_hal_manager_set_volume_level(pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t level);
-int32_t pa_hal_manager_get_volume_value(pa_hal_manager *h, const char *volume_type, const char *gain_type, io_direction_t direction, uint32_t level, double *value);
-int32_t pa_hal_manager_get_volume_mute(pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t *mute);
-int32_t pa_hal_manager_set_volume_mute(pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t mute);
-int32_t pa_hal_manager_update_route(pa_hal_manager *h, hal_route_info *info);
-int32_t pa_hal_manager_update_route_option(pa_hal_manager *h, hal_route_option *option);
-int32_t pa_hal_manager_notify_stream_connection_changed(pa_hal_manager *h, hal_stream_connection_info *info);
-int32_t pa_hal_manager_get_buffer_attribute(pa_hal_manager *h, hal_stream_info *info, uint32_t *maxlength, uint32_t *tlength, uint32_t *prebuf, uint32_t* minreq, uint32_t *fragsize);
-int32_t pa_hal_manager_pcm_open(pa_hal_manager *h, pcm_handle *pcm_h, io_direction_t direction, pa_sample_spec *sample_spec, uint32_t period_size, uint32_t periods);
-int32_t pa_hal_manager_pcm_start(pa_hal_manager *h, pcm_handle pcm_h);
-int32_t pa_hal_manager_pcm_stop(pa_hal_manager *h, pcm_handle pcm_h);
-int32_t pa_hal_manager_pcm_close(pa_hal_manager *h, pcm_handle pcm_h);
-int32_t pa_hal_manager_pcm_available(pa_hal_manager *h, pcm_handle pcm_h, uint32_t *available);
-int32_t pa_hal_manager_pcm_write(pa_hal_manager *h, pcm_handle pcm_h, const void *buffer, uint32_t frames);
-int32_t pa_hal_manager_pcm_read(pa_hal_manager *h, pcm_handle pcm_h, void *buffer, uint32_t frames);
-int32_t pa_hal_manager_pcm_get_fd(pa_hal_manager *h, pcm_handle pcm_h, int *fd);
-int32_t pa_hal_manager_pcm_recover(pa_hal_manager *h, pcm_handle pcm_h, int err);
-int32_t pa_hal_manager_pcm_get_params(pa_hal_manager *h, pcm_handle pcm_h, uint32_t direction, void **sample_spec, uint32_t *period_size, uint32_t *periods);
-int32_t pa_hal_manager_pcm_set_params(pa_hal_manager *h, pcm_handle pcm_h, uint32_t direction, void *sample_spec, uint32_t period_size, uint32_t periods);
-int32_t pa_hal_manager_add_message_callback(pa_hal_manager *h, hal_message_callback callback, void *user_data);
-int32_t pa_hal_manager_remove_message_callback(pa_hal_manager *h, hal_message_callback callback);
-
-#endif
#include "module-policy-symdef.h"
#include "communicator.h"
-#include "hal-manager.h"
+#include "hal-interface.h"
#include "stream-manager.h"
#include "device-manager.h"
pa_hook_slot *comm_hook_update_info_slot;
} communicator;
- pa_hal_manager *hal_manager;
+ pa_hal_interface *hal_interface;
pa_stream_manager *stream_manager;
pa_device_manager *device_manager;
if (route_info.device_infos) {
/* send information to HAL to update route */
- if (pa_hal_manager_update_route(u->hal_manager, &route_info))
- pa_log_error("[ROUTE] Failed to pa_hal_manager_update_route()");
+ if (pa_hal_interface_update_route(u->hal_interface, &route_info))
+ pa_log_error("[ROUTE] Failed to pa_hal_interface_update_route()");
pa_xfree(route_info.device_infos);
}
u->core = m->core;
u->module = m;
- u->hal_manager = pa_hal_manager_get(u->core);
+ u->hal_interface = pa_hal_interface_get(u->core);
if ((u->communicator.comm = pa_communicator_get(u->core))) {
u->communicator.comm_hook_select_proper_sink_or_source_slot = pa_hook_connect(
pa_communicator_unref(u->communicator.comm);
}
- if (u->hal_manager)
- pa_hal_manager_unref(u->hal_manager);
+ if (u->hal_interface)
+ pa_hal_interface_unref(u->hal_interface);
pa_xfree(u);
#include <pulsecore/rtpoll.h>
#include <pulsecore/poll.h>
-#include "hal-manager.h"
+#include "hal-interface.h"
#include "module-tizenaudio-sink-symdef.h"
pa_rtpoll_item *rtpoll_item;
uint64_t write_count;
- pa_hal_manager *hal_manager;
+ pa_hal_interface *hal_interface;
};
static const char* const valid_modargs[] = {
u->rtpoll_item = pa_rtpoll_item_new(u->rtpoll, PA_RTPOLL_NEVER, 1);
pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
- ret = pa_hal_manager_pcm_get_fd(u->hal_manager, u->pcm_handle, &fd);
+ ret = pa_hal_interface_pcm_get_fd(u->hal_interface, u->pcm_handle, &fd);
if (ret < 0 || fd < 0) {
pa_log_error("Failed to get fd(%d) of PCM device %d", fd, ret);
return -1;
pa_assert(u);
pa_assert(u->pcm_handle);
- ret = pa_hal_manager_pcm_close(u->hal_manager, u->pcm_handle);
+ ret = pa_hal_interface_pcm_close(u->hal_interface, u->pcm_handle);
if (ret) {
pa_log_error("Error closing PCM device %x", ret);
}
pa_log_info("Trying resume...");
sample_spec = u->sink->sample_spec;
- ret = pa_hal_manager_pcm_open(u->hal_manager,
+ ret = pa_hal_interface_pcm_open(u->hal_interface,
(void **)&u->pcm_handle,
DIRECTION_OUT,
&sample_spec,
fail:
if (u->pcm_handle) {
- pa_hal_manager_pcm_close(u->hal_manager, u->pcm_handle);
+ pa_hal_interface_pcm_close(u->hal_interface, u->pcm_handle);
u->pcm_handle = NULL;
}
return -PA_ERR_IO;
pa_memchunk chunk;
frame_size = pa_frame_size(&u->sink->sample_spec);
- pa_hal_manager_pcm_available(u->hal_manager, u->pcm_handle, &avail);
+ pa_hal_interface_pcm_available(u->hal_interface, u->pcm_handle, &avail);
if ((avail == 0) && !(u->first)) {
break;
}
pa_sink_render_full(u->sink, frames_to_write * frame_size, &chunk);
p = pa_memblock_acquire(chunk.memblock);
- pa_hal_manager_pcm_write(u->hal_manager, u->pcm_handle, (const char*)p + chunk.index, (uint32_t)frames_to_write);
+ pa_hal_interface_pcm_write(u->hal_interface, u->pcm_handle, (const char*)p + chunk.index, (uint32_t)frames_to_write);
pa_memblock_release(chunk.memblock);
pa_memblock_unref(chunk.memblock);
} else {
if (u->first) {
pa_log_info("Starting playback.");
- pa_hal_manager_pcm_start(u->hal_manager, u->pcm_handle);
+ pa_hal_interface_pcm_start(u->hal_interface, u->pcm_handle);
u->first = false;
}
pa_rtpoll_set_timer_relative(u->rtpoll, (10 * PA_USEC_PER_MSEC));
revents = pollfd->revents;
if (revents & ~POLLOUT) {
pa_log_debug("Poll error 0x%x occured, try recover.", revents);
- pa_hal_manager_pcm_recover(u->hal_manager, u->pcm_handle, revents);
+ pa_hal_interface_pcm_recover(u->hal_interface, u->pcm_handle, revents);
u->first = true;
revents = 0;
} else {
u->core = m->core;
u->module = m;
u->first = true;
- u->hal_manager = pa_hal_manager_get(u->core);
+ u->hal_interface = pa_hal_interface_get(u->core);
u->rtpoll = pa_rtpoll_new();
pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll);
#include <pulsecore/rtpoll.h>
#include <pulsecore/poll.h>
-#include "hal-manager.h"
+#include "hal-interface.h"
#include "module-tizenaudio-source-symdef.h"
uint64_t read_count;
pa_usec_t latency_time;
- pa_hal_manager *hal_manager;
+ pa_hal_interface *hal_interface;
};
static const char* const valid_modargs[] = {
u->rtpoll_item = pa_rtpoll_item_new(u->rtpoll, PA_RTPOLL_NEVER, 1);
pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
- ret = pa_hal_manager_pcm_get_fd(u->hal_manager, u->pcm_handle, &fd);
+ ret = pa_hal_interface_pcm_get_fd(u->hal_interface, u->pcm_handle, &fd);
if (ret < 0 || fd < 0) {
pa_log_error("Failed to get fd(%d) of PCM device %d", fd, ret);
return -1;
pa_assert(u);
pa_assert(u->pcm_handle);
- ret = pa_hal_manager_pcm_close(u->hal_manager, u->pcm_handle);
+ ret = pa_hal_interface_pcm_close(u->hal_interface, u->pcm_handle);
if (ret) {
pa_log_error("Error closing PCM device %x", ret);
}
pa_log_info("Trying resume...");
sample_spec = u->source->sample_spec;
- ret = pa_hal_manager_pcm_open(u->hal_manager,
+ ret = pa_hal_interface_pcm_open(u->hal_interface,
(void **)&u->pcm_handle,
DIRECTION_IN,
&sample_spec,
fail:
if (u->pcm_handle) {
- pa_hal_manager_pcm_close(u->hal_manager, u->pcm_handle);
+ pa_hal_interface_pcm_close(u->hal_interface, u->pcm_handle);
u->pcm_handle = NULL;
}
return -PA_ERR_IO;
pa_memchunk chunk;
frame_size = pa_frame_size(&u->source->sample_spec);
- pa_hal_manager_pcm_available(u->hal_manager, u->pcm_handle, &avail);
+ pa_hal_interface_pcm_available(u->hal_interface, u->pcm_handle, &avail);
if (avail == 0) {
break;
}
frames_to_read = (size_t)avail;
p = pa_memblock_acquire(chunk.memblock);
- pa_hal_manager_pcm_read(u->hal_manager, u->pcm_handle, p, (uint32_t)frames_to_read);
+ pa_hal_interface_pcm_read(u->hal_interface, u->pcm_handle, p, (uint32_t)frames_to_read);
pa_memblock_release(chunk.memblock);
chunk.index = 0;
if (u->first) {
pa_log_info("Starting capture.");
- pa_hal_manager_pcm_start(u->hal_manager, u->pcm_handle);
+ pa_hal_interface_pcm_start(u->hal_interface, u->pcm_handle);
u->first = false;
u->timestamp = now;
}
revents = pollfd->revents;
if (revents & ~POLLIN) {
pa_log_debug("Poll error 0x%x occured, try recover.", revents);
- pa_hal_manager_pcm_recover(u->hal_manager, u->pcm_handle, revents);
+ pa_hal_interface_pcm_recover(u->hal_interface, u->pcm_handle, revents);
u->first = true;
revents = 0;
} else {
u->core = m->core;
u->module = m;
u->first = true;
- u->hal_manager = pa_hal_manager_get(u->core);
+ u->hal_interface = pa_hal_interface_get(u->core);
u->rtpoll = pa_rtpoll_new();
pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll);
#define foostreammanagerprivfoo
#include "stream-manager.h"
-#include "hal-manager.h"
+#include "hal-interface.h"
#include "communicator.h"
#include "device-manager.h"
#include "subscribe-observer.h"
struct _stream_manager {
pa_core *core;
- pa_hal_manager *hal;
+ pa_hal_interface *hal;
pa_device_manager *dm;
pa_subscribe_observer *subs_ob;
/* Get volume value by type & level */
if (is_hal_volume) {
/* Get value from HAL */
- if (pa_hal_manager_get_volume_value(m->hal, volume_type, NULL,
+ if (pa_hal_interface_get_volume_value(m->hal, volume_type, NULL,
CONVERT_TO_HAL_DIRECTION(stream_type), volume_level, &volume_linear)) {
return -1;
}
}
if (is_hal_volume)
- if (pa_hal_manager_set_volume_level(m->hal, volume_type, CONVERT_TO_HAL_DIRECTION(stream_type), volume_level))
+ if (pa_hal_interface_set_volume_level(m->hal, volume_type, CONVERT_TO_HAL_DIRECTION(stream_type), volume_level))
return -1;
volumes = m->volume_infos;
/* Get level */
if (is_hal_volume) {
/* from HAL */
- if (pa_hal_manager_get_volume_level(m->hal, volume_type, CONVERT_TO_HAL_DIRECTION(stream_type), volume_level))
+ if (pa_hal_interface_get_volume_level(m->hal, volume_type, CONVERT_TO_HAL_DIRECTION(stream_type), volume_level))
return -1;
} else {
/* from stream-manager */
/* Get max level */
if (is_hal_volume) {
/* from HAL */
- if (pa_hal_manager_get_volume_level_max(m->hal, volume_type, CONVERT_TO_HAL_DIRECTION(stream_type), volume_level))
+ if (pa_hal_interface_get_volume_level_max(m->hal, volume_type, CONVERT_TO_HAL_DIRECTION(stream_type), volume_level))
return -1;
} else {
/* from stream-manager */
}
if (is_hal_volume)
- if (pa_hal_manager_set_volume_level(m->hal, volume_type_str, CONVERT_TO_HAL_DIRECTION(stream_type), volume_level))
+ if (pa_hal_interface_set_volume_level(m->hal, volume_type_str, CONVERT_TO_HAL_DIRECTION(stream_type), volume_level))
return -1;
/* Get modifier for gain */
}
if (is_hal_volume)
- if (pa_hal_manager_set_volume_level(m->hal, volume_type_str, CONVERT_TO_HAL_DIRECTION(stream_type), volume_level))
+ if (pa_hal_interface_set_volume_level(m->hal, volume_type_str, CONVERT_TO_HAL_DIRECTION(stream_type), volume_level))
return -1;
/* Get modifier for gain */
}
if (is_hal_volume)
- if (pa_hal_manager_set_volume_mute(m->hal, volume_type, CONVERT_TO_HAL_DIRECTION(stream_type), (uint32_t)volume_mute))
+ if (pa_hal_interface_set_volume_mute(m->hal, volume_type, CONVERT_TO_HAL_DIRECTION(stream_type), (uint32_t)volume_mute))
return -1;
/* Set mute */
}
if (is_hal_volume)
- if (pa_hal_manager_set_volume_mute(m->hal, volume_type_str, CONVERT_TO_HAL_DIRECTION(stream_type), volume_mute))
+ if (pa_hal_interface_set_volume_mute(m->hal, volume_type_str, CONVERT_TO_HAL_DIRECTION(stream_type), volume_mute))
return -1;
if (stream_type == STREAM_SINK_INPUT)
(m->cur_highest_priority.role_so);
route_option.name = ((stream_route_option*)user_data)->name;
route_option.value = ((stream_route_option*)user_data)->value;
- pa_hal_manager_update_route_option(m->hal, &route_option);
+ pa_hal_interface_update_route_option(m->hal, &route_option);
}
break;
}
stream_conn_info.direction = (type == STREAM_SINK_INPUT) ? DIRECTION_OUT : DIRECTION_IN;
stream_conn_info.idx = (type == STREAM_SINK_INPUT) ? ((pa_sink_input*)s)->index : ((pa_source_output*)s)->index;
stream_conn_info.is_connected = (command == NOTIFY_COMMAND_INFORM_STREAM_CONNECTED) ? true : false;
- pa_hal_manager_notify_stream_connection_changed(m->hal, &stream_conn_info);
+ pa_hal_interface_notify_stream_connection_changed(m->hal, &stream_conn_info);
}
break;
}
info.direction = (io_direction_t)!stream_type;
info.sample_spec = GET_STREAM_NEW_SAMPLE_SPEC_PTR(new_data, stream_type);
- if (!pa_hal_manager_get_buffer_attribute(m->hal, &info, (uint32_t*)&maxlength, (uint32_t*)&tlength,
+ if (!pa_hal_interface_get_buffer_attribute(m->hal, &info, (uint32_t*)&maxlength, (uint32_t*)&tlength,
(uint32_t*)&prebuf, (uint32_t*)&minreq, (uint32_t*)&fragsize)) {
pa_log_info(" - maxlength:%d, tlength:%d, prebuf:%d, minreq:%d, fragsize:%d", maxlength, tlength, prebuf, minreq, fragsize);
pa_proplist_setf(GET_STREAM_NEW_PROPLIST(new_data, stream_type), "maxlength", "%d", maxlength);
m = pa_xnew0(pa_stream_manager, 1);
m->core = c;
- m->hal = pa_hal_manager_get(c);
- if (pa_hal_manager_add_message_callback(m->hal, message_cb, m))
+ m->hal = pa_hal_interface_get(c);
+ if (pa_hal_interface_add_message_callback(m->hal, message_cb, m))
pa_log_warn("skip adding message callback");
m->dm = pa_device_manager_get(c);
m->subs_ob = pa_subscribe_observer_get(c);
deinit_stream_map(m);
deinit_ipc(m);
if (m->hal) {
- pa_hal_manager_remove_message_callback(m->hal, message_cb);
- pa_hal_manager_unref(m->hal);
+ pa_hal_interface_remove_message_callback(m->hal, message_cb);
+ pa_hal_interface_unref(m->hal);
}
if (m->dm)
pa_device_manager_unref(m->dm);
pa_device_manager_unref(m->dm);
if (m->hal) {
- pa_hal_manager_remove_message_callback(m->hal, message_cb);
- pa_hal_manager_unref(m->hal);
+ pa_hal_interface_remove_message_callback(m->hal, message_cb);
+ pa_hal_interface_unref(m->hal);
}
pa_xfree(m);