summaryrefslogtreecommitdiff
authorJian Xu <jian.xu@amlogic.com>2016-05-12 11:26:53 (GMT)
committer Jian Xu <jian.xu@amlogic.com>2016-05-12 15:26:08 (GMT)
commit1996c0d7e9dfc30a029aa066971a7249e1c42c68 (patch)
treed6437bf8001c9088e0a581562ba895793486b22a
parentb0f0295dfcecb530f00fd5e4b70b03a7f2d6b13b (diff)
downloadaudio-1996c0d7e9dfc30a029aa066971a7249e1c42c68.zip
audio-1996c0d7e9dfc30a029aa066971a7249e1c42c68.tar.gz
audio-1996c0d7e9dfc30a029aa066971a7249e1c42c68.tar.bz2
PD#124235: audio: hwsync fix audio pause can not resume issue.
Change-Id: Ib83b43ac03c4bb448c43eb8f4f07a9c4549b34d2
Diffstat
-rw-r--r--audio_hw.c7
-rw-r--r--hdmi_audio_hw.c20
-rw-r--r--hdmi_audio_hw.h1
3 files changed, 23 insertions, 5 deletions
diff --git a/audio_hw.c b/audio_hw.c
index 3412d29..85edce1 100644
--- a/audio_hw.c
+++ b/audio_hw.c
@@ -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 {