summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSangchul Lee <sc11.lee@samsung.com>2016-01-15 15:08:32 +0900
committerSangchul Lee <sc11.lee@samsung.com>2016-01-15 17:28:18 +0900
commitdd3c8dcf992c0e5880faede16b4a094eb96ff424 (patch)
treea4708f2b8ee73cd3eed692754b7703733e36d887
parent66cebc127215e96f7abdb55a3fd5b5ad9d686969 (diff)
downloadaudio-hal-max98090-dd3c8dcf992c0e5880faede16b4a094eb96ff424.tar.gz
audio-hal-max98090-dd3c8dcf992c0e5880faede16b4a094eb96ff424.tar.bz2
audio-hal-max98090-dd3c8dcf992c0e5880faede16b4a094eb96ff424.zip
[Version] 0.2.16 [Profile] TV [Issue Type] Feature Enhancement Change-Id: Ib737dd6d9dbd972929d52202eb8e1e9576174f62
-rw-r--r--Makefile.am1
-rw-r--r--packaging/audio-hal-max98090.spec2
-rw-r--r--tizen-audio-comm.c91
-rw-r--r--tizen-audio-internal.h17
-rw-r--r--tizen-audio.c17
-rw-r--r--tizen-audio.h5
6 files changed, 129 insertions, 4 deletions
diff --git a/Makefile.am b/Makefile.am
index 1145f10..b5c6943 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,6 +4,7 @@ libtizen_audio_la_SOURCES = tizen-audio.c \
tizen-audio-device.c \
tizen-audio-volume.c \
tizen-audio-ucm.c \
+ tizen-audio-comm.c \
tizen-audio-util.c
libtizen_audio_la_LDFLAGS = $(AM_LDFLAGS) -disable-static -avoid-version
if USE_TINYALSA
diff --git a/packaging/audio-hal-max98090.spec b/packaging/audio-hal-max98090.spec
index 1d9ce95..860c801 100644
--- a/packaging/audio-hal-max98090.spec
+++ b/packaging/audio-hal-max98090.spec
@@ -1,6 +1,6 @@
Name: audio-hal-max98090
Summary: TIZEN Audio HAL for MAX98090
-Version: 0.2.15
+Version: 0.2.16
Release: 0
Group: System/Libraries
License: Apache-2.0
diff --git a/tizen-audio-comm.c b/tizen-audio-comm.c
new file mode 100644
index 0000000..d94aa22
--- /dev/null
+++ b/tizen-audio-comm.c
@@ -0,0 +1,91 @@
+/*
+ * audio-hal
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "tizen-audio-internal.h"
+
+audio_return_t _audio_comm_send_message(audio_hal_t *ah, const char *name, int value)
+{
+ audio_return_t audio_ret = AUDIO_RET_OK;
+
+ AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
+ AUDIO_RETURN_VAL_IF_FAIL(name, AUDIO_ERR_PARAMETER);
+
+ AUDIO_LOG_DEBUG("send message : name(%s), value(%d)", name, value);
+ if (ah->comm.msg_cb) {
+ ah->comm.msg_cb(name, value, ah->comm.user_data);
+ }
+
+ return audio_ret;
+}
+
+audio_return_t _audio_comm_set_message_callback(audio_hal_t *ah, message_cb callback, void *user_data)
+{
+ audio_return_t audio_ret = AUDIO_RET_OK;
+
+ AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
+ AUDIO_RETURN_VAL_IF_FAIL(callback, AUDIO_ERR_PARAMETER);
+
+ ah->comm.msg_cb = callback;
+ ah->comm.user_data = user_data;
+
+ AUDIO_LOG_DEBUG("message callback is set, callback(%p), user_data(%p)", ah->comm.msg_cb, ah->comm.user_data);
+
+ return audio_ret;
+}
+
+audio_return_t _audio_comm_unset_message_callback(audio_hal_t *ah)
+{
+ audio_return_t audio_ret = AUDIO_RET_OK;
+
+ AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
+
+ ah->comm.msg_cb = NULL;
+ ah->comm.user_data = NULL;
+
+ AUDIO_LOG_DEBUG("message callback is unset");
+
+ return audio_ret;
+}
+
+audio_return_t _audio_comm_init(audio_hal_t *ah)
+{
+ audio_return_t audio_ret = AUDIO_RET_OK;
+
+ AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
+
+ ah->comm.msg_cb = NULL;
+ ah->comm.user_data = NULL;
+
+ return audio_ret;
+}
+
+audio_return_t _audio_comm_deinit(audio_hal_t *ah)
+{
+ audio_return_t audio_ret = AUDIO_RET_OK;
+
+ AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
+
+ ah->comm.msg_cb = NULL;
+ ah->comm.user_data = NULL;
+
+ return audio_ret;
+}
diff --git a/tizen-audio-internal.h b/tizen-audio-internal.h
index 382d039..93cb5cd 100644
--- a/tizen-audio-internal.h
+++ b/tizen-audio-internal.h
@@ -271,12 +271,18 @@ typedef enum audio_sample_format {
AUDIO_SAMPLE_INVALID = -1
} audio_sample_format_t;
+typedef struct audio_hal_comm {
+ message_cb msg_cb;
+ void *user_data;
+} audio_hal_comm_t;
+
/* Overall */
typedef struct audio_hal {
audio_hal_device_t device;
audio_hal_volume_t volume;
audio_hal_ucm_t ucm;
audio_hal_mixer_t mixer;
+ audio_hal_comm_t comm;
} audio_hal_t;
typedef struct {
@@ -292,11 +298,15 @@ typedef struct samplerate_ctrl {
audio_return_t _audio_volume_init(audio_hal_t *ah);
audio_return_t _audio_volume_deinit(audio_hal_t *ah);
-
audio_return_t _audio_device_init(audio_hal_t *ah);
audio_return_t _audio_device_deinit(audio_hal_t *ah);
audio_return_t _audio_ucm_init(audio_hal_t *ah);
audio_return_t _audio_ucm_deinit(audio_hal_t *ah);
+audio_return_t _audio_util_init(audio_hal_t *ah);
+audio_return_t _audio_util_deinit(audio_hal_t *ah);
+audio_return_t _audio_comm_init(audio_hal_t *ah);
+audio_return_t _audio_comm_deinit(audio_hal_t *ah);
+
void _audio_ucm_get_device_name(audio_hal_t *ah, const char *use_case, audio_direction_t direction, const char **value);
#define _audio_ucm_update_use_case _audio_ucm_set_use_case
audio_return_t _audio_ucm_set_use_case(audio_hal_t *ah, const char *verb, const char *devices[], const char *modifiers[]);
@@ -305,13 +315,14 @@ audio_return_t _audio_ucm_set_modifiers(audio_hal_t *ah, const char *verb, const
int _audio_ucm_fill_device_info_list(audio_hal_t *ah, audio_device_info_t *device_info_list, const char *verb);
audio_return_t _audio_ucm_get_verb(audio_hal_t *ah, const char **value);
audio_return_t _audio_ucm_reset_use_case(audio_hal_t *ah);
-audio_return_t _audio_util_init(audio_hal_t *ah);
-audio_return_t _audio_util_deinit(audio_hal_t *ah);
audio_return_t _audio_mixer_control_set_param(audio_hal_t *ah, const char* ctl_name, snd_ctl_elem_value_t* value, int size);
audio_return_t _audio_mixer_control_set_value(audio_hal_t *ah, const char *ctl_name, int val);
audio_return_t _audio_mixer_control_set_value_string(audio_hal_t *ah, const char* ctl_name, const char* value);
audio_return_t _audio_mixer_control_get_value(audio_hal_t *ah, const char *ctl_name, int *val);
audio_return_t _audio_mixer_control_get_element(audio_hal_t *ah, const char *ctl_name, snd_hctl_elem_t **elem);
+audio_return_t _audio_comm_send_message(audio_hal_t *ah, const char *name, int value);
+audio_return_t _audio_comm_set_message_callback(audio_hal_t *ah, message_cb callback, void *user_data);
+audio_return_t _audio_comm_unset_message_callback(audio_hal_t *ah);
audio_return_t _audio_pcm_set_sw_params(snd_pcm_t *pcm, snd_pcm_uframes_t avail_min, uint8_t period_event);
audio_return_t _audio_pcm_set_hw_params(snd_pcm_t *pcm, audio_pcm_sample_spec_t *sample_spec, uint8_t *use_mmap, snd_pcm_uframes_t *period_size, snd_pcm_uframes_t *buffer_size);
uint32_t _convert_format(audio_sample_format_t format);
diff --git a/tizen-audio.c b/tizen-audio.c
index 882a9b4..d8f7a70 100644
--- a/tizen-audio.c
+++ b/tizen-audio.c
@@ -29,6 +29,18 @@ static const char* AUDIO_LATENCY_MID = "mid";
static const char* AUDIO_LATENCY_HIGH = "high";
static const char* AUDIO_LATENCY_VOIP = "voip";
+audio_return_t audio_set_message_cb(void *audio_handle, message_cb callback, void *user_data)
+{
+ audio_return_t ret = AUDIO_RET_OK;
+
+ AUDIO_RETURN_VAL_IF_FAIL(audio_handle, AUDIO_ERR_PARAMETER);
+ AUDIO_RETURN_VAL_IF_FAIL(callback, AUDIO_ERR_PARAMETER);
+
+ ret = _audio_comm_set_message_callback((audio_hal_t *)audio_handle, callback, user_data);
+
+ return ret;
+}
+
audio_return_t audio_init(void **audio_handle)
{
audio_hal_t *ah;
@@ -56,6 +68,10 @@ audio_return_t audio_init(void **audio_handle)
AUDIO_LOG_ERROR("mixer init failed");
goto error_exit;
}
+ if (AUDIO_IS_ERROR((ret = _audio_comm_init(ah)))) {
+ AUDIO_LOG_ERROR("comm init failed");
+ goto error_exit;
+ }
*audio_handle = (void *)ah;
return AUDIO_RET_OK;
@@ -77,6 +93,7 @@ audio_return_t audio_deinit(void *audio_handle)
_audio_volume_deinit(ah);
_audio_ucm_deinit(ah);
_audio_util_deinit(ah);
+ _audio_comm_deinit(ah);
free(ah);
ah = NULL;
diff --git a/tizen-audio.h b/tizen-audio.h
index dcc95da..794cdd7 100644
--- a/tizen-audio.h
+++ b/tizen-audio.h
@@ -71,6 +71,8 @@ typedef struct audio_stream_info {
uint32_t idx;
} audio_stream_info_t ;
+typedef void (*message_cb)(const char *name, int value, void *user_data);
+
/* Overall */
typedef struct audio_interface {
audio_return_t (*init)(void **audio_handle);
@@ -101,6 +103,8 @@ typedef struct audio_interface {
audio_return_t (*pcm_recover)(void *audio_handle, void *pcm_handle, int revents);
audio_return_t (*pcm_get_params)(void *audio_handle, void *pcm_handle, uint32_t direction, void **sample_spec, uint32_t *period_size, uint32_t *periods);
audio_return_t (*pcm_set_params)(void *audio_handle, void *pcm_handle, uint32_t direction, void *sample_spec, uint32_t period_size, uint32_t periods);
+ /* Message callback */
+ audio_return_t (*set_message_cb)(void *audio_handle, message_cb callback, void *user_data);
} audio_interface_t;
audio_return_t audio_init(void **audio_handle);
@@ -127,4 +131,5 @@ audio_return_t audio_pcm_get_fd(void *audio_handle, void *pcm_handle, int *fd);
audio_return_t audio_pcm_recover(void *audio_handle, void *pcm_handle, int revents);
audio_return_t audio_pcm_get_params(void *audio_handle, void *pcm_handle, uint32_t direction, void **sample_spec, uint32_t *period_size, uint32_t *periods);
audio_return_t audio_pcm_set_params(void *audio_handle, void *pcm_handle, uint32_t direction, void *sample_spec, uint32_t period_size, uint32_t periods);
+audio_return_t audio_set_message_cb(void *audio_handle, message_cb callback, void *user_data);
#endif