summaryrefslogtreecommitdiff
authorTellen Yu <tellen.yu@amlogic.com>2016-12-30 05:29:54 (GMT)
committer Gerrit Code Review <gituser@scgit.amlogic.com>2016-12-30 05:29:54 (GMT)
commite15d4ca33fb1b7da080e46d4586032583356436a (patch)
treecd48c8459144421c4367496c2ca8de5052462c33
parent5e9c5c1f7ae35f3071b732b37355285ce735d77a (diff)
parent07e177d436045d535217477bd5ec3f676debe68d (diff)
downloadaudio-e15d4ca33fb1b7da080e46d4586032583356436a.zip
audio-e15d4ca33fb1b7da080e46d4586032583356436a.tar.gz
audio-e15d4ca33fb1b7da080e46d4586032583356436a.tar.bz2
Merge "PD#137519: audio: refine the get render position api for passthr" into n-amlogic
Diffstat
-rw-r--r--audio_hw.c24
-rw-r--r--audio_hw.h4
2 files changed, 27 insertions, 1 deletions
diff --git a/audio_hw.c b/audio_hw.c
index 8d95609..ea885aa 100644
--- a/audio_hw.c
+++ b/audio_hw.c
@@ -616,18 +616,22 @@ static int start_output_stream_direct(struct aml_stream_out *out)
out->config.period_size = PERIOD_SIZE * 2;
out->write_threshold = PLAYBACK_PERIOD_COUNT * PERIOD_SIZE * 2;
out->config.start_threshold = PLAYBACK_PERIOD_COUNT * PERIOD_SIZE * 2;
+ //as dd+ frame size = 1 and alsa sr as divide 16
+ //out->raw_61937_frame_size = 16;
break;
case AUDIO_FORMAT_DTS_HD:
case AUDIO_FORMAT_TRUEHD:
out->config.period_size = PERIOD_SIZE * 4 * 2;
out->write_threshold = PLAYBACK_PERIOD_COUNT * PERIOD_SIZE * 4 * 2;
out->config.start_threshold = PLAYBACK_PERIOD_COUNT * PERIOD_SIZE * 4 * 2;
+ //out->raw_61937_frame_size = 16;//192k 2ch
break;
case AUDIO_FORMAT_PCM:
default:
out->config.period_size = PERIOD_SIZE;
out->write_threshold = PLAYBACK_PERIOD_COUNT * PERIOD_SIZE;
out->config.start_threshold = PERIOD_SIZE * PLAYBACK_PERIOD_COUNT;
+ //out->raw_61937_frame_size = 4;
}
out->config.avail_min = 0;
set_codec_type(codec_type);
@@ -2433,8 +2437,18 @@ static int out_get_render_position(const struct audio_stream_out *stream,
uint32_t *dsp_frames)
{
struct aml_stream_out *out = (struct aml_stream_out *)stream;
-
+ uint64_t dsp_frame_int64 = 0;
*dsp_frames = out->last_frames_postion;
+ if (out->flags & AUDIO_OUTPUT_FLAG_IEC958_NONAUDIO) {
+ dsp_frame_int64 = out->last_frames_postion / out->raw_61937_frame_size;
+ *dsp_frames = (uint32_t)(dsp_frame_int64 & 0xffffffff);
+ if (out->last_dsp_frame > *dsp_frames) {
+ ALOGI("maybe uint32_t wraparound,print something,last %u,now %u", out->last_dsp_frame, *dsp_frames);
+ ALOGI("wraparound,out_get_render_position return %u,playback time %llu ms,sr %d\n", *dsp_frames,
+ out->last_frames_postion * 1000 / out->raw_61937_frame_size / out->config.rate, out->config.rate);
+
+ }
+ }
ALOGV("out_get_render_position %d\n", *dsp_frames);
return 0;
}
@@ -2466,6 +2480,9 @@ static int out_get_presentation_position(const struct audio_stream_out *stream,
if (timestamp != NULL) {
clock_gettime(CLOCK_MONOTONIC, timestamp);
}
+ if (out->flags & AUDIO_OUTPUT_FLAG_IEC958_NONAUDIO) {
+ *frames = out->last_frames_postion / out->raw_61937_frame_size;
+ }
ALOGV("out_get_presentation_position %lld\n", *frames);
return 0;
@@ -3224,12 +3241,17 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
}
out->config.rate = out->hal_rate = config->sample_rate;
out->hal_format = config->format;
+ out->raw_61937_frame_size = 1;
digital_codec = get_codec_type(config->format);
if (digital_codec == TYPE_EAC3) {
+ out->raw_61937_frame_size = 16;
out->config.period_size = pcm_config_out.period_size * 2;
} else if (digital_codec == TYPE_TRUE_HD || digital_codec == TYPE_DTS_HD) {
out->config.period_size = pcm_config_out.period_size * 4 * 2;
+ out->raw_61937_frame_size = 16;
}
+ else if (digital_codec == TYPE_AC3 || digital_codec == TYPE_DTS)
+ out->raw_61937_frame_size = 4;
if (channel_count > 2) {
ALOGI("[adev_open_output_stream]: out/%p channel/%d\n", out,
diff --git a/audio_hw.h b/audio_hw.h
index 23b77b3..83d3080 100644
--- a/audio_hw.h
+++ b/audio_hw.h
@@ -131,6 +131,10 @@ struct aml_stream_out {
float volume_l;
float volume_r;
int last_codec_type;
+ //as raw audio framesize is 1 computed by audio_stream_out_frame_size
+ //we need divide more when we got 61937 audio package
+ int raw_61937_frame_size;//61937 frame size
+ unsigned last_dsp_frame;//recorded for wraparound print info
};
#define MAX_PREPROCESSORS 3 /* maximum one AGC + one NS + one AEC per input stream */