diff options
author | Eric Laurent <elaurent@google.com> | 2014-05-09 18:04:42 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2014-05-12 10:46:31 -0700 |
commit | 0ede8924b98c2967be2795e8d4f9837d8d3f094c (patch) | |
tree | ae5603fc402e1c5db80932e805cba811145ebc77 /services/audiopolicy/AudioPolicyService.h | |
parent | 0fdbdd2a3909e4692fa3baaaa1f53eb91b31af56 (diff) | |
download | frameworks_av-0ede8924b98c2967be2795e8d4f9837d8d3f094c.zip frameworks_av-0ede8924b98c2967be2795e8d4f9837d8d3f094c.tar.gz frameworks_av-0ede8924b98c2967be2795e8d4f9837d8d3f094c.tar.bz2 |
audiopolicy: refactor audio command threads
- Use strong pointers for command data to avoid transfering
ownership of the object to receiver thread.
This avoids waiting for the command acknowlegement to proceed
with next command on server side.
- Use a separate mutex for each command condition.
- Factor in duplicated code to send commands.
Change-Id: Ib0526e7c4fa64a71ad4015f477c6361727c6f40a
Diffstat (limited to 'services/audiopolicy/AudioPolicyService.h')
-rw-r--r-- | services/audiopolicy/AudioPolicyService.h | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/services/audiopolicy/AudioPolicyService.h b/services/audiopolicy/AudioPolicyService.h index 28e3a4b..26037e4 100644 --- a/services/audiopolicy/AudioPolicyService.h +++ b/services/audiopolicy/AudioPolicyService.h @@ -194,30 +194,31 @@ private: audio_stream_type_t stream, int session); void releaseOutputCommand(audio_io_handle_t output); - - void insertCommand_l(AudioCommand *command, int delayMs = 0); + status_t sendCommand(sp<AudioCommand>& command, int delayMs = 0); + void insertCommand_l(sp<AudioCommand>& command, int delayMs = 0); private: class AudioCommandData; // descriptor for requested tone playback event - class AudioCommand { + class AudioCommand: public RefBase { public: AudioCommand() - : mCommand(-1) {} + : mCommand(-1), mStatus(NO_ERROR), mWaitStatus(false) {} void dump(char* buffer, size_t size); int mCommand; // START_TONE, STOP_TONE ... nsecs_t mTime; // time stamp + Mutex mLock; // mutex associated to mCond Condition mCond; // condition for status return status_t mStatus; // command status bool mWaitStatus; // true if caller is waiting for status - AudioCommandData *mParam; // command specific parameter data + sp<AudioCommandData> mParam; // command specific parameter data }; - class AudioCommandData { + class AudioCommandData: public RefBase { public: virtual ~AudioCommandData() {} protected: @@ -262,9 +263,9 @@ private: Mutex mLock; Condition mWaitWorkCV; - Vector <AudioCommand *> mAudioCommands; // list of pending commands + Vector < sp<AudioCommand> > mAudioCommands; // list of pending commands ToneGenerator *mpToneGenerator; // the tone generator - AudioCommand mLastCommand; // last processed command (used by dump) + sp<AudioCommand> mLastCommand; // last processed command (used by dump) String8 mName; // string used by wake lock fo delayed commands wp<AudioPolicyService> mService; }; |