Only increase the counter when we do take a wakelock

We keep track on how many wakelocks we have taken. We always
just take one real wakelock but increase / decrease the
counter every time we try to acquire / release a wakelock.
The counter is always increased even if the power manager is
not ready, leading to an incorrect counter that could cause a
crash when we try to release it.
Make sure we only increase the counter when a wakelock, real
or counted, is taken.

Change-Id: Iad940e052694932f1dad8a1a71fa63601d289d6a
update offloaded audio track sampling rate

AudioPlayer must read the sampling rate from offloaded audio sinks
whenever a new time position is computed as the decoder can update
the sampling rate on the fly.

Change-Id: I997e5248cfd4017aeceb4e11689324ded2a5bc88
AudioTrack: fix position callback after restore

When restoring an AudioTrack, the next position callback point
should not be modified and set ahead of current buffer head.
Otherwise, as frames are dropped, the new position is never reached
and an application relying on position callbacks to reload the buffer
would be stalled.

Bug: 11868603.
Change-Id: I93b2a311642a0c89944b78bcc0482d4ceed98ae4
fix deadlock issues that arise when there are simultaneous
effect control interface calls to proxy and to
non sub-effect wrappers(eg., bundlewrapper) from audioflinger
Also, return NO_ERROR when CMD_OFFLOAD succeeds

Whenever there are parallel calls to proxy and non sub-effects wrappers,
some of the calls are not completed. This is due to deadlock arsing out
of Proxy waiting for the subeffect call to return and subeffect waiting
for proxy to release lock.
The call flow is changed to a cleaner and simple one - Proxy gets the
aeli(effect library info) of subeffects during the EffectGetSubEffects()
call. Therby, proxy will manage the sub effects by itself rather than
going through effects factory.

Signed-off-by: jpadmana <jayashree.r.padmanaban@intel.com>
Bug: 12424044
Change-Id: I16852222f1d0e94e433a19177729323a4bb1c090
audioflinger: fix static track end detection

If a static track is not a fast track,
prepareTracks_l() must rely on framesReady() to
detect end of buffer and remove the track from the active
track list.
Failing to do so results in the track staying active but
not processed by the mixer because in underrun. This leaves the
mix buffer content uninitialized and causes the effect process
function to accumulate its output onto undefined data.

Bug: 12013676.
Change-Id: Iad72c921fa18d34811abf7d1073890c093a27725
AudioTrack: Never try to use the fast path if resampling is required

Unless AudioFlinger was built with FAST_TRACKS_AT_NON_NATIVE_SAMPLE_RATE
enabled, AudioFlinger would deny using the fast path (and internally
fall back to the normal codepath) when it realized that resampling
was required. Since the buffer size calculations within AudioFlinger
don't take resampling into account properly (see the calculation
below "AUDIO_OUTPUT_FLAG_FAST denied" in audioflinger/Threads.cpp,
just below the hunk that this patch changes), make sure AudioTrack
doesn't try to use the fast path if resampling is required.

This removes the possibility to enable
FAST_TRACKS_AT_NON_NATIVE_SAMPLE_RATE in AudioFlinger since it
AudioTrack now won't even try to use the fast path for content
that requires resampling, regardless of the AudioFlinger configuration.

Change-Id: Icf0f8ad50bf0fdb84657f518c0120aa0535f23f9
AudioFlinger: Remove code for supporting resampling in fast tracks

This isn't used at the moment.

Change-Id: I4e0fb2af5f7d959dbafd5ddb7defa1c6b8e8636a
Merge remote-tracking branch 'cm/cm-11.0' into cm-11.0
audioflinger: Set power hints for audio activity

 * Send a hint to the power manager when audio starts or stops.
 * This lets us behave in a smart way when streams are active-
   ie, don't mess with timer_rate while a2dp is active, which
   can cause skipping. Same deal for USB audio.

Change-Id: Ic1cf3f96afb44a8a5c4af4503cf7b30eed491910
Merge remote-tracking branch 'cm/cm-11.0' into cm-11.0
audioflinger: Power hints for audio activity

 * Take 2, now with 100% less crashes!

Change-Id: I48fb0d2e3cfc64f46d99f177b4cf3fe842d06df4
Merge remote-tracking branch 'cm/cm-11.0' into cm-11.0
Revert "camera: Add a few missing legacy camera params."

Either we keep legacy stuff, or remove ALL parts
of it, but not partly leaving dead code.

This reverts commit 12c66985ae4177feb73bbcc709ef80a18660ebec.

Change-Id: I0bbd47b0328114672f798864d04f2e9bdaa1f91e
Merge remote-tracking branch 'cm/cm-11.0' into cm-11.0
libstagefright: Fix ANR issue in HTTP Streaming

The root cause of the ANRs during this usecase is the
blocking nature of the read calls on the network data
source due to which application thread gets blocked on
some lock in framework.

Fixes ANR during seek/pause during HTTP streaming
* Non-blocking read implmentation for NuCachedSource2
* Other framework related changes to handle underruns

Change-Id: Ief280b7e23727606746e1ca2bf4caa4a3044b7bc
Add 2 APIs (suspend/resume) in MediaPlayer

- API:suspend() will just pause the player and release all the decoders
  to replace release() which will release the whole player
- API:resume() will just init the decoders again,
  then start() will be called to start to play the streaming
- Add a check in AwesomePlayer::onVideoEvent()
  to make sure the first seek operation will always seek the next i-frame

Change-Id: Ie4c82906a2a056378119921a656128ebdc1007c4
[libstagefright] : camcorder pause-resume implementation

- Added pause resume feature in camcorder app.so that
  user pause recording and resume later which results
  in a single recorded clip.
CRs-Fixed: 587051

Change-Id: Ib82a93009348d997a4b8343b8b417b433be4c9df
libstagefright: Fix crash during seek

OMXCodec state is changed to EXECUTING when flush
is complete. Update assert condition to check
EXECUTING state instead of FLUSHING.

CRs-Fixed: 607762
Change-Id: I12b3eedfc83e00578d70af3ef903c5a26ccde3eb
 libstagefright: Signal input EOS after last buffer is released

-In offload playback, sink stop is called at EOS from the sink call
 back when input EOS is reached. This is called before the last
 buffer is released.
-During seek to the end of clip ,drain can complete even before
 last buffer is released. This can cause playback to switch to
 next stream.
-Fix by ensuring sink stop is called only after the last buffer is
 released.

CRs-Fixed: 607104
Change-Id: I9cc45cc25b5f87dd878b26f76ea741323a0242a6
AwesomePlayer: Enable audio offload for widevine

- Set offload parameter for ADTS compressed data
- Remove offload audio check for drm content
  so that widevine goes through tunnel mode

Change-Id: I383fd315becc714f5bad08ef11ab1da4730b55fc