libstagefright: Post video events dynamically.

- calculate amount of time to delay video event after render ,using the
formula : delay = (us between frames)-(us taken by event)-(lateness)
- Reverting the previous change and posting the event dynamically will
lead to power improvement.

Change-Id: I585409f245cd4d548e35e05b0e9542e5eb33cc43
CRs-Fixed: 586127
audioflinger: Add Null pointer check while enabling effects for LPA

- MediaServer is crashing when disabling effects after mediaplayer
object is released.
- EffectChain pointer is de-referenced without NULL check, hence
leading to a mediaserver crash.
- Adding a NULL pointer check before using EffectChain object.

Change-Id: If5ff469445246028046ba65e5ddf3300180318c2
CRs-Fixed: 583305
audio: Check the return code of MediaWriter::start

- Return code of MediaWriter::start method is not checked
  in startRawAudioRecording. Due to this, sound recorder
  application is not receiving the error whenever there is
  an error in starting of the recording
- Fix is to check the error and return it back to
  the client accordingly

Change-Id: I15916211da7a2eb0f27fbf9d4151410a8bdfdd42
CRs-Fixed: 591788
Audio: Tunnel Exception for ER AAC ELD profile format

- some m4a clips are not working properly

- ADSP audio decoders don't support ER AAC ELD support

- Added tunnel exception for ER AAC ELD format.
  Added AACProfile metadata support for MKVExtractor

Change-Id: I2f6fe721b05377dfe0f24ea0ad1f6c4a885d576d
audioflinger: OffloadThread state fix

When switching from one offload session to another that
reuses the same offload output, audio HAL is paused & flushed in
preparation for the new track.

OffloadThread must reset mHwPaused to allow proper state transitions
for the second track.

CRs-Fixed: 578165
Change-Id: I8173845e1782b5a8b372a82c7d337299a61e0efe
libstagefright: customize delay to post video events

Calculate delay as a function of lateness rather
than fixed 10ms.
When video frames are decoded quite early, this
change will delay the wake up of video events.

We save some unwanted wake up of video events
which save power.

Change-Id: I12839b9df62d453f394894b499491e2cac3a0c8a
CRs-Fixed: 578988
libstagefright: set threshold for earliness

Change the threshold value for earliness to 40ms
This fixes the av sync loss issues.

Change-Id: Ib912048987e8e6187dc37d5dbaff5d1ead224c61
CRs-Fixed: 584417