summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKimJeongYeon <jeongyeon.kim@samsung.com>2015-07-31 10:09:10 +0900
committerKimJeongYeon <jeongyeon.kim@samsung.com>2015-07-31 14:58:15 +0900
commit8333b75b5d6f060dcea03c69aa7cf0438b084f23 (patch)
tree389125f00ddbc960dc1aa7eb64d317cd29608dd8
parent69ed2e4e7db7a9a111288ab211fe8384912b87ee (diff)
downloadaudio-hal-max98090-8333b75b5d6f060dcea03c69aa7cf0438b084f23.tar.gz
audio-hal-max98090-8333b75b5d6f060dcea03c69aa7cf0438b084f23.tar.bz2
audio-hal-max98090-8333b75b5d6f060dcea03c69aa7cf0438b084f23.zip
[Version] 0.2.8 [Profile] TV [Issue Type] Features [Dependency module] NA [Dependency commit] NA [Comment] Signed-off-by: KimJeongYeon <jeongyeon.kim@samsung.com> Change-Id: I50f0b7de5b2609f3b07ffd2cd23e6fe992c735be
-rw-r--r--packaging/audio-hal-max98090.spec2
-rw-r--r--tizen-audio.c196
-rw-r--r--tizen-audio.h19
3 files changed, 101 insertions, 116 deletions
diff --git a/packaging/audio-hal-max98090.spec b/packaging/audio-hal-max98090.spec
index 77bbfdc..01e77dd 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.7
+Version: 0.2.8
Release: 0
Group: System/Libraries
License: Apache-2.0
diff --git a/tizen-audio.c b/tizen-audio.c
index 0f697d4..af3cb39 100644
--- a/tizen-audio.c
+++ b/tizen-audio.c
@@ -179,7 +179,8 @@ uint32_t _audio_sample_size(audio_sample_format_t format)
return g_size_table[format];
}
audio_return_t audio_get_buffer_attr(void *userdata,
- audio_latency_t latency,
+ uint32_t direction,
+ const char *latency,
uint32_t samplerate,
audio_sample_format_t format,
uint32_t channels,
@@ -190,13 +191,14 @@ audio_return_t audio_get_buffer_attr(void *userdata,
uint32_t *fragsize)
{
assert(userdata);
+ assert(latency);
assert(maxlength);
assert(tlength);
assert(prebuf);
assert(minreq);
assert(fragsize);
- AUDIO_LOG_DEBUG("hal-latency - audio_get_buffer_attr(latency:%d, samplerate:%d, format:%d, channels:%d)", latency, samplerate, format, channels);
+ AUDIO_LOG_DEBUG("hal-latency - audio_get_buffer_attr(direction:%d, latency:%s, samplerate:%d, format:%d, channels:%d)", direction, latency, samplerate, format, channels);
audio_mgr_t *am = (audio_mgr_t *)userdata;
@@ -208,106 +210,96 @@ audio_return_t audio_get_buffer_attr(void *userdata,
return AUDIO_ERR_PARAMETER;
}
- switch (latency) {
- case AUDIO_IN_LATENCY_LOW:
- AUDIO_LOG_DEBUG("AUDIO_IN_LATENCY_LOW");
- period_time = PERIOD_TIME_FOR_LOW_LATENCY_MSEC;
- sample_per_period = (samplerate * period_time) / 1000;
- periods_per_buffer = PERIODS_PER_BUFFER_FASTMODE;
- *prebuf = 0;
- *minreq = -1;
- *tlength = -1;
- *maxlength = -1;
- *fragsize = sample_per_period * _audio_sample_size(format);
- break;
-
- case AUDIO_IN_LATENCY_MID:
- AUDIO_LOG_DEBUG("AUDIO_IN_LATENCY_MID");
- period_time = PERIOD_TIME_FOR_MID_LATENCY_MSEC;
- sample_per_period = (samplerate * period_time) / 1000;
- periods_per_buffer = PERIODS_PER_BUFFER_DEFAULT;
- *prebuf = 0;
- *minreq = -1;
- *tlength = -1;
- *maxlength = -1;
- *fragsize = _audio_usec_to_bytes(100000, samplerate, format, channels);
- break;
-
- case AUDIO_IN_LATENCY_HIGH:
- AUDIO_LOG_DEBUG("AUDIO_IN_LATENCY_HIGH");
- period_time = PERIOD_TIME_FOR_HIGH_LATENCY_MSEC;
- sample_per_period = (samplerate * period_time) / 1000;
- periods_per_buffer = PERIODS_PER_BUFFER_CAPTURE;
- *prebuf = 0;
- *minreq = -1;
- *tlength = -1;
- *maxlength = -1;
- *fragsize = sample_per_period * _audio_sample_size(format);
- break;
-
- case AUDIO_IN_LATENCY_VOIP:
- AUDIO_LOG_DEBUG("AUDIO_IN_LATENCY_VOIP");
- period_time = PERIOD_TIME_FOR_VOIP_LATENCY_MSEC;
- sample_per_period = (samplerate * period_time) / 1000;
- periods_per_buffer = PERIODS_PER_BUFFER_VOIP;
- *prebuf = 0;
- *minreq = -1;
- *tlength = -1;
- *maxlength = -1;
- *fragsize = sample_per_period * _audio_sample_size(format);
- break;
-
- case AUDIO_OUT_LATENCY_LOW:
- AUDIO_LOG_DEBUG("AUDIO_OUT_LATENCY_LOW");
- period_time = PERIOD_TIME_FOR_LOW_LATENCY_MSEC;
- sample_per_period = (samplerate * period_time) / 1000;
- periods_per_buffer = PERIODS_PER_BUFFER_FASTMODE;
- *prebuf = (samplerate / 100) * _audio_sample_size(format) * channels;
- *minreq = -1;
- *tlength = (samplerate / 10) * _audio_sample_size(format) * channels;
- *maxlength = -1;
- *fragsize = 0;
- break;
-
- case AUDIO_OUT_LATENCY_MID:
- AUDIO_LOG_DEBUG("AUDIO_OUT_LATENCY_MID");
- period_time = PERIOD_TIME_FOR_MID_LATENCY_MSEC;
- sample_per_period = (samplerate * period_time) / 1000;
- periods_per_buffer = PERIODS_PER_BUFFER_DEFAULT;
- *prebuf = -1;
- *minreq = -1;
- *tlength = (uint32_t) _audio_usec_to_bytes(350000, samplerate, format, channels);
- *maxlength = -1;
- *fragsize = -1;
- break;
-
- case AUDIO_OUT_LATENCY_HIGH:
- AUDIO_LOG_DEBUG("AUDIO_OUT_LATENCY_HIGH");
- period_time = PERIOD_TIME_FOR_HIGH_LATENCY_MSEC;
- sample_per_period = (samplerate * period_time) / 1000;
- periods_per_buffer = PERIODS_PER_BUFFER_PLAYBACK;
- *prebuf = 0;
- *minreq = -1;
- *tlength = (uint32_t) _audio_usec_to_bytes(500000, samplerate, format, channels);
- *maxlength = -1;
- *fragsize = -1;
- break;
-
- case AUDIO_OUT_LATENCY_VOIP:
- AUDIO_LOG_DEBUG("AUDIO_OUT_LATENCY_VOIP");
- period_time = PERIOD_TIME_FOR_VOIP_LATENCY_MSEC;
- sample_per_period = (samplerate * period_time) / 1000;
- periods_per_buffer = PERIODS_PER_BUFFER_VOIP;
- *prebuf = -1;
- *minreq = _audio_usec_to_bytes(20000, samplerate, format, channels);
- *tlength = _audio_usec_to_bytes(100000, samplerate, format, channels);
- *maxlength = -1;
- *fragsize = 0;
- break;
-
- default:
- AUDIO_LOG_ERROR("hal-latency - The latency(%d) is undefined", latency);
- return AUDIO_ERR_UNDEFINED;
+ if (direction == AUDIO_DIRECTION_IN) {
+ if (!strcmp(latency, AUDIO_LATENCY_LOW)) {
+ AUDIO_LOG_DEBUG("AUDIO_DIRECTION_IN, AUDIO_LATENCY_LOW");
+ period_time = PERIOD_TIME_FOR_LOW_LATENCY_MSEC;
+ sample_per_period = (samplerate * period_time) / 1000;
+ periods_per_buffer = PERIODS_PER_BUFFER_FASTMODE;
+ *prebuf = 0;
+ *minreq = -1;
+ *tlength = -1;
+ *maxlength = -1;
+ *fragsize = sample_per_period * _audio_sample_size(format);
+ } else if (!strcmp(latency, AUDIO_LATENCY_MID)) {
+ AUDIO_LOG_DEBUG("AUDIO_DIRECTION_IN, AUDIO_LATENCY_MID");
+ period_time = PERIOD_TIME_FOR_MID_LATENCY_MSEC;
+ sample_per_period = (samplerate * period_time) / 1000;
+ periods_per_buffer = PERIODS_PER_BUFFER_DEFAULT;
+ *prebuf = 0;
+ *minreq = -1;
+ *tlength = -1;
+ *maxlength = -1;
+ *fragsize = sample_per_period * _audio_sample_size(format);
+ } else if (!strcmp(latency, AUDIO_LATENCY_HIGH)) {
+ AUDIO_LOG_DEBUG("AUDIO_DIRECTION_IN, AUDIO_LATENCY_HIGH");
+ period_time = PERIOD_TIME_FOR_HIGH_LATENCY_MSEC;
+ sample_per_period = (samplerate * period_time) / 1000;
+ periods_per_buffer = PERIODS_PER_BUFFER_CAPTURE;
+ *prebuf = 0;
+ *minreq = -1;
+ *tlength = -1;
+ *maxlength = -1;
+ *fragsize = sample_per_period * _audio_sample_size(format);
+ } else if (!strcmp(latency, AUDIO_LATENCY_VOIP)) {
+ AUDIO_LOG_DEBUG("AUDIO_DIRECTION_IN, AUDIO_LATENCY_VOIP");
+ period_time = PERIOD_TIME_FOR_VOIP_LATENCY_MSEC;
+ sample_per_period = (samplerate * period_time) / 1000;
+ periods_per_buffer = PERIODS_PER_BUFFER_VOIP;
+ *prebuf = 0;
+ *minreq = -1;
+ *tlength = -1;
+ *maxlength = -1;
+ *fragsize = sample_per_period * _audio_sample_size(format);
+ } else {
+ AUDIO_LOG_ERROR("hal-latency - The latency(%s) is undefined", latency);
+ return AUDIO_ERR_UNDEFINED;
+ }
+ } else { /* AUDIO_DIRECTION_OUT */
+ if (!strcmp(latency, AUDIO_LATENCY_LOW)) {
+ AUDIO_LOG_DEBUG("AUDIO_DIRECTION_OUT, AUDIO_LATENCY_LOW");
+ period_time = PERIOD_TIME_FOR_LOW_LATENCY_MSEC;
+ sample_per_period = (samplerate * period_time) / 1000;
+ periods_per_buffer = PERIODS_PER_BUFFER_FASTMODE;
+ *prebuf = (samplerate / 100) * _audio_sample_size(format) * channels; /* 10ms */
+ *minreq = -1;
+ *tlength = (samplerate / 10) * _audio_sample_size(format) * channels; /* 100ms */
+ *maxlength = -1;
+ *fragsize = 0;
+ } else if (!strcmp(latency, AUDIO_LATENCY_MID)) {
+ AUDIO_LOG_DEBUG("AUDIO_DIRECTION_OUT, AUDIO_LATENCY_MID");
+ period_time = PERIOD_TIME_FOR_MID_LATENCY_MSEC;
+ sample_per_period = (samplerate * period_time) / 1000;
+ periods_per_buffer = PERIODS_PER_BUFFER_DEFAULT;
+ *prebuf = -1;
+ *minreq = -1;
+ *tlength = (uint32_t) _audio_usec_to_bytes(200000, samplerate, format, channels);
+ *maxlength = -1;
+ *fragsize = -1;
+ } else if (!strcmp(latency, AUDIO_LATENCY_HIGH)) {
+ AUDIO_LOG_DEBUG("AUDIO_DIRECTION_OUT, AUDIO_LATENCY_HIGH");
+ period_time = PERIOD_TIME_FOR_HIGH_LATENCY_MSEC;
+ sample_per_period = (samplerate * period_time) / 1000;
+ periods_per_buffer = PERIODS_PER_BUFFER_PLAYBACK;
+ *prebuf = 0;
+ *minreq = -1;
+ *tlength = (uint32_t) _audio_usec_to_bytes(400000, samplerate, format, channels);
+ *maxlength = -1;
+ *fragsize = -1;
+ } else if (!strcmp(latency, AUDIO_LATENCY_VOIP)) {
+ AUDIO_LOG_DEBUG("AUDIO_DIRECTION_OUT, AUDIO_LATENCY_VOIP");
+ period_time = PERIOD_TIME_FOR_VOIP_LATENCY_MSEC;
+ sample_per_period = (samplerate * period_time) / 1000;
+ periods_per_buffer = PERIODS_PER_BUFFER_VOIP;
+ *prebuf = -1;
+ *minreq = _audio_usec_to_bytes(20000, samplerate, format, channels);
+ *tlength = _audio_usec_to_bytes(100000, samplerate, format, channels);
+ *maxlength = -1;
+ *fragsize = 0;
+ } else {
+ AUDIO_LOG_ERROR("hal-latency - The latency(%s) is undefined", latency);
+ return AUDIO_ERR_UNDEFINED;
+ }
}
AUDIO_LOG_INFO("hal-latency - return attr --> prebuf:%d, minreq:%d, tlength:%d, maxlength:%d, fragsize:%d", *prebuf, *minreq, *tlength, *maxlength, *fragsize);
diff --git a/tizen-audio.h b/tizen-audio.h
index 61f8edc..d838c82 100644
--- a/tizen-audio.h
+++ b/tizen-audio.h
@@ -98,17 +98,10 @@ typedef enum audio_sample_format {
} audio_sample_format_t;
/* audio latency */
-typedef enum audio_latency {
- AUDIO_IN_LATENCY_LOW,
- AUDIO_IN_LATENCY_MID,
- AUDIO_IN_LATENCY_HIGH,
- AUDIO_IN_LATENCY_VOIP,
- AUDIO_OUT_LATENCY_LOW,
- AUDIO_OUT_LATENCY_MID,
- AUDIO_OUT_LATENCY_HIGH,
- AUDIO_OUT_LATENCY_VOIP,
- AUDIO_LATENCY_MAX
-} audio_latency_t;
+static const char* AUDIO_LATENCY_LOW = "low";
+static const char* AUDIO_LATENCY_MID = "mid";
+static const char* AUDIO_LATENCY_HIGH = "high";
+static const char* AUDIO_LATENCY_VOIP = "voip";
typedef struct audio_device_param_info {
audio_device_param_t param;
@@ -231,7 +224,7 @@ typedef struct audio_interface {
audio_return_t (*pcm_close)(void *userdata, void *pcm_handle);
audio_return_t (*pcm_avail)(void *pcm_handle);
audio_return_t (*pcm_write)(void *pcm_handle, const void *buffer, uint32_t frames);
- audio_return_t (*get_buffer_attr)(void *userdata, audio_latency_t latency, uint32_t samplerate, audio_sample_format_t format, uint32_t channels, uint32_t *maxlength, uint32_t *tlength, uint32_t *prebuf, uint32_t* minreq, uint32_t *fragsize);
+ audio_return_t (*get_buffer_attr)(void *userdata, uint32_t direction, const char *latency, uint32_t samplerate, audio_sample_format_t format, uint32_t channels, uint32_t *maxlength, uint32_t *tlength, uint32_t *prebuf, uint32_t* minreq, uint32_t *fragsize);
audio_return_t (*set_callback)(void *userdata, audio_cb_interface_t *cb_interface);
} audio_interface_t;
@@ -254,6 +247,6 @@ audio_return_t audio_pcm_open(void *userdata, void **pcm_handle, void *sample_sp
audio_return_t audio_pcm_close (void *userdata, void *pcm_handle);
audio_return_t audio_pcm_avail(void *pcm_handle);
audio_return_t audio_pcm_write(void *pcm_handle, const void *buffer, uint32_t frames);
-audio_return_t audio_get_buffer_attr(void *userdata, audio_latency_t latency, uint32_t samplerate, audio_sample_format_t format, uint32_t channels, uint32_t *maxlength, uint32_t *tlength, uint32_t *prebuf, uint32_t* minreq, uint32_t *fragsize);
+audio_return_t audio_get_buffer_attr(void *userdata, uint32_t direction, const char *latency, uint32_t samplerate, audio_sample_format_t format, uint32_t channels, uint32_t *maxlength, uint32_t *tlength, uint32_t *prebuf, uint32_t* minreq, uint32_t *fragsize);
audio_return_t audio_set_callback (void *userdata, audio_cb_interface_t *cb_interface);
#endif