diff options
author | Misael Lopez Cruz <misael.lopez@ti.com> | 2015-01-07 19:54:37 -0600 |
---|---|---|
committer | Misael Lopez Cruz <misael.lopez@ti.com> | 2015-01-07 20:14:32 -0600 |
commit | 24e06f0b30e57555398ea11f9a97dbc90f10dcab (patch) | |
tree | 3a676a1ac92d6928619a42ff3fc0855c5ef8eed8 | |
parent | a90931216bc8887972bc8c1913051e0f70909b8b (diff) | |
download | jacinto6evm-24e06f0b30e57555398ea11f9a97dbc90f10dcab.tar.gz |
audio: Legacy: Use monotonic clock for presentation position
The timestamp returned by AudioHAL's get_presentation_position()
must be from the MONOTONIC clock. An additional flag has to be
passed when opening the pcm ports in tinyalsa in order to get
timestamps from the monotonic clock.
Change-Id: Ib06c686985ae9229df59a2756c5da35e858e2d0e
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
-rw-r--r-- | audio/legacy/audio_hw.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/audio/legacy/audio_hw.c b/audio/legacy/audio_hw.c index 12459e5..6912570 100644 --- a/audio/legacy/audio_hw.c +++ b/audio/legacy/audio_hw.c @@ -524,8 +524,12 @@ static int voice_stream_init(struct j6_voice_stream *stream, return ret; } - stream->pcm_in = pcm_open(in_card, in_port, PCM_IN, &stream->in_config); - stream->pcm_out = pcm_open(out_card, out_port, PCM_OUT, &stream->out_config); + stream->pcm_in = pcm_open(in_card, in_port, + PCM_IN | PCM_MONOTONIC, + &stream->in_config); + stream->pcm_out = pcm_open(out_card, out_port, + PCM_OUT | PCM_MONOTONIC, + &stream->out_config); if (!pcm_is_ready(stream->pcm_in) || !pcm_is_ready(stream->pcm_out)) { ALOGE("voice_stream_init() failed to open pcm %s devices", stream->name); @@ -848,7 +852,9 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer, select_output_device(adev); ALOGI("out_write() open card %u port %u", adev->card, adev->out_port); - out->pcm = pcm_open(adev->card, adev->out_port, PCM_OUT, &out->config); + out->pcm = pcm_open(adev->card, adev->out_port, + PCM_OUT | PCM_MONOTONIC, + &out->config); if (!pcm_is_ready(out->pcm)) { ALOGE("out_write() failed to open pcm out: %s", pcm_get_error(out->pcm)); pcm_close(out->pcm); @@ -932,7 +938,7 @@ static int out_get_presentation_position(const struct audio_stream_out *stream, signed_frames = out->written - pcm_get_buffer_size(out->pcm) + avail; } } else { - clock_gettime(CLOCK_REALTIME, timestamp); + clock_gettime(CLOCK_MONOTONIC, timestamp); signed_frames = out->written + (time_diff(*timestamp, out->last) * out->config.rate) / 1000000; } @@ -1202,7 +1208,9 @@ static ssize_t in_read(struct audio_stream_in *stream, void* buffer, select_input_device(adev); ALOGI("in_read() open card %u port %u", adev->card, adev->in_port); - in->pcm = pcm_open(adev->card, adev->in_port, PCM_IN, &in->config); + in->pcm = pcm_open(adev->card, adev->in_port, + PCM_IN | PCM_MONOTONIC, + &in->config); if (!pcm_is_ready(in->pcm)) { ALOGE("in_read() failed to open pcm in: %s", pcm_get_error(in->pcm)); pcm_close(in->pcm); |