summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/media/stagefright/MediaCodec.h1
-rw-r--r--media/libavextensions/mediaplayerservice/AVNuExtensions.h3
-rw-r--r--media/libavextensions/mediaplayerservice/AVNuUtils.cpp4
-rw-r--r--media/libavextensions/stagefright/AVExtensions.h1
-rw-r--r--media/libmediaplayerservice/nuplayer/GenericSource.cpp27
-rw-r--r--media/libmediaplayerservice/nuplayer/GenericSource.h2
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp8
-rw-r--r--media/libstagefright/ACodec.cpp4
-rw-r--r--media/libstagefright/Android.mk11
-rw-r--r--media/libstagefright/MPEG4Writer.cpp4
-rw-r--r--media/libstagefright/MediaCodec.cpp8
-rw-r--r--media/libstagefright/SurfaceMediaSource.cpp11
-rw-r--r--media/libstagefright/include/SimpleSoftOMXComponent.h1
-rw-r--r--media/libstagefright/omx/SimpleSoftOMXComponent.cpp44
-rw-r--r--services/audiopolicy/common/managerdefinitions/include/EffectDescriptor.h3
-rw-r--r--services/audiopolicy/common/managerdefinitions/src/EffectDescriptor.cpp5
-rw-r--r--services/camera/libcameraservice/CameraFlashlight.cpp12
17 files changed, 122 insertions, 27 deletions
diff --git a/include/media/stagefright/MediaCodec.h b/include/media/stagefright/MediaCodec.h
index b0ae83b..9c489e5 100644
--- a/include/media/stagefright/MediaCodec.h
+++ b/include/media/stagefright/MediaCodec.h
@@ -52,6 +52,7 @@ struct MediaCodec : public AHandler {
BUFFER_FLAG_CODECCONFIG = 2,
BUFFER_FLAG_EOS = 4,
BUFFER_FLAG_EXTRADATA = 0x1000,
+ BUFFER_FLAG_DATACORRUPT = 0x2000,
};
enum {
diff --git a/media/libavextensions/mediaplayerservice/AVNuExtensions.h b/media/libavextensions/mediaplayerservice/AVNuExtensions.h
index 5a7a0cb..d7e29d1 100644
--- a/media/libavextensions/mediaplayerservice/AVNuExtensions.h
+++ b/media/libavextensions/mediaplayerservice/AVNuExtensions.h
@@ -80,12 +80,13 @@ struct AVNuUtils {
virtual void setDecodedPCMFormat(const sp<AMessage> &);
virtual status_t convertToSinkFormatIfNeeded(const sp<ABuffer> &, sp<ABuffer> &,
audio_format_t sinkFormat, bool isOffload);
- virtual uint32_t getUseSetBuffersFlag();
+ virtual uint32_t getFlags();
virtual bool canUseSetBuffers(const sp<MetaData> &Meta);
virtual void printFileName(int fd);
virtual void checkFormatChange(bool *formatChange, const sp<ABuffer> &accessUnit);
virtual void addFlagsInMeta(const sp<ABuffer> &buffer, int32_t flags, bool isAudio);
+ virtual bool dropCorruptFrame();
// ----- NO TRESSPASSING BEYOND THIS LINE ------
DECLARE_LOADABLE_SINGLETON(AVNuUtils);
diff --git a/media/libavextensions/mediaplayerservice/AVNuUtils.cpp b/media/libavextensions/mediaplayerservice/AVNuUtils.cpp
index ba837e4..85f07db 100644
--- a/media/libavextensions/mediaplayerservice/AVNuUtils.cpp
+++ b/media/libavextensions/mediaplayerservice/AVNuUtils.cpp
@@ -146,7 +146,7 @@ void AVNuUtils::addFlagsInMeta(const sp<ABuffer> & /*buffer*/,
int32_t /*flags*/, bool /*isAudio*/) {
}
-uint32_t AVNuUtils::getUseSetBuffersFlag() {
+uint32_t AVNuUtils::getFlags() {
return 0;
}
@@ -154,6 +154,8 @@ bool AVNuUtils::canUseSetBuffers(const sp<MetaData> &/*Meta*/) {
return false;
}
+bool AVNuUtils::dropCorruptFrame() { return false; }
+
// ----- NO TRESSPASSING BEYOND THIS LINE ------
AVNuUtils::AVNuUtils() {}
diff --git a/media/libavextensions/stagefright/AVExtensions.h b/media/libavextensions/stagefright/AVExtensions.h
index 937180f..0b70c08 100644
--- a/media/libavextensions/stagefright/AVExtensions.h
+++ b/media/libavextensions/stagefright/AVExtensions.h
@@ -47,7 +47,6 @@ struct ACodec;
struct ALooper;
struct IMediaHTTPConnection;
struct MediaCodec;
-struct MediaSource;
struct MediaHTTP;
struct NuCachedSource2;
class CameraParameters;
diff --git a/media/libmediaplayerservice/nuplayer/GenericSource.cpp b/media/libmediaplayerservice/nuplayer/GenericSource.cpp
index 7be4d23..c0355d7 100644
--- a/media/libmediaplayerservice/nuplayer/GenericSource.cpp
+++ b/media/libmediaplayerservice/nuplayer/GenericSource.cpp
@@ -128,6 +128,7 @@ status_t NuPlayer::GenericSource::setDataSource(
status_t NuPlayer::GenericSource::setDataSource(const sp<DataSource>& source) {
resetDataSource();
+ Mutex::Autolock _l(mSourceLock);
mDataSource = source;
return OK;
}
@@ -155,7 +156,12 @@ status_t NuPlayer::GenericSource::initFromDataSource() {
return UNKNOWN_ERROR;
}
} else if (mIsStreaming) {
- if (!mDataSource->sniff(&mimeType, &confidence, &dummy)) {
+ sp<DataSource> dataSource;
+ {
+ Mutex::Autolock _l(mSourceLock);
+ dataSource = mDataSource;
+ }
+ if (!dataSource->sniff(&mimeType, &confidence, &dummy)) {
return UNKNOWN_ERROR;
}
isWidevineStreaming = !strcasecmp(
@@ -175,7 +181,7 @@ status_t NuPlayer::GenericSource::initFromDataSource() {
} else {
extractor = MediaExtractor::Create(mDataSource,
mimeType.isEmpty() ? NULL : mimeType.string(),
- mIsStreaming ? 0 : AVNuUtils::get()->getUseSetBuffersFlag());
+ mIsStreaming ? 0 : AVNuUtils::get()->getFlags());
}
if (extractor == NULL) {
@@ -380,6 +386,7 @@ void NuPlayer::GenericSource::onPrepareAsync() {
}
}
+ Mutex::Autolock _l(mSourceLock);
mDataSource = DataSource::CreateFromURI(
mHTTPService, uri, &mUriHeaders, &contentType,
static_cast<HTTPBase *>(mHttpSource.get()),
@@ -387,6 +394,7 @@ void NuPlayer::GenericSource::onPrepareAsync() {
} else {
mIsWidevine = false;
+ Mutex::Autolock _l(mSourceLock);
mDataSource = new FileSource(mFd, mOffset, mLength);
mFd = -1;
}
@@ -478,15 +486,10 @@ void NuPlayer::GenericSource::finishPrepareAsync() {
void NuPlayer::GenericSource::notifyPreparedAndCleanup(status_t err) {
if (err != OK) {
{
- sp<DataSource> dataSource = mDataSource;
- sp<NuCachedSource2> cachedSource = mCachedSource;
- sp<DataSource> httpSource = mHttpSource;
- {
- Mutex::Autolock _l(mDisconnectLock);
- mDataSource.clear();
- mCachedSource.clear();
- mHttpSource.clear();
- }
+ Mutex::Autolock _l(mSourceLock);
+ mDataSource.clear();
+ mCachedSource.clear();
+ mHttpSource.clear();
}
mBitrate = -1;
@@ -542,7 +545,7 @@ void NuPlayer::GenericSource::resume() {
void NuPlayer::GenericSource::disconnect() {
sp<DataSource> dataSource, httpSource;
{
- Mutex::Autolock _l(mDisconnectLock);
+ Mutex::Autolock _l(mSourceLock);
dataSource = mDataSource;
httpSource = mHttpSource;
}
diff --git a/media/libmediaplayerservice/nuplayer/GenericSource.h b/media/libmediaplayerservice/nuplayer/GenericSource.h
index bdcf706..c1d6e3e 100644
--- a/media/libmediaplayerservice/nuplayer/GenericSource.h
+++ b/media/libmediaplayerservice/nuplayer/GenericSource.h
@@ -137,6 +137,7 @@ protected:
int64_t mOffset;
int64_t mLength;
+ Mutex mSourceLock;
sp<DataSource> mDataSource;
sp<NuCachedSource2> mCachedSource;
sp<DataSource> mHttpSource;
@@ -154,7 +155,6 @@ protected:
int32_t mPrevBufferPercentage;
mutable Mutex mReadBufferLock;
- mutable Mutex mDisconnectLock;
sp<ALooper> mLooper;
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
index 9ca8c9f..98eff88 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
@@ -606,6 +606,14 @@ bool NuPlayer::Decoder::handleAnOutputBuffer(
reply->setSize("buffer-ix", index);
reply->setInt32("generation", mBufferGeneration);
+ if ((flags & MediaCodec::BUFFER_FLAG_DATACORRUPT) &&
+ AVNuUtils::get()->dropCorruptFrame()) {
+ ALOGV("[%s] dropping corrupt buffer at time %lld as requested.",
+ mComponentName.c_str(), (long long)timeUs);
+ reply->post();
+ return true;
+ }
+
if (eos) {
ALOGI("[%s] saw output EOS", mIsAudio ? "audio" : "video");
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index ebe8046..213d4e2 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -2098,7 +2098,11 @@ status_t ACodec::configureCodec(
}
err = setupG711Codec(encoder, sampleRate, numChannels);
}
+#ifdef QTI_FLAC_DECODER
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_FLAC) && encoder) {
+#else
+ } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_FLAC)) {
+#endif
int32_t numChannels = 0, sampleRate = 0, compressionLevel = -1;
if (encoder &&
(!msg->findInt32("channel-count", &numChannels)
diff --git a/media/libstagefright/Android.mk b/media/libstagefright/Android.mk
index 6c37819..5a75269 100644
--- a/media/libstagefright/Android.mk
+++ b/media/libstagefright/Android.mk
@@ -156,6 +156,11 @@ LOCAL_SHARED_LIBRARIES += \
LOCAL_CFLAGS += -Wno-multichar -Werror -Wno-error=deprecated-declarations -Wall
+ifeq ($(TARGET_USES_QCOM_BSP), true)
+ LOCAL_C_INCLUDES += $(call project-path-for,qcom-display)/libgralloc
+ LOCAL_CFLAGS += -DQTI_BSP
+endif
+
# enable experiments only in userdebug and eng builds
ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
LOCAL_CFLAGS += -DENABLE_STAGEFRIGHT_EXPERIMENTS
@@ -165,6 +170,12 @@ ifeq ($(TARGET_BOARD_PLATFORM),omap4)
LOCAL_CFLAGS += -DBOARD_CANT_REALLOCATE_OMX_BUFFERS
endif
+ifeq ($(call is-vendor-board-platform,QCOM),true)
+ifeq ($(strip $(AUDIO_FEATURE_ENABLED_EXTN_FLAC_DECODER)),true)
+ LOCAL_CFLAGS += -DQTI_FLAC_DECODER
+endif
+endif
+
LOCAL_CLANG := true
ifeq ($(BOARD_USE_SAMSUNG_CAMERAFORMAT_NV21), true)
diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp
index 926833f..7f7ddf7 100644
--- a/media/libstagefright/MPEG4Writer.cpp
+++ b/media/libstagefright/MPEG4Writer.cpp
@@ -2231,7 +2231,9 @@ status_t MPEG4Writer::Track::threadEntry() {
MediaBuffer *buffer;
const char *trackName = mIsAudio ? "Audio" : "Video";
while (!mDone && (err = mSource->read(&buffer)) == OK) {
- if (buffer->range_length() == 0) {
+ if (buffer == NULL) {
+ continue;
+ } else if (buffer->range_length() == 0) {
buffer->release();
buffer = NULL;
++nZeroLengthFrames;
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp
index 45e9a79..b6bea65 100644
--- a/media/libstagefright/MediaCodec.cpp
+++ b/media/libstagefright/MediaCodec.cpp
@@ -872,6 +872,8 @@ status_t MediaCodec::getBufferAndFormat(
}
*format = info.mFormat;
}
+ } else {
+ return BAD_INDEX;
}
return OK;
}
@@ -988,6 +990,9 @@ bool MediaCodec::handleDequeueOutputBuffer(const sp<AReplyToken> &replyID, bool
if (omxFlags & OMX_BUFFERFLAG_EXTRADATA) {
flags |= BUFFER_FLAG_EXTRADATA;
}
+ if (omxFlags & OMX_BUFFERFLAG_DATACORRUPT) {
+ flags |= BUFFER_FLAG_DATACORRUPT;
+ }
response->setInt32("flags", flags);
response->postReply(replyID);
@@ -2635,6 +2640,9 @@ void MediaCodec::onOutputBufferAvailable() {
if (omxFlags & OMX_BUFFERFLAG_EOS) {
flags |= BUFFER_FLAG_EOS;
}
+ if (omxFlags & OMX_BUFFERFLAG_DATACORRUPT) {
+ flags |= BUFFER_FLAG_DATACORRUPT;
+ }
msg->setInt32("flags", flags);
diff --git a/media/libstagefright/SurfaceMediaSource.cpp b/media/libstagefright/SurfaceMediaSource.cpp
index 7da5a9f..147eb45 100644
--- a/media/libstagefright/SurfaceMediaSource.cpp
+++ b/media/libstagefright/SurfaceMediaSource.cpp
@@ -35,6 +35,9 @@
#include <utils/String8.h>
#include <private/gui/ComposerService.h>
+#if QTI_BSP
+#include <gralloc_priv.h>
+#endif
namespace android {
@@ -59,8 +62,12 @@ SurfaceMediaSource::SurfaceMediaSource(uint32_t bufferWidth, uint32_t bufferHeig
BufferQueue::createBufferQueue(&mProducer, &mConsumer);
mConsumer->setDefaultBufferSize(bufferWidth, bufferHeight);
- mConsumer->setConsumerUsageBits(GRALLOC_USAGE_HW_VIDEO_ENCODER |
- GRALLOC_USAGE_HW_TEXTURE);
+ mConsumer->setConsumerUsageBits(GRALLOC_USAGE_HW_VIDEO_ENCODER
+ | GRALLOC_USAGE_HW_TEXTURE
+#if QTI_BSP
+ | GRALLOC_USAGE_PRIVATE_WFD
+#endif
+ );
sp<ISurfaceComposer> composer(ComposerService::getComposerService());
diff --git a/media/libstagefright/include/SimpleSoftOMXComponent.h b/media/libstagefright/include/SimpleSoftOMXComponent.h
index 591b38e..6a0a958 100644
--- a/media/libstagefright/include/SimpleSoftOMXComponent.h
+++ b/media/libstagefright/include/SimpleSoftOMXComponent.h
@@ -140,6 +140,7 @@ private:
void onPortFlush(OMX_U32 portIndex, bool sendFlushComplete);
void checkTransitions();
+ void onTransitionError();
DISALLOW_EVIL_CONSTRUCTORS(SimpleSoftOMXComponent);
};
diff --git a/media/libstagefright/omx/SimpleSoftOMXComponent.cpp b/media/libstagefright/omx/SimpleSoftOMXComponent.cpp
index e6a0c49..1fd0641 100644
--- a/media/libstagefright/omx/SimpleSoftOMXComponent.cpp
+++ b/media/libstagefright/omx/SimpleSoftOMXComponent.cpp
@@ -417,16 +417,43 @@ void SimpleSoftOMXComponent::onSendCommand(
}
}
+void SimpleSoftOMXComponent::onTransitionError() {
+ mState = OMX_StateInvalid;
+ mTargetState = OMX_StateInvalid;
+ notify(OMX_EventError, OMX_CommandStateSet, OMX_StateInvalid, 0);
+}
+
void SimpleSoftOMXComponent::onChangeState(OMX_STATETYPE state) {
+ bool skipTransitions = false;
+
// We shouldn't be in a state transition already.
- CHECK_EQ((int)mState, (int)mTargetState);
+ if (mState != mTargetState) {
+ // Workaround to prevent assertion
+ // XXX CHECK_EQ((int)mState, (int)mTargetState);
+ ALOGW("mState %d != mTargetState %d", mState, mTargetState);
+ skipTransitions = true;
+ onTransitionError();
+ }
switch (mState) {
case OMX_StateLoaded:
- CHECK_EQ((int)state, (int)OMX_StateIdle);
+ if (state != OMX_StateIdle) {
+ // Workaround to prevent assertion
+ // XXX CHECK_EQ((int)state, (int)OMX_StateIdle);
+ ALOGW("In OMX_StateLoaded, state %d != OMX_StateIdle", state);
+ skipTransitions = true;
+ onTransitionError();
+ }
break;
case OMX_StateIdle:
- CHECK(state == OMX_StateLoaded || state == OMX_StateExecuting);
+ if (!(state == OMX_StateLoaded || state == OMX_StateExecuting)) {
+ // Workaround to prevent assertion
+ // XXX CHECK(state == OMX_StateLoaded || state == OMX_StateExecuting);
+ ALOGW("In OMX_StateIdle, state %d != OMX_StateLoaded||OMX_StateExecuting",
+ state);
+ skipTransitions = true;
+ onTransitionError();
+ }
break;
case OMX_StateExecuting:
{
@@ -440,11 +467,20 @@ void SimpleSoftOMXComponent::onChangeState(OMX_STATETYPE state) {
notify(OMX_EventCmdComplete, OMX_CommandStateSet, state, NULL);
break;
}
-
+ case OMX_StateInvalid: {
+ ALOGW("In OMX_StateInvalid, ignore state transition to %d", state);
+ skipTransitions = true;
+ onTransitionError();
+ break;
+ }
default:
TRESPASS();
}
+ if (skipTransitions) {
+ return;
+ }
+
mTargetState = state;
checkTransitions();
diff --git a/services/audiopolicy/common/managerdefinitions/include/EffectDescriptor.h b/services/audiopolicy/common/managerdefinitions/include/EffectDescriptor.h
index c9783a1..396541b 100644
--- a/services/audiopolicy/common/managerdefinitions/include/EffectDescriptor.h
+++ b/services/audiopolicy/common/managerdefinitions/include/EffectDescriptor.h
@@ -21,6 +21,7 @@
#include <utils/KeyedVector.h>
#include <utils/RefBase.h>
#include <utils/Errors.h>
+#include <utils/Thread.h>
namespace android {
@@ -66,6 +67,8 @@ private:
* Maximum memory allocated to audio effects in KB
*/
static const uint32_t MAX_EFFECTS_MEMORY = 512;
+
+ Mutex mLock;
};
}; // namespace android
diff --git a/services/audiopolicy/common/managerdefinitions/src/EffectDescriptor.cpp b/services/audiopolicy/common/managerdefinitions/src/EffectDescriptor.cpp
index 33d838d..6a0d079 100644
--- a/services/audiopolicy/common/managerdefinitions/src/EffectDescriptor.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/EffectDescriptor.cpp
@@ -56,6 +56,7 @@ status_t EffectDescriptorCollection::registerEffect(const effect_descriptor_t *d
int session,
int id)
{
+ Mutex::Autolock _l(mLock);
if (mTotalEffectsMemory + desc->memoryUsage > getMaxEffectsMemory()) {
ALOGW("registerEffect() memory limit exceeded for Fx %s, Memory %d KB",
desc->name, desc->memoryUsage);
@@ -80,6 +81,7 @@ status_t EffectDescriptorCollection::registerEffect(const effect_descriptor_t *d
status_t EffectDescriptorCollection::unregisterEffect(int id)
{
+ Mutex::Autolock _l(mLock);
ssize_t index = indexOfKey(id);
if (index < 0) {
ALOGW("unregisterEffect() unknown effect ID %d", id);
@@ -106,6 +108,7 @@ status_t EffectDescriptorCollection::unregisterEffect(int id)
status_t EffectDescriptorCollection::setEffectEnabled(int id, bool enabled)
{
+ Mutex::Autolock _l(mLock);
ssize_t index = indexOfKey(id);
if (index < 0) {
ALOGW("unregisterEffect() unknown effect ID %d", id);
@@ -148,6 +151,7 @@ status_t EffectDescriptorCollection::setEffectEnabled(const sp<EffectDescriptor>
bool EffectDescriptorCollection::isNonOffloadableEffectEnabled()
{
+ Mutex::Autolock _l(mLock);
for (size_t i = 0; i < size(); i++) {
sp<EffectDescriptor> effectDesc = valueAt(i);
if (effectDesc->mEnabled && (effectDesc->mStrategy == STRATEGY_MEDIA) &&
@@ -172,6 +176,7 @@ uint32_t EffectDescriptorCollection::getMaxEffectsMemory() const
status_t EffectDescriptorCollection::dump(int fd)
{
+ Mutex::Autolock _l(mLock);
const size_t SIZE = 256;
char buffer[SIZE];
diff --git a/services/camera/libcameraservice/CameraFlashlight.cpp b/services/camera/libcameraservice/CameraFlashlight.cpp
index 280bb9d..fd23ef9 100644
--- a/services/camera/libcameraservice/CameraFlashlight.cpp
+++ b/services/camera/libcameraservice/CameraFlashlight.cpp
@@ -99,7 +99,8 @@ status_t CameraFlashlight::createFlashlightControl(const String8& cameraId) {
status_t CameraFlashlight::setTorchMode(const String8& cameraId, bool enabled) {
if (!mFlashlightMapInitialized) {
- ALOGE("%s: findFlashUnits() must be called before this method.");
+ ALOGE("%s: findFlashUnits() must be called before this method.",
+ __FUNCTION__);
return NO_INIT;
}
@@ -200,7 +201,8 @@ bool CameraFlashlight::hasFlashUnit(const String8& cameraId) {
bool CameraFlashlight::hasFlashUnitLocked(const String8& cameraId) {
if (!mFlashlightMapInitialized) {
- ALOGE("%s: findFlashUnits() must be called before this method.");
+ ALOGE("%s: findFlashUnits() must be called before this method.",
+ __FUNCTION__);
return false;
}
@@ -219,7 +221,8 @@ status_t CameraFlashlight::prepareDeviceOpen(const String8& cameraId) {
Mutex::Autolock l(mLock);
if (!mFlashlightMapInitialized) {
- ALOGE("%s: findFlashUnits() must be called before this method.");
+ ALOGE("%s: findFlashUnits() must be called before this method.",
+ __FUNCTION__);
return NO_INIT;
}
@@ -256,7 +259,8 @@ status_t CameraFlashlight::deviceClosed(const String8& cameraId) {
Mutex::Autolock l(mLock);
if (!mFlashlightMapInitialized) {
- ALOGE("%s: findFlashUnits() must be called before this method.");
+ ALOGE("%s: findFlashUnits() must be called before this method.",
+ __FUNCTION__);
return NO_INIT;
}