diff options
author | qctecmdr <qctecmdr@localhost> | 2022-06-20 22:30:41 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2022-06-20 22:30:41 -0700 |
commit | bfa4b49e21a811e057916e5444848957e26d1c06 (patch) | |
tree | d8617bec037d6ce1f5161c79d2389880299d89e2 | |
parent | 893e466c5b96668a13b1e1e2451fd772bcaa31e9 (diff) | |
parent | 3c88dca4cb9df8e8244f6238521d9abdaadcfb56 (diff) |
Merge "ahal: query DSP postion for pcm offload"
-rw-r--r-- | hal/AudioStream.cpp | 7 | ||||
-rw-r--r-- | hal/AudioStream.h | 1 |
2 files changed, 6 insertions, 2 deletions
diff --git a/hal/AudioStream.cpp b/hal/AudioStream.cpp index c10b5bf5..11495923 100644 --- a/hal/AudioStream.cpp +++ b/hal/AudioStream.cpp @@ -706,6 +706,7 @@ static int astream_out_get_presentation_position( if (astream_out) { switch (astream_out->GetPalStreamType(astream_out->flags_)) { case PAL_STREAM_COMPRESSED: + case PAL_STREAM_PCM_OFFLOAD: ret = astream_out->GetFrames(frames); if (ret != 0) { AHAL_ERR("GetTimestamp failed %d", ret); @@ -744,6 +745,7 @@ static int out_get_render_position(const struct audio_stream_out *stream, if (astream_out) { switch (astream_out->GetPalStreamType(astream_out->flags_)) { case PAL_STREAM_COMPRESSED: + case PAL_STREAM_PCM_OFFLOAD: ret = astream_out->GetFrames(&frames); if (ret != 0) { AHAL_ERR("Get DSP Frames failed %d", ret); @@ -751,7 +753,6 @@ static int out_get_render_position(const struct audio_stream_out *stream, } *dsp_frames = (uint32_t) frames; break; - case PAL_STREAM_PCM_OFFLOAD: case PAL_STREAM_LOW_LATENCY: case PAL_STREAM_DEEP_BUFFER: ret = astream_out->GetFramesWritten(NULL); @@ -1937,6 +1938,8 @@ int StreamOutPrimary::Standby() { AHAL_DBG("Enter"); stream_mutex_.lock(); if (pal_stream_handle_) { + if (streamAttributes_.type == PAL_STREAM_PCM_OFFLOAD) + GetFrames(&mCachedPosition); ret = pal_stream_stop(pal_stream_handle_); if (ret) { AHAL_ERR("failed to stop stream."); @@ -2832,7 +2835,7 @@ int StreamOutPrimary::GetFrames(uint64_t *frames) dsp_frames = (dsp_frames > offset) ? (dsp_frames - offset) : 0; } } - *frames = dsp_frames; + *frames = dsp_frames + mCachedPosition; exit: return ret; } diff --git a/hal/AudioStream.h b/hal/AudioStream.h index 07e179f9..d3e8b103 100644 --- a/hal/AudioStream.h +++ b/hal/AudioStream.h @@ -536,6 +536,7 @@ protected: uint16_t mchannels; std::shared_ptr<audio_stream_out> stream_; uint64_t mBytesWritten; /* total bytes written, not cleared when entering standby */ + uint64_t mCachedPosition = 0; /* cache pcm offload position when entering standby */ offload_effects_start_output fnp_offload_effect_start_output_ = nullptr; offload_effects_stop_output fnp_offload_effect_stop_output_ = nullptr; visualizer_hal_start_output fnp_visualizer_start_output_ = nullptr; |