summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2010-03-05 16:01:47 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-03-05 16:01:47 -0800
commit29855801de083e82b76dee18e5e161d154bdb60c (patch)
tree0b1b15f34b43bbad34060d8e231bb10cc64864d2 /media
parent931bf89d327ecf07301231fd86b17deac535feaa (diff)
parentba8811f5528404527b0cbad584a836f0b1807d26 (diff)
downloadframeworks_base-29855801de083e82b76dee18e5e161d154bdb60c.zip
frameworks_base-29855801de083e82b76dee18e5e161d154bdb60c.tar.gz
frameworks_base-29855801de083e82b76dee18e5e161d154bdb60c.tar.bz2
Merge "Fix issue 2428563: Camera rendered inoperable by voice call interruption."
Diffstat (limited to 'media')
-rw-r--r--media/libmedia/AudioRecord.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index bce3371..ad037d6 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -552,13 +552,17 @@ ssize_t AudioRecord::read(void* buffer, size_t userSize)
audioBuffer.frameCount = userSize/frameSize();
- // Calling obtainBuffer() with a negative wait count causes
- // an (almost) infinite wait time.
- status_t err = obtainBuffer(&audioBuffer, -1);
+ // By using a wait count corresponding to twice the timeout period in
+ // obtainBuffer() we give a chance to recover once for a read timeout
+ // (if media_server crashed for instance) before returning a length of
+ // 0 bytes read to the client
+ status_t err = obtainBuffer(&audioBuffer, ((2 * MAX_RUN_TIMEOUT_MS) / WAIT_PERIOD_MS));
if (err < 0) {
// out of buffers, return #bytes written
if (err == status_t(NO_MORE_BUFFERS))
break;
+ if (err == status_t(TIMED_OUT))
+ err = 0;
return ssize_t(err);
}