From d8a9d0220e84ae0b5049385aa9b1a0d8ea02b5bb Mon Sep 17 00:00:00 2001 From: Glenn Kasten Date: Tue, 14 Jan 2014 15:46:38 -0800 Subject: Cleanup loop termination logic in AudioRecord::obtainBuffer() Apply the same change to AudioRecord, that was already done for AudioTrack in this CL: > Change-Id: I0fc48117946364cb255afd653195498891f622bd If the proxy->obtainBuffer at the end of the "do" loop fails with status DEAD_OBJECT, and the restoreRecord_l during the next trip of the "do" loop also fails, then the value of the buffer fields will be based on the previous proxy->obtainBuffer that returned DEAD_OBJECT. This will have cleared the buffer, but it's tricky. So instead explicitly clear the buffer after restoreRecord_l, before breaking out of the loop. Change-Id: Ifc97f2ab7b8195d6b149502bb5d765d2983b07be --- media/libmedia/AudioRecord.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'media/libmedia/AudioRecord.cpp') diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp index e39a475..f332313 100644 --- a/media/libmedia/AudioRecord.cpp +++ b/media/libmedia/AudioRecord.cpp @@ -591,6 +591,9 @@ status_t AudioRecord::obtainBuffer(Buffer* audioBuffer, const struct timespec *r if (newSequence == oldSequence) { status = restoreRecord_l("obtainBuffer"); if (status != NO_ERROR) { + buffer.mFrameCount = 0; + buffer.mRaw = NULL; + buffer.mNonContig = 0; break; } } -- cgit v1.1