replicant-frameworks_native/libs/audioflinger
Eric Laurent 4edfe75018 Fix issue 2553359: Pandora does not work well with Passion deskdock / Cardock.
The problem is due to a too big difference between the buffer size used at the hardware interface and at the A2DP interface.
When no resampling occurs we don't notice problems but the timing is very tight. As soon as resampling is activated, the AudioTrack underruns.
This is because the AudioTrack buffers are not resized when moving the AudioTrack from hardware to A2DP output.
The AudioTrack buffers are calculated based on a hardware output buffer size of 3072 bytes. Which is much less than the A2DP output buffer size (10240).

The solution consists in creating new tracks with new buffers in AudioFlinger when the A2DP output is opened
instead of just transfering active tracks from hardware output mixer thread to the new A2DP output mixer thread.
To avoid synchronization issues between mixer threads and client processes, this is done by invalidating tracks
by setting a flag in their control block and having AudioTrack release the handle on this track (IAudioTrack)
and create a new IAudioTrack when this flag is detected next time obtainBuffer() or start() is executed.

AudioFlinger modifications:
- invalidate the tracks when setStreamOutput() is called
- make sure that notifications of output opening/closing and change of stream type to output mapping are sent synchronously to client process.
This is necessary so that AudioSystem has the new stream to output mapping when the AudioTrack detects the invalidate flag in the client process.
Previously their were sent when the corresponding thread loop was executed.

AudioTrack modifications:
- move frame count calculation and verification from set() to createTrack() so that is is updated every time a new IAudioTrack is created.
- detect track invalidate flag in obtainBuffer() and start() and create a new IAudioTrack.

AudioTrackShared modifications
- group all flags (out, flowControlFlag, forceReady...) into a single bit filed to save space.

Change-Id: I9ac26b6192230627d35084e1449640caaf7d56ee
2010-05-17 02:23:47 -07:00
..
A2dpAudioInterface.cpp Fix bug 2604132 40s skip after undocking 2010-04-20 12:12:13 -07:00
A2dpAudioInterface.h
Android.mk Use proper config to enable LVMX 2010-03-09 18:13:59 -08:00
AudioBufferProvider.h
AudioDumpInterface.cpp Several fixes in AudioDumpInterface: 2010-05-12 08:31:04 -07:00
AudioDumpInterface.h Several fixes in AudioDumpInterface: 2010-05-12 08:31:04 -07:00
AudioFlinger.cpp Fix issue 2553359: Pandora does not work well with Passion deskdock / Cardock. 2010-05-17 02:23:47 -07:00
AudioFlinger.h Fix issue 2553359: Pandora does not work well with Passion deskdock / Cardock. 2010-05-17 02:23:47 -07:00
AudioHardwareGeneric.cpp
AudioHardwareGeneric.h Issue 2071329: audio track is shorter than video track for video capture on sholes 2010-03-02 08:20:13 -08:00
AudioHardwareInterface.cpp
AudioHardwareStub.cpp Initial version of LifeVibes integration. 2010-03-09 14:16:01 -08:00
AudioHardwareStub.h Issue 2071329: audio track is shorter than video track for video capture on sholes 2010-03-02 08:20:13 -08:00
AudioMixer.cpp
AudioMixer.h
AudioPolicyManagerBase.cpp Fix issue 2553359: Pandora does not work well with Passion deskdock / Cardock. 2010-05-17 02:23:47 -07:00
AudioPolicyService.cpp
AudioPolicyService.h
AudioResampler.cpp
AudioResampler.h Initial version of LifeVibes integration. 2010-03-09 14:16:01 -08:00
AudioResamplerCubic.cpp
AudioResamplerCubic.h
AudioResamplerSinc.cpp
AudioResamplerSinc.h