ExternalCamera: Fix a deadlock crash using std::thread
It's not a good idea to call join() from std::thread's destructor.
In this case, the order of sequence is:
1. OutputThread::threadLoop runs to completion, holding the last
ExternalCameraDeviceSession reference,
2. Upon exiting OutputThread::threadLopp, ~ExternalCameraDeviceSession
is called, which calls OutputThread.requestExitAndWait()
In this sequence, the requesetExitAndWait() is joining on itself,
causing deadlock. Check the calling thread id before calling
'join'. If the calling thread id matches the 'thread' object's thread
id, use 'detach' instead.
Test: Run VTS on a USB camera
Flag: EXEMPT bugfix
Bug: 399939768
Change-Id: Ic39a2d54828f4269a29ba047dee8e6644fef62a4
1 file changed