audioflinger: fix offload resume after drain

When pausing and resuming during the drain,
the drain sequence number shuold not be modified
otherwise the drain callback will be ignored.
This causes failure to notify end of stream to audio
player and transition to next song.

Bug: 11247103.
Change-Id: I2a35c5cc3fd6aa667cdd257f9e9cc8715cef5159
audioflinger: fix offload track transition

Make sure that when transitioning from one active
offloaded track to the next we flush DSP content
if both tracks are not on the same audio session.
This happens when switching between two applications
playing the same type of content (e.g MP3, stereo, 44.1).
In this case, we reuse the same output thread because the track
formats are compatible.

Bug: 11247103.
Change-Id: I2b9031591149adeb70766da5e0d21ff2933a37e8
Camera2: Rework the FPS range vs. FPS single setting detection

Give up on current approach of writing out consistent FPS values
into parameters that will be read back by the app.

- Preserve app's latest set parameters exactly, and compare against
  them when detecting if a new FPS range or single FPS value has been
  selected.

- Since get() returns exactly what was set(), it doesn't matter if the
  app calls getParameters() before its next setParameters(), in terms
  of retriggering FPS selection logic. Before, the behavior varied
  depending on whether the app re-read the parameters.

- As before, if app changes both range and single FPS in a single set
  call, the range set wins. Otherwise, the value that has changed more
  recently is used.

Bug: 11570973
Change-Id: I72b5e60c3f60e88d55127dd1bda87e26eaf929c6
AwesomePlayer: correct stream type for offload

canOffloadStream() function in stagefright utils forces the
stream type to AUDIO_STREAM_MUSIC when querying the audio policy
manager if a particular track is offloadable or not.
This causes MP3 ringtones to be offloaded which is not a validated use case.

The fix consists in using the actual stream type read from the AudioSink.

Bug: 11410937.
Change-Id: I44b8e033a8e785a79cdc291b142f80b5580bdc4d
audioflinger: do not use raw pointer for tracks

Commit 9da3d95 surfaced a problem caused by the use of a raw
pointer to a track in offload thread implementation.

Pointers to tracks should always be weak or strong pointers.

Bug: 11708529.
Change-Id: Ic48632532d186c9be8261f73cefdf824b9fbbd2b
Fix metadata access

Metadata string pointers become invalid after setting more metadata,
so don't cache them.
b/11692062

Change-Id: Iaf1afb24cf53f7fa36f49ce759355693494076e5
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
MediaScanner: Ignore dirs with .noscanandnomtp

Completely ignore directories with .noscanandnomtp files
in them. Placing a .nomedia file will still scan a
directory but exclude it from the media database. This
is so the file may still be presented for MTP purposes.

Placing .noscanandnomtp completely prevents the scan,
which saves considerable processing power and battery
life on systems with numerous media files, but prevents
them from being seen over MTP.

Change-Id: Ibff2a9f2525255a2ac34132eeee36734962fbdd7
audio: Increase kFastTrackMultiplier from 1 to 2

- Fast Track implementation is modified to use single
  buffer in kitkat. This is causing audio breaks when
  long DTMF tones are played
- Fix is to use double buffering to avoid audio breaks

Change-Id: Idc811ee7fe0d7f49bfa95ad34bc6e88bd04b734e
CRs-Fixed: 561567