Merge "Stagefright: idle OMX after ANW errors" into ics-mr0
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp
index b5eef94..3ebe989 100644
--- a/media/libmediaplayerservice/MediaPlayerService.cpp
+++ b/media/libmediaplayerservice/MediaPlayerService.cpp
@@ -374,11 +374,13 @@
} else {
for (int i = 0, n = mMediaRecorderClients.size(); i < n; ++i) {
sp<MediaRecorderClient> c = mMediaRecorderClients[i].promote();
- snprintf(buffer, 255, " MediaRecorderClient pid(%d)\n", c->mPid);
- result.append(buffer);
- write(fd, result.string(), result.size());
- result = "\n";
- c->dump(fd, args);
+ if (c != 0) {
+ snprintf(buffer, 255, " MediaRecorderClient pid(%d)\n", c->mPid);
+ result.append(buffer);
+ write(fd, result.string(), result.size());
+ result = "\n";
+ c->dump(fd, args);
+ }
}
}
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 1128771..00d414c 100755
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -52,6 +52,13 @@
// buffers after 3 seconds.
const static int64_t kBufferFilledEventTimeOutNs = 3000000000LL;
+// OMX Spec defines less than 50 color formats. If the query for
+// color format is executed for more than kMaxColorFormatSupported,
+// the query will fail to avoid looping forever.
+// 1000 is more than enough for us to tell whether the omx
+// component in question is buggy or not.
+const static uint32_t kMaxColorFormatSupported = 1000;
+
struct CodecInfo {
const char *mime;
const char *codec;
@@ -818,6 +825,11 @@
}
++index;
+ if (index >= kMaxColorFormatSupported) {
+ CODEC_LOGE("color format %d or compression format %d is not supported",
+ colorFormat, compressionFormat);
+ return UNKNOWN_ERROR;
+ }
}
if (!found) {
@@ -901,22 +913,19 @@
// the incremented index (bug 2897413).
CHECK_EQ(index, portFormat.nIndex);
if (portFormat.eColorFormat == colorFormat) {
- LOGV("Found supported color format: %d", portFormat.eColorFormat);
+ CODEC_LOGV("Found supported color format: %d", portFormat.eColorFormat);
return OK; // colorFormat is supported!
}
++index;
portFormat.nIndex = index;
- // OMX Spec defines less than 50 color formats
- // 1000 is more than enough for us to tell whether the omx
- // component in question is buggy or not.
- if (index >= 1000) {
- LOGE("More than %ld color formats are supported???", index);
+ if (index >= kMaxColorFormatSupported) {
+ CODEC_LOGE("More than %ld color formats are supported???", index);
break;
}
}
- LOGE("color format %d is not supported", colorFormat);
+ CODEC_LOGE("color format %d is not supported", colorFormat);
return UNKNOWN_ERROR;
}
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index ab49f93..69560e5 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -1332,7 +1332,13 @@
int sessionId)
{
Mutex::Autolock _l(mLock);
+ checkSuspendOnEffectEnabled_l(effect, enabled, sessionId);
+}
+void AudioFlinger::ThreadBase::checkSuspendOnEffectEnabled_l(const sp<EffectModule>& effect,
+ bool enabled,
+ int sessionId)
+{
if (mType != RECORD) {
// suspend all effects in AUDIO_SESSION_OUTPUT_MIX when enabling any effect on
// another session. This gives the priority to well behaved effect control panels
@@ -1832,7 +1838,9 @@
size_t mixBufferSize = mFrameCount * mFrameSize;
// FIXME: Relaxed timing because of a certain device that can't meet latency
// Should be reduced to 2x after the vendor fixes the driver issue
- nsecs_t maxPeriod = seconds(mFrameCount) / mSampleRate * 3;
+ // increase threshold again due to low power audio mode. The way this warning threshold is
+ // calculated and its usefulness should be reconsidered anyway.
+ nsecs_t maxPeriod = seconds(mFrameCount) / mSampleRate * 15;
nsecs_t lastWarning = 0;
bool longStandbyExit = false;
uint32_t activeSleepTime = activeSleepTimeUs();
@@ -1886,7 +1894,9 @@
mixBufferSize = mFrameCount * mFrameSize;
// FIXME: Relaxed timing because of a certain device that can't meet latency
// Should be reduced to 2x after the vendor fixes the driver issue
- maxPeriod = seconds(mFrameCount) / mSampleRate * 3;
+ // increase threshold again due to low power audio mode. The way this warning
+ // threshold is calculated and its usefulness should be reconsidered anyway.
+ maxPeriod = seconds(mFrameCount) / mSampleRate * 15;
activeSleepTime = activeSleepTimeUs();
idleSleepTime = idleSleepTimeUs();
}
@@ -1983,7 +1993,7 @@
mInWrite = false;
nsecs_t now = systemTime();
nsecs_t delta = now - mLastWriteTime;
- if (delta > maxPeriod) {
+ if (!mStandby && delta > maxPeriod) {
mNumDelayedWrites++;
if ((now - lastWarning) > kWarningThrottle) {
LOGW("write blocked for %llu msecs, %d delayed writes, thread %p",
@@ -5220,6 +5230,9 @@
sp<EffectHandle> handle = effect->mHandles[j].promote();
if (handle != 0) {
handle->mEffect.clear();
+ if (handle->mHasControl && handle->mEnabled) {
+ t->checkSuspendOnEffectEnabled_l(effect, false, effect->sessionId());
+ }
}
}
AudioSystem::unregisterEffect(effect->id());
@@ -6840,7 +6853,7 @@
}
mEffect->disconnect(this, unpiniflast);
- if (mEnabled) {
+ if (mHasControl && mEnabled) {
sp<ThreadBase> thread = mEffect->thread().promote();
if (thread != 0) {
thread->checkSuspendOnEffectEnabled(mEffect, false, mEffect->sessionId());
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index ed9d81e..4b794ef 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -492,10 +492,12 @@
int sessionId = AUDIO_SESSION_OUTPUT_MIX);
// check if some effects must be suspended/restored when an effect is enabled
// or disabled
- virtual void checkSuspendOnEffectEnabled(const sp<EffectModule>& effect,
+ void checkSuspendOnEffectEnabled(const sp<EffectModule>& effect,
bool enabled,
int sessionId = AUDIO_SESSION_OUTPUT_MIX);
-
+ void checkSuspendOnEffectEnabled_l(const sp<EffectModule>& effect,
+ bool enabled,
+ int sessionId = AUDIO_SESSION_OUTPUT_MIX);
mutable Mutex mLock;
protected:
@@ -1299,7 +1301,7 @@
// suspend all eligible effects
void setEffectSuspendedAll_l(bool suspend);
// check if effects should be suspend or restored when a given effect is enable or disabled
- virtual void checkSuspendOnEffectEnabled(const sp<EffectModule>& effect,
+ void checkSuspendOnEffectEnabled(const sp<EffectModule>& effect,
bool enabled);
status_t dump(int fd, const Vector<String16>& args);
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 171710a..bb0e664 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -331,14 +331,8 @@
Mutex::Autolock lock(mSoundLock);
sp<MediaPlayer> player = mSoundPlayer[kind];
if (player != 0) {
- // do not play the sound if stream volume is 0
- // (typically because ringer mode is silent).
- int index;
- AudioSystem::getStreamVolumeIndex(mAudioStreamType, &index);
- if (index != 0) {
- player->seekTo(0);
- player->start();
- }
+ player->seekTo(0);
+ player->start();
}
}