summaryrefslogtreecommitdiffstats
path: root/hal
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2013-09-20 09:20:13 -0700
committerEric Laurent <elaurent@google.com>2013-09-20 09:20:13 -0700
commit949a089132db31b652d937a949f7bd425f2e42f9 (patch)
treea47ccd78a6086772227d5a64bd6bb3cebfa75610 /hal
parent957b4382a1fdd8b7bf3cb32db32041887863fa37 (diff)
downloadandroid_hardware_qcom_audio-949a089132db31b652d937a949f7bd425f2e42f9.tar.gz
android_hardware_qcom_audio-949a089132db31b652d937a949f7bd425f2e42f9.tar.bz2
android_hardware_qcom_audio-949a089132db31b652d937a949f7bd425f2e42f9.zip
implement get_presentation_position() for offloaded outputs
Bug: 9587132. Change-Id: Idf40259b59552c29671830f30ccca3bef6ef0edd
Diffstat (limited to 'hal')
-rw-r--r--hal/audio_hw.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index c2997c66..76533c66 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1422,19 +1422,33 @@ static int out_get_presentation_position(const struct audio_stream_out *stream,
{
struct stream_out *out = (struct stream_out *)stream;
int ret = -1;
+ unsigned long dsp_frames;
pthread_mutex_lock(&out->lock);
- if (out->pcm) {
- size_t avail;
- if (pcm_get_htimestamp(out->pcm, &avail, timestamp) == 0) {
- size_t kernel_buffer_size = out->config.period_size * out->config.period_count;
- // FIXME This calculation is incorrect if there is buffering after app processor
- int64_t signed_frames = out->written - kernel_buffer_size + avail;
- // It would be unusual for this value to be negative, but check just in case ...
- if (signed_frames >= 0) {
- *frames = signed_frames;
- ret = 0;
+ if (out->usecase == USECASE_AUDIO_PLAYBACK_OFFLOAD) {
+ if (out->compr != NULL) {
+ compress_get_tstamp(out->compr, &dsp_frames,
+ &out->sample_rate);
+ ALOGVV("%s rendered frames %ld sample_rate %d",
+ __func__, dsp_frames, out->sample_rate);
+ *frames = dsp_frames;
+ ret = 0;
+ /* this is the best we can do */
+ clock_gettime(CLOCK_MONOTONIC, timestamp);
+ }
+ } else {
+ if (out->pcm) {
+ size_t avail;
+ if (pcm_get_htimestamp(out->pcm, &avail, timestamp) == 0) {
+ size_t kernel_buffer_size = out->config.period_size * out->config.period_count;
+ // FIXME This calculation is incorrect if there is buffering after app processor
+ int64_t signed_frames = out->written - kernel_buffer_size + avail;
+ // It would be unusual for this value to be negative, but check just in case ...
+ if (signed_frames >= 0) {
+ *frames = signed_frames;
+ ret = 0;
+ }
}
}
}