summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisael Lopez Cruz2015-01-07 19:54:37 -0600
committerMisael Lopez Cruz2015-01-07 20:14:32 -0600
commit24e06f0b30e57555398ea11f9a97dbc90f10dcab (patch)
tree3a676a1ac92d6928619a42ff3fc0855c5ef8eed8 /audio/legacy
parenta90931216bc8887972bc8c1913051e0f70909b8b (diff)
downloaddevice-ti-jacinto6evm-24e06f0b30e57555398ea11f9a97dbc90f10dcab.tar.gz
device-ti-jacinto6evm-24e06f0b30e57555398ea11f9a97dbc90f10dcab.tar.xz
device-ti-jacinto6evm-24e06f0b30e57555398ea11f9a97dbc90f10dcab.zip
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>
Diffstat (limited to 'audio/legacy')
-rw-r--r--audio/legacy/audio_hw.c18
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,
524 return ret; 524 return ret;
525 } 525 }
526 526
527 stream->pcm_in = pcm_open(in_card, in_port, PCM_IN, &stream->in_config); 527 stream->pcm_in = pcm_open(in_card, in_port,
528 stream->pcm_out = pcm_open(out_card, out_port, PCM_OUT, &stream->out_config); 528 PCM_IN | PCM_MONOTONIC,
529 &stream->in_config);
530 stream->pcm_out = pcm_open(out_card, out_port,
531 PCM_OUT | PCM_MONOTONIC,
532 &stream->out_config);
529 533
530 if (!pcm_is_ready(stream->pcm_in) || !pcm_is_ready(stream->pcm_out)) { 534 if (!pcm_is_ready(stream->pcm_in) || !pcm_is_ready(stream->pcm_out)) {
531 ALOGE("voice_stream_init() failed to open pcm %s devices", stream->name); 535 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,
848 select_output_device(adev); 852 select_output_device(adev);
849 853
850 ALOGI("out_write() open card %u port %u", adev->card, adev->out_port); 854 ALOGI("out_write() open card %u port %u", adev->card, adev->out_port);
851 out->pcm = pcm_open(adev->card, adev->out_port, PCM_OUT, &out->config); 855 out->pcm = pcm_open(adev->card, adev->out_port,
856 PCM_OUT | PCM_MONOTONIC,
857 &out->config);
852 if (!pcm_is_ready(out->pcm)) { 858 if (!pcm_is_ready(out->pcm)) {
853 ALOGE("out_write() failed to open pcm out: %s", pcm_get_error(out->pcm)); 859 ALOGE("out_write() failed to open pcm out: %s", pcm_get_error(out->pcm));
854 pcm_close(out->pcm); 860 pcm_close(out->pcm);
@@ -932,7 +938,7 @@ static int out_get_presentation_position(const struct audio_stream_out *stream,
932 signed_frames = out->written - pcm_get_buffer_size(out->pcm) + avail; 938 signed_frames = out->written - pcm_get_buffer_size(out->pcm) + avail;
933 } 939 }
934 } else { 940 } else {
935 clock_gettime(CLOCK_REALTIME, timestamp); 941 clock_gettime(CLOCK_MONOTONIC, timestamp);
936 signed_frames = out->written + 942 signed_frames = out->written +
937 (time_diff(*timestamp, out->last) * out->config.rate) / 1000000; 943 (time_diff(*timestamp, out->last) * out->config.rate) / 1000000;
938 } 944 }
@@ -1202,7 +1208,9 @@ static ssize_t in_read(struct audio_stream_in *stream, void* buffer,
1202 select_input_device(adev); 1208 select_input_device(adev);
1203 1209
1204 ALOGI("in_read() open card %u port %u", adev->card, adev->in_port); 1210 ALOGI("in_read() open card %u port %u", adev->card, adev->in_port);
1205 in->pcm = pcm_open(adev->card, adev->in_port, PCM_IN, &in->config); 1211 in->pcm = pcm_open(adev->card, adev->in_port,
1212 PCM_IN | PCM_MONOTONIC,
1213 &in->config);
1206 if (!pcm_is_ready(in->pcm)) { 1214 if (!pcm_is_ready(in->pcm)) {
1207 ALOGE("in_read() failed to open pcm in: %s", pcm_get_error(in->pcm)); 1215 ALOGE("in_read() failed to open pcm in: %s", pcm_get_error(in->pcm));
1208 pcm_close(in->pcm); 1216 pcm_close(in->pcm);