From 342e9cf388cceb807def720e40e8b0a217f4bcaa Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Tue, 19 Jan 2010 17:37:09 -0800 Subject: Fix issue 2285561: New AudioFlinger and audio driver API needed for A/V sync Added getRenderPosition() API to IAudioFlinger to retreive number of audio frames written by AudioFlinger to audio HAL and by DSP to DAC. Added getRenderPosition() API to AudioHardwareInterface to retreive number of audio frames written by DSP to DAC. Exposed AudioTrack::getPosition() to AudioSink() to make it available to media player. Removed excessive log in AudioHardwareGeneric. --- media/libmedia/IAudioFlinger.cpp | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'media/libmedia/IAudioFlinger.cpp') diff --git a/media/libmedia/IAudioFlinger.cpp b/media/libmedia/IAudioFlinger.cpp index fc42979..ca3a2a6 100644 --- a/media/libmedia/IAudioFlinger.cpp +++ b/media/libmedia/IAudioFlinger.cpp @@ -60,7 +60,8 @@ enum { OPEN_INPUT, CLOSE_INPUT, SET_STREAM_OUTPUT, - SET_VOICE_VOLUME + SET_VOICE_VOLUME, + GET_RENDER_POSITION }; class BpAudioFlinger : public BpInterface @@ -466,6 +467,26 @@ public: remote()->transact(SET_VOICE_VOLUME, data, &reply); return reply.readInt32(); } + + virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int output) + { + Parcel data, reply; + data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); + data.writeInt32(output); + remote()->transact(GET_RENDER_POSITION, data, &reply); + status_t status = reply.readInt32(); + if (status == NO_ERROR) { + uint32_t tmp = reply.readInt32(); + if (halFrames) { + *halFrames = tmp; + } + tmp = reply.readInt32(); + if (dspFrames) { + *dspFrames = tmp; + } + } + return status; + } }; IMPLEMENT_META_INTERFACE(AudioFlinger, "android.media.IAudioFlinger"); @@ -718,6 +739,19 @@ status_t BnAudioFlinger::onTransact( reply->writeInt32( setVoiceVolume(volume) ); return NO_ERROR; } break; + case GET_RENDER_POSITION: { + CHECK_INTERFACE(IAudioFlinger, data, reply); + int output = data.readInt32(); + uint32_t halFrames; + uint32_t dspFrames; + status_t status = getRenderPosition(&halFrames, &dspFrames, output); + reply->writeInt32(status); + if (status == NO_ERROR) { + reply->writeInt32(halFrames); + reply->writeInt32(dspFrames); + } + return NO_ERROR; + } default: return BBinder::onTransact(code, data, reply, flags); } -- cgit v1.1