summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2016-09-07 16:58:39 -0700
committergitbuildkicker <android-build@google.com>2016-09-27 15:56:39 -0700
commitd8cf9aa813be5363fb5425b4f818a267edd5e750 (patch)
tree32dee67c0b6fd952baec8ca54bda27c1d9e67f16
parentace612c5f838944d1b88be18e317709e640becc2 (diff)
downloadframeworks_av-d8cf9aa813be5363fb5425b4f818a267edd5e750.zip
frameworks_av-d8cf9aa813be5363fb5425b4f818a267edd5e750.tar.gz
frameworks_av-d8cf9aa813be5363fb5425b4f818a267edd5e750.tar.bz2
SoundTrigger: get service by value.
Get strong pointer to service interface by value and not reference to prevent race conditions where the service pointer can be cleared by another thread while in use. Bug: 30907212 Change-Id: I6f02ec3fd1e6392b842b334e1cc4f9aa23916009 (cherry picked from commit 3b01b3019b1c62132792a1a94e2dc1f7cfc84f2e)
-rw-r--r--include/soundtrigger/SoundTrigger.h2
-rw-r--r--soundtrigger/SoundTrigger.cpp8
2 files changed, 5 insertions, 5 deletions
diff --git a/include/soundtrigger/SoundTrigger.h b/include/soundtrigger/SoundTrigger.h
index bf5e1de..9a05cac 100644
--- a/include/soundtrigger/SoundTrigger.h
+++ b/include/soundtrigger/SoundTrigger.h
@@ -68,7 +68,7 @@ public:
private:
SoundTrigger(sound_trigger_module_handle_t module,
const sp<SoundTriggerCallback>&);
- static const sp<ISoundTriggerHwService>& getSoundTriggerHwService();
+ static const sp<ISoundTriggerHwService> getSoundTriggerHwService();
Mutex mLock;
sp<ISoundTrigger> mISoundTrigger;
diff --git a/soundtrigger/SoundTrigger.cpp b/soundtrigger/SoundTrigger.cpp
index 2138cb7..e959b83 100644
--- a/soundtrigger/SoundTrigger.cpp
+++ b/soundtrigger/SoundTrigger.cpp
@@ -55,7 +55,7 @@ namespace {
sp<DeathNotifier> gDeathNotifier;
}; // namespace anonymous
-const sp<ISoundTriggerHwService>& SoundTrigger::getSoundTriggerHwService()
+const sp<ISoundTriggerHwService> SoundTrigger::getSoundTriggerHwService()
{
Mutex::Autolock _l(gLock);
if (gSoundTriggerHwService.get() == 0) {
@@ -84,7 +84,7 @@ status_t SoundTrigger::listModules(struct sound_trigger_module_descriptor *modul
uint32_t *numModules)
{
ALOGV("listModules()");
- const sp<ISoundTriggerHwService>& service = getSoundTriggerHwService();
+ const sp<ISoundTriggerHwService> service = getSoundTriggerHwService();
if (service == 0) {
return NO_INIT;
}
@@ -96,7 +96,7 @@ sp<SoundTrigger> SoundTrigger::attach(const sound_trigger_module_handle_t module
{
ALOGV("attach()");
sp<SoundTrigger> soundTrigger;
- const sp<ISoundTriggerHwService>& service = getSoundTriggerHwService();
+ const sp<ISoundTriggerHwService> service = getSoundTriggerHwService();
if (service == 0) {
return soundTrigger;
}
@@ -116,7 +116,7 @@ sp<SoundTrigger> SoundTrigger::attach(const sound_trigger_module_handle_t module
status_t SoundTrigger::setCaptureState(bool active)
{
ALOGV("setCaptureState(%d)", active);
- const sp<ISoundTriggerHwService>& service = getSoundTriggerHwService();
+ const sp<ISoundTriggerHwService> service = getSoundTriggerHwService();
if (service == 0) {
return NO_INIT;
}