auto import from //depot/cupcake/@136594
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index e79f336..d26b0c5 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -808,7 +808,14 @@
writtenSize = audioBuffer.size;
// Sanity check on returned size
- if (ssize_t(writtenSize) <= 0) break;
+ if (ssize_t(writtenSize) <= 0) {
+ // The callback is done filling buffers
+ // Keep this thread going to handle timed events and
+ // still try to get more data in intervals of WAIT_PERIOD_MS
+ // but don't just loop and block the CPU, so wait
+ usleep(WAIT_PERIOD_MS*1000);
+ break;
+ }
if (writtenSize > reqSize) writtenSize = reqSize;
if (mFormat == AudioSystem::PCM_8_BIT) {
diff --git a/media/libmedia/mediarecorder.cpp b/media/libmedia/mediarecorder.cpp
index 98aac39..5eba0ef 100644
--- a/media/libmedia/mediarecorder.cpp
+++ b/media/libmedia/mediarecorder.cpp
@@ -42,7 +42,7 @@
if (OK != ret) {
LOGV("setCamera failed: %d", ret);
mCurrentState = MEDIA_RECORDER_ERROR;
- return UNKNOWN_ERROR;
+ return ret;
}
return ret;
}
@@ -67,7 +67,7 @@
if (OK != ret) {
LOGV("setPreviewSurface failed: %d", ret);
mCurrentState = MEDIA_RECORDER_ERROR;
- return UNKNOWN_ERROR;
+ return ret;
}
return ret;
}
@@ -88,14 +88,14 @@
if (OK != ret) {
LOGV("init failed: %d", ret);
mCurrentState = MEDIA_RECORDER_ERROR;
- return UNKNOWN_ERROR;
+ return ret;
}
ret = mMediaRecorder->setListener(this);
if (OK != ret) {
LOGV("setListener failed: %d", ret);
mCurrentState = MEDIA_RECORDER_ERROR;
- return UNKNOWN_ERROR;
+ return ret;
}
mCurrentState = MEDIA_RECORDER_INITIALIZED;
@@ -129,7 +129,7 @@
if (OK != ret) {
LOGV("setVideoSource failed: %d", ret);
mCurrentState = MEDIA_RECORDER_ERROR;
- return UNKNOWN_ERROR;
+ return ret;
}
mIsVideoSourceSet = true;
return ret;
@@ -162,7 +162,7 @@
if (OK != ret) {
LOGV("setAudioSource failed: %d", ret);
mCurrentState = MEDIA_RECORDER_ERROR;
- return UNKNOWN_ERROR;
+ return ret;
}
mIsAudioSourceSet = true;
return ret;
@@ -188,7 +188,7 @@
if (OK != ret) {
LOGE("setOutputFormat failed: %d", ret);
mCurrentState = MEDIA_RECORDER_ERROR;
- return UNKNOWN_ERROR;
+ return ret;
}
mCurrentState = MEDIA_RECORDER_DATASOURCE_CONFIGURED;
return ret;
@@ -218,7 +218,7 @@
if (OK != ret) {
LOGV("setVideoEncoder failed: %d", ret);
mCurrentState = MEDIA_RECORDER_ERROR;
- return UNKNOWN_ERROR;
+ return ret;
}
mIsVideoEncoderSet = true;
return ret;
@@ -248,7 +248,7 @@
if (OK != ret) {
LOGV("setAudioEncoder failed: %d", ret);
mCurrentState = MEDIA_RECORDER_ERROR;
- return UNKNOWN_ERROR;
+ return ret;
}
mIsAudioEncoderSet = true;
return ret;
@@ -274,7 +274,7 @@
if (OK != ret) {
LOGV("setOutputFile failed: %d", ret);
mCurrentState = MEDIA_RECORDER_ERROR;
- return UNKNOWN_ERROR;
+ return ret;
}
mIsOutputFileSet = true;
return ret;
@@ -300,7 +300,7 @@
if (OK != ret) {
LOGV("setOutputFile failed: %d", ret);
mCurrentState = MEDIA_RECORDER_ERROR;
- return UNKNOWN_ERROR;
+ return ret;
}
mIsOutputFileSet = true;
return ret;
@@ -326,7 +326,7 @@
if (OK != ret) {
LOGE("setVideoSize failed: %d", ret);
mCurrentState = MEDIA_RECORDER_ERROR;
- return UNKNOWN_ERROR;
+ return ret;
}
return ret;
}
@@ -351,7 +351,7 @@
if (OK != ret) {
LOGE("setVideoFrameRate failed: %d", ret);
mCurrentState = MEDIA_RECORDER_ERROR;
- return UNKNOWN_ERROR;
+ return ret;
}
return ret;
}
@@ -389,7 +389,7 @@
if (OK != ret) {
LOGE("prepare failed: %d", ret);
mCurrentState = MEDIA_RECORDER_ERROR;
- return UNKNOWN_ERROR;
+ return ret;
}
mCurrentState = MEDIA_RECORDER_PREPARED;
return ret;
@@ -411,7 +411,7 @@
if (OK != ret) {
LOGE("getMaxAmplitude failed: %d", ret);
mCurrentState = MEDIA_RECORDER_ERROR;
- return UNKNOWN_ERROR;
+ return ret;
}
return ret;
}
@@ -432,7 +432,7 @@
if (OK != ret) {
LOGE("start failed: %d", ret);
mCurrentState = MEDIA_RECORDER_ERROR;
- return UNKNOWN_ERROR;
+ return ret;
}
mCurrentState = MEDIA_RECORDER_RECORDING;
return ret;
@@ -454,7 +454,7 @@
if (OK != ret) {
LOGE("stop failed: %d", ret);
mCurrentState = MEDIA_RECORDER_ERROR;
- return UNKNOWN_ERROR;
+ return ret;
}
mCurrentState = MEDIA_RECORDER_IDLE;
return ret;
@@ -522,7 +522,7 @@
if (OK != ret) {
LOGE("doReset failed: %d", ret);
mCurrentState = MEDIA_RECORDER_ERROR;
- return UNKNOWN_ERROR;
+ return ret;
} else {
mCurrentState = MEDIA_RECORDER_INITIALIZED;
}