Ignore onImageAvailable callbacks after ImageReader has been closed.
In order to not access a closed ImageReader compare mImgReader with
ImageReader in onImageAvailable callback and ignore it if they're not
the same. Synchronize the comparison in onImageAvailable with a new
mImgReaderLock.
Also change acquireLatestImage() -> acquireNextImage() since we don't
do any compute intensive operations on the image reader thread - and
therefore never accumulate image buffers ready to be acquired.
acquireLatestImage() can cause a lot of internal logspam when we
have MAX_BUFFERS - 1 buffers already in the encode loop.
Bug: 301216738
Test: Have webcam be evicted multiple times to try to trigger
ImageReader re-creation.
Change-Id: Ic566e8fa71d2f126480b7e46b587741d27308508
Signed-off-by: Jayant Chowdhary <jchowdhary@google.com>
2 files changed