AudioFlinger: add check for NULL mInput in MMAP Thread
exitStandby() was crashing if headphones were
unplugged between the open and start of a MMAP stream.
Bug: 120564294
Test: see repro steps in bug
Change-Id: Ic42743682ffeb48f2869eaa90581b4e4f7fcb1ab
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 45d3a06..27aec9e 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -9146,7 +9146,13 @@
status_t AudioFlinger::MmapCaptureThread::exitStandby()
{
- mInput->stream->setGain(1.0f);
+ {
+ // mInput might have been cleared by clearInput()
+ Mutex::Autolock _l(mLock);
+ if (mInput != nullptr && mInput->stream != nullptr) {
+ mInput->stream->setGain(1.0f);
+ }
+ }
return MmapThread::exitStandby();
}