From 49f02be9d7fafb8841f75394a90f1409c6f82c1f Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Thu, 19 Nov 2009 09:00:56 -0800 Subject: Issue 2265163: Audio still reported routed through earpiece on sholes This is a second attempt to fix the audio routed to earpiece syndrom. The root cause identified this time is the crash of an application having an active AudioTrack playing on the VOICE_CALL stream type. When this happens, the AudioTrack destructor is not called and the audio policy manager is not notified of the track stop. Results a situation where the VOICE_CALL stream is considered as always in use by audio policy manager which makes that audio is routed to earpiece. The fix consists in moving the track start/stop/close notification to audio policiy manager from AudioTrack to AudioFlinger Track objet. The net result is that in the case of a client application crash, the AudioFlinger TrackHandle object (which implements the remote side of the IAudioTrack binder interface) destructor is called which in turn destroys the Track object and we can notify the audio policy manager of the track stop and removal. The same modification is made for AudioRecord although no bug related to record has been reported yet. Also fixed a potential problem if record stop is called while the record thread is exiting. --- include/media/AudioRecord.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h index 008468c..622c596 100644 --- a/include/media/AudioRecord.h +++ b/include/media/AudioRecord.h @@ -268,7 +268,7 @@ public: * Returned value: * handle on audio hardware input */ - audio_io_handle_t getInput() { return mInput; } + audio_io_handle_t getInput(); /* obtains a buffer of "frameCount" frames. The buffer must be * filled entirely. If the track is stopped, obtainBuffer() returns @@ -318,7 +318,8 @@ private: int format, int channelCount, int frameCount, - uint32_t flags); + uint32_t flags, + audio_io_handle_t input); sp mAudioRecord; sp mCblkMemory; @@ -345,8 +346,8 @@ private: bool mMarkerReached; uint32_t mNewPosition; uint32_t mUpdatePeriod; - audio_io_handle_t mInput; uint32_t mFlags; + uint32_t mChannels; }; }; // namespace android -- cgit v1.1