author | Tim Yao <tim.yao@amlogic.com> | 2016-05-16 05:49:06 (GMT) |
---|---|---|
committer | Gerrit Code Review <gituser@git.myamlogic.com> | 2016-05-16 05:49:06 (GMT) |
commit | d74aeff0d50cfbbbbab86d636b6851a4c088b198 (patch) | |
tree | 00c62de778622ccfbfd6223f01a33374df8ffd16 | |
parent | 578ee7432974c11a31292d82b57072570d0e1d12 (diff) | |
parent | 1996c0d7e9dfc30a029aa066971a7249e1c42c68 (diff) | |
download | audio-d74aeff0d50cfbbbbab86d636b6851a4c088b198.zip audio-d74aeff0d50cfbbbbab86d636b6851a4c088b198.tar.gz audio-d74aeff0d50cfbbbbab86d636b6851a4c088b198.tar.bz2 |
Merge "PD#124235: audio: hwsync fix audio pause can not resume issue." into m-amlogic
-rw-r--r-- | audio_hw.c | 7 | ||||
-rw-r--r-- | hdmi_audio_hw.c | 20 | ||||
-rw-r--r-- | hdmi_audio_hw.h | 1 |
3 files changed, 23 insertions, 5 deletions
@@ -861,9 +861,12 @@ out_flush(const struct audio_stream *stream) LOGFUNC("%s(%p)", __FUNCTION__, stream); struct aml_stream_out *out = (struct aml_stream_out *) stream; struct aml_audio_device *adev = out->dev; + pthread_mutex_lock(&adev->lock); pthread_mutex_lock(&out->lock); + do_output_standby(out); out->frame_write_sum = 0; - out->last_frames_postion = 0; + out->last_frames_postion = 0; + pthread_mutex_unlock(&adev->lock); pthread_mutex_unlock(&out->lock); return 0; } @@ -2362,12 +2365,10 @@ static int adev_open_output_stream(struct audio_hw_device *dev, out->frame_write_sum = 0; out->hw_sync_mode = false; out->first_apts_flag = false; - if (0/*flags & AUDIO_OUTPUT_FLAG_HW_AV_SYNC*/) { out->hw_sync_mode = true; ALOGI("Output stream open with AUDIO_OUTPUT_FLAG_HW_AV_SYNC"); } - /* FIXME: when we support multiple output devices, we will want to * do the following: * adev->devices &= ~AUDIO_DEVICE_OUT_ALL; diff --git a/hdmi_audio_hw.c b/hdmi_audio_hw.c index 3e5030f..5c2984d 100644 --- a/hdmi_audio_hw.c +++ b/hdmi_audio_hw.c @@ -464,10 +464,14 @@ out_flush(const struct audio_stream *stream) LOGFUNC("%s(%p)", __FUNCTION__, stream); struct aml_stream_out *out = (struct aml_stream_out *) stream; struct aml_audio_device *adev = out->dev; + pthread_mutex_lock(&adev->lock); pthread_mutex_lock(&out->lock); + do_output_standby(out); out->spdif_enc_init_frame_write_sum = 0; out->frame_write_sum = 0; out->frame_skip_sum = 0; + out->skip_frame = 3; + pthread_mutex_unlock(&adev->lock); pthread_mutex_unlock(&out->lock); return 0; } @@ -786,12 +790,24 @@ out_write(struct audio_stream_out *stream, const void *buffer, size_t bytes) hwsync_cost_bytes = aml_audio_hwsync_find_frame(out, buffer, bytes, &cur_pts, &outsize); DEBUG("after aml_audio_hwsync_find_frame bytes remain %d,cost %d,outsize %d,pts %llx\n", bytes - hwsync_cost_bytes, hwsync_cost_bytes, outsize, cur_pts); - if (cur_pts != 0xffffffff) { + //TODO,skip 3 frames after flush, to tmp fix seek pts discontinue issue.need dig more + // to find out why seek ppint pts frame is remained after flush.WTF. + if (out->skip_frame > 0) { + out->skip_frame--; + ALOGI("skip pts@%llx,cur frame size %d,cost size %d\n",cur_pts,outsize,hwsync_cost_bytes); + pthread_mutex_unlock(&adev->lock); + pthread_mutex_unlock(&out->lock); + return hwsync_cost_bytes; + } + if (cur_pts != 0xffffffff && outsize > 0) { +// if we got the frame body,which means we get a complete frame. +//we take this frame pts as the first apts. +//this can fix the seek discontinue,we got a fake frame,which maybe cached before the seek if (p_hwsync->first_apts_flag == false) { p_hwsync->first_apts_flag = true; p_hwsync->first_apts = cur_pts; sprintf(tempbuf, "AUDIO_START:0x%lx", cur_pts & 0xffffffff); - ALOGI("tsync -> %s", tempbuf); + ALOGI("tsync -> %s,frame size %d", tempbuf,outsize); if (sysfs_set_sysfs_str(TSYNC_EVENT, tempbuf) == -1) { ALOGE("set AUDIO_START failed \n"); } diff --git a/hdmi_audio_hw.h b/hdmi_audio_hw.h index 58e0167..8399b23 100644 --- a/hdmi_audio_hw.h +++ b/hdmi_audio_hw.h @@ -67,6 +67,7 @@ struct aml_stream_out { uint64_t last_frames_postion; uint64_t bytes_write_total; unsigned char pause_status; + int skip_frame; }; struct aml_stream_in { |