WA: Queue extra buffers on output port during reconfig if input EOS-ed

Some codecs may return input buffers before having them processed.
This causes a halt if we already signaled an EOS on the input
port.  For now keep submitting output meta buffers one at a time if
the input EOS-ed, but the output not yet.

Normally, we submit an output buffer for each input buffer that is
with the component (waiting to be processed).

Change-Id: I8a1251bfb504f40f1e4085a1e220bf9a4d0b05d9
Signed-off-by: Lajos Molnar <lajos@google.com>
Bug: 11433909
Merge "WA: Queue extra buffers on output port during reconfig if input EOS-ed" into klp-dev
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
audio: Add support for tunnel mode recording and compress voip

- Use modulo operator for common block buffer handling. Common block
  size is rounded to power of two. This limitation is avoided with
  modulo operator.
- Add support for tunnel mode recording
- Add support for compress voip

Change-Id: I95cdfff729affd784141487521c9f2f714221d11

audio: check audio mode to enable voice path for VoIP apps

- Add check for MODE_IN_COMMUNICATION to enable voice path
for VoIP applications

Change-Id: Ib603c6321c935d3b1313c2841b09eea932aa13f3

audio: Restrict opening of voip direct output to one instance

Avoid opening of voip direct output track if it is already in use
by another voip application.

Change-Id: I740bbb9e7153c8871c296f1ec5d8d68997391779

audio: check voip input sample rate to allow voip direct output

It is possible that some voip applications request different sample
rates for input and output streams. Avoid opening of voip direct
output if the voip input is already opened with a different sample
rate.

Change-Id: I5669e2a0880ffed0c10cde21da8994c2b47e1878
CRs-fixed: 601785
AudioFlinger: Remove unwanted update of track generation

PlaybackThread::threadLoop unncessarily updates the track generation
before waiting for a pending aync write. This is unncessary and
leads to excess calls to the power manager service for updating
uids.

Change-Id: I1284d79da3be6495acb19a97c81b3ab8db6dbb12
(cherry picked from commit f10fdf3ac4aced7d64bd0d1f05cc886271436685)
(cherry picked from commit 48568df4edf4d9b98c4d05bcfae3770c91f3be7f)
AudioTrack: Fix for race condition

This fixes a race condition between releaseBuffer and flush.

An AudioTrack::releaseBuffer() can be delayed (pre-empted) by
AudioTrack::pause/flush() and ServerProxy::obtainBuffer() calls leading
to a situation where an incorrect position is copied to the cblk

<<Change to be tested>>

Change-Id: I70074d4824ba8c7fa86c9f9ef8cc182de9172ab9
(cherry picked from commit ec237ff01ca194bf0e29933f916a30b8f83c8ace)
(cherry picked from commit 6984cd7b9e99ffa48872cf9316c68d5ae51ad3c5)
audioflinger: Fix for a deadlock in track creation

AudioFlinger enters a deadlock (with itself) on trying to free a
RecordTrack or Track object that failed initialization. Clear this
bad object from the caller instead.

Bug: 12423233
Change-Id: I926f2beb922a70f6924e593e2bbf1a5b5df85b16
audioflinger: update track ready condition

Signal track ready if the track isStopping().

Bug: 12423190
Change-Id: I95e14905df10ebf301e398263478c8ca25d7e2ce
audioflinger: check for condition before waiting

AsyncCallbackThread must check for any condition that
was already been satisfied before waiting.

Bug: 11824817
Change-Id: I04683a1f355de4f440106cab47fd916aa39d5e35
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.

Change-Id: If4b259da5776f151c1e81a78a0239d342046d923
Signed-off-by: jpadmana <jayashree.r.padmanaban@intel.com>
Bug: 12424044
audioflinger: fix offload write buffer offset

Fix current audio HAL write buffer offset calculation
which assumes that the frame size is a multiple of 2.
'
Bug: 12823725.

Change-Id: I0195ed5cfef225a6f114e7dd405a02680bb7254e
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.

Bug: 12823955.

Change-Id: I997e5248cfd4017aeceb4e11689324ded2a5bc88
AudioMixer: Remove tracks from enabledTracks after reseting outTemp

If any track goes through AudioMixer::process__genericNoResampling, and
its getnextbuffer returns NULL, Then that track is removed by AudioMixer
from enabledTracks.

Thus if all tracks getnextbuffer return NULL, Then this function doesn't
reset outTemp and last buffer in AudioFlinger's mMixBuffer will be
repeated and noise is observed.

Remove tracks from enabledTracks after reseting outTemp to zero, so that
process__genericNoResampling will reset outTemp and noise won't appear.

Bug: 12450065

Change-Id: I28996d425838728955f01eb1a00acf6e6dc2dea1
Signed-off-by: Gaurav Kumar <gaurav.kumar@broadcom.com>
Signed-off-by: Pierre Couillaud <pierre@broadcom.com>
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: I4b0819a9d93141ac3307b8786fc6a451dd585220
libstagefright: Delay release of wakelock in TimedEventQueue

Delay release of wakelock in the TimedEventQueue to
after an event has been processed.
This ensures AP shutdown does not happen while an event
is ready but hasn't been processed yet.

Bug: 11976087.
Change-Id: I9bce83b9ff0f2b4d174a53c95e5b0f135b5ccc70
AudioTrack: fix obtainBuffer timeout calculation

AudioTrack::obtainBuffer() passes a pointer to a timeout
variable that has gone out of scope when calling
ClientProxy::obtainBuffer().

Same fix for AudioRecord.

Bug: 11968591.
Change-Id: I5b3d0d86ed2bd8c0412eb2432b1ab519d70efce9
Increase kFastTrackMultiplier from 1 to 2

Bug: 11967381
Change-Id: Iedec06280aa745d9df5d661f4916940cede9c191
DO NOT MERGE: camera2/3: Add protection for still capture path

Jpeg stream in JpegProcessor could be deleted while process new capture is
ongoing, which unsafe to access a dead consumer endpoint.
Bug: 9316454
Change-Id: I2950f31ea28d0ba01f08502e2e3ba452bf8bb818
DO NOT MERGE: camera2: Fix race with stream deletion during disconnect.

Bug: 11856804

- Shutdown order in Camera2Client allows a stream to be
  deleted before the corresponding processing thread has
  quit.  This can result in updates being called on the
  processor thread without a valid stream.

Change-Id: Ie4e649771f4321498659211f2a37ed89a6d956c4
DO NOT MERGE: Camera: fix focusArea wrong indexing issue

Bug: 12304559
Change-Id: Id28b35fdd9697c1ec3365f617996801965de8bd0