From 493404d8c396e15ed73455acd39aa0f1940996e2 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Tue, 21 Apr 2015 15:07:36 -0700 Subject: audio policy: fix AudioTrack output device selection Have AudioTrack::setOutputDevice() set CBLK_INVALID flag instead of calling restoreTrack_l(). This allows restoreTrack_l() to be called in a safe context. Allow device change while the AudioTrack is active by forcing a new device selection in startOutput() if the output route for this session was changed. Remove some warnings. Change-Id: I2d921a63c9bfa0e122233645e2d6d39f95f5f17d --- services/audiopolicy/managerdefault/AudioPolicyManager.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'services/audiopolicy/managerdefault/AudioPolicyManager.h') diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h index 146a7af..521f6c4 100644 --- a/services/audiopolicy/managerdefault/AudioPolicyManager.h +++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h @@ -244,7 +244,10 @@ protected: mStreamType(streamType), mDeviceDescriptor(deviceDescriptor), mRefCount(0), - mActivityCount(0) {} + mActivityCount(0), + mChanged(false) {} + + void log(const char* prefix); audio_session_t mSession; audio_stream_type_t mStreamType; @@ -252,10 +255,9 @@ protected: sp mDeviceDescriptor; // "reference" counting - int mRefCount; // +/- on references - int mActivityCount; // +/- on start/stop - - void log(const char* prefix); + int mRefCount; // +/- on references + int mActivityCount; // +/- on start/stop + bool mChanged; }; class SessionRouteMap: public KeyedVector> @@ -268,7 +270,7 @@ protected: int incRouteActivity(audio_session_t session); int decRouteActivity(audio_session_t session); - + bool hasRouteChanged(audio_session_t session); // also clears the changed flag void log(const char* caption); }; @@ -510,6 +512,8 @@ protected: void updateCallRouting(audio_devices_t rxDevice, int delayMs = 0); + // if argument "device" is different from AUDIO_DEVICE_NONE, startSource() will force + // the re-evaluation of the output device. status_t startSource(sp outputDesc, audio_stream_type_t stream, audio_devices_t device, -- cgit v1.1