summaryrefslogtreecommitdiffstats
path: root/media/libstagefright
diff options
context:
space:
mode:
Diffstat (limited to 'media/libstagefright')
-rw-r--r--media/libstagefright/AwesomePlayer.cpp5
-rw-r--r--media/libstagefright/OMXCodec.cpp3
-rw-r--r--media/libstagefright/WVMExtractor.cpp22
-rw-r--r--media/libstagefright/chromium_http/support.cpp2
-rw-r--r--media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp27
-rw-r--r--media/libstagefright/include/SimpleSoftOMXComponent.h2
-rw-r--r--media/libstagefright/include/SoftOMXComponent.h2
-rw-r--r--media/libstagefright/include/WVMExtractor.h16
-rw-r--r--media/libstagefright/omx/SimpleSoftOMXComponent.cpp6
-rw-r--r--media/libstagefright/omx/SoftOMXPlugin.cpp4
10 files changed, 58 insertions, 31 deletions
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index fb7a871..70053ea 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -400,6 +400,7 @@ status_t AwesomePlayer::setDataSource_l(const sp<MediaExtractor> &extractor) {
}
void AwesomePlayer::reset() {
+ LOGI("reset");
Mutex::Autolock autoLock(mLock);
reset_l();
}
@@ -413,8 +414,10 @@ void AwesomePlayer::reset_l() {
Playback::STOP, 0);
mDecryptHandle = NULL;
mDrmManagerClient = NULL;
+ LOGI("DRM manager client stopped");
}
+
if (mFlags & PLAYING) {
uint32_t params = IMediaPlayerService::kBatteryDataTrackDecoder;
if ((mAudioSource != NULL) && (mAudioSource != mAudioTrack)) {
@@ -447,6 +450,7 @@ void AwesomePlayer::reset_l() {
mPreparedCondition.wait(mLock);
}
+ LOGI("cancel player events");
cancelPlayerEvents();
mWVMExtractor.clear();
@@ -1081,6 +1085,7 @@ void AwesomePlayer::shutdownVideoDecoder_l() {
usleep(1000);
}
IPCThreadState::self()->flushCommands();
+ LOGI("video decoder shutdown completed");
}
void AwesomePlayer::setNativeWindow_l(const sp<ANativeWindow> &native) {
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 0f0ffd4..ba495cc 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -3443,7 +3443,7 @@ status_t OMXCodec::start(MetaData *meta) {
}
status_t OMXCodec::stop() {
- CODEC_LOGV("stop mState=%d", mState);
+ CODEC_LOGI("stop mState=%d", mState);
Mutex::Autolock autoLock(mLock);
@@ -3505,6 +3505,7 @@ status_t OMXCodec::stop() {
mLeftOverBuffer = NULL;
}
+ CODEC_LOGI("stopping video source");
mSource->stop();
CODEC_LOGI("stopped in state %d", mState);
diff --git a/media/libstagefright/WVMExtractor.cpp b/media/libstagefright/WVMExtractor.cpp
index 83a1eaa..26eda0c 100644
--- a/media/libstagefright/WVMExtractor.cpp
+++ b/media/libstagefright/WVMExtractor.cpp
@@ -45,8 +45,7 @@ namespace android {
static Mutex gWVMutex;
WVMExtractor::WVMExtractor(const sp<DataSource> &source)
- : mDataSource(source),
- mUseAdaptiveStreaming(false) {
+ : mDataSource(source) {
{
Mutex::Autolock autoLock(gWVMutex);
if (gVendorLibHandle == NULL) {
@@ -59,13 +58,12 @@ WVMExtractor::WVMExtractor(const sp<DataSource> &source)
}
}
- typedef MediaExtractor *(*GetInstanceFunc)(sp<DataSource>);
+ typedef WVMLoadableExtractor *(*GetInstanceFunc)(sp<DataSource>);
GetInstanceFunc getInstanceFunc =
(GetInstanceFunc) dlsym(gVendorLibHandle,
"_ZN7android11GetInstanceENS_2spINS_10DataSourceEEE");
if (getInstanceFunc) {
- LOGD("Calling GetInstanceFunc");
mImpl = (*getInstanceFunc)(source);
CHECK(mImpl != NULL);
} else {
@@ -102,19 +100,17 @@ sp<MetaData> WVMExtractor::getMetaData() {
}
int64_t WVMExtractor::getCachedDurationUs(status_t *finalStatus) {
- // TODO: Fill this with life.
-
- *finalStatus = OK;
+ if (mImpl == NULL) {
+ return 0;
+ }
- return 0;
+ return mImpl->getCachedDurationUs(finalStatus);
}
void WVMExtractor::setAdaptiveStreamingMode(bool adaptive) {
- mUseAdaptiveStreaming = adaptive;
-}
-
-bool WVMExtractor::getAdaptiveStreamingMode() const {
- return mUseAdaptiveStreaming;
+ if (mImpl != NULL) {
+ mImpl->setAdaptiveStreamingMode(adaptive);
+ }
}
} //namespace android
diff --git a/media/libstagefright/chromium_http/support.cpp b/media/libstagefright/chromium_http/support.cpp
index 3e4e493..805bd48 100644
--- a/media/libstagefright/chromium_http/support.cpp
+++ b/media/libstagefright/chromium_http/support.cpp
@@ -23,7 +23,7 @@
#include "support.h"
#include "android/net/android_network_library_impl.h"
-#include "base/thread.h"
+#include "base/threading/thread.h"
#include "net/base/cert_verifier.h"
#include "net/base/host_resolver.h"
#include "net/base/ssl_config_service.h"
diff --git a/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp b/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp
index 13e1662..cffbfb5 100644
--- a/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp
+++ b/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp
@@ -360,10 +360,14 @@ void SoftMPEG4::onQueueFilled(OMX_U32 portIndex) {
mFramesConfigured = true;
}
- uint32_t timestamp = 0xFFFFFFFF;
+ uint32_t useExtTimestamp = (inHeader->nOffset == 0);
+
+ // decoder deals in ms, OMX in us.
+ uint32_t timestamp =
+ useExtTimestamp ? (inHeader->nTimeStamp + 500) / 1000 : 0xFFFFFFFF;
+
int32_t bufferSize = inHeader->nFilledLen;
- uint32_t useExtTimestamp = 0;
if (PVDecodeVideoFrame(
mHandle, &bitstream, &timestamp, &bufferSize,
&useExtTimestamp,
@@ -379,13 +383,20 @@ void SoftMPEG4::onQueueFilled(OMX_U32 portIndex) {
return;
}
- outHeader->nTimeStamp = inHeader->nTimeStamp;
+ // decoder deals in ms, OMX in us.
+ outHeader->nTimeStamp = timestamp * 1000;
- inInfo->mOwnedByUs = false;
- inQueue.erase(inQueue.begin());
- inInfo = NULL;
- notifyEmptyBufferDone(inHeader);
- inHeader = NULL;
+ CHECK_LE(bufferSize, inHeader->nFilledLen);
+ inHeader->nOffset += inHeader->nFilledLen - bufferSize;
+ inHeader->nFilledLen = bufferSize;
+
+ if (inHeader->nFilledLen == 0) {
+ inInfo->mOwnedByUs = false;
+ inQueue.erase(inQueue.begin());
+ inInfo = NULL;
+ notifyEmptyBufferDone(inHeader);
+ inHeader = NULL;
+ }
++mInputBufferCount;
diff --git a/media/libstagefright/include/SimpleSoftOMXComponent.h b/media/libstagefright/include/SimpleSoftOMXComponent.h
index 2a29a7d..50cd275 100644
--- a/media/libstagefright/include/SimpleSoftOMXComponent.h
+++ b/media/libstagefright/include/SimpleSoftOMXComponent.h
@@ -36,7 +36,7 @@ struct SimpleSoftOMXComponent : public SoftOMXComponent {
OMX_PTR appData,
OMX_COMPONENTTYPE **component);
- virtual ~SimpleSoftOMXComponent();
+ virtual void prepareForDestruction();
void onMessageReceived(const sp<AMessage> &msg);
diff --git a/media/libstagefright/include/SoftOMXComponent.h b/media/libstagefright/include/SoftOMXComponent.h
index 053bc22..a808611 100644
--- a/media/libstagefright/include/SoftOMXComponent.h
+++ b/media/libstagefright/include/SoftOMXComponent.h
@@ -38,6 +38,8 @@ struct SoftOMXComponent : public RefBase {
void setLibHandle(void *libHandle);
void *libHandle() const;
+ virtual void prepareForDestruction() {}
+
protected:
virtual ~SoftOMXComponent();
diff --git a/media/libstagefright/include/WVMExtractor.h b/media/libstagefright/include/WVMExtractor.h
index 62e5aa5..deecd25 100644
--- a/media/libstagefright/include/WVMExtractor.h
+++ b/media/libstagefright/include/WVMExtractor.h
@@ -25,6 +25,15 @@ namespace android {
class DataSource;
+class WVMLoadableExtractor : public MediaExtractor {
+public:
+ WVMLoadableExtractor() {}
+ virtual ~WVMLoadableExtractor() {}
+
+ virtual int64_t getCachedDurationUs(status_t *finalStatus) = 0;
+ virtual void setAdaptiveStreamingMode(bool adaptive) = 0;
+};
+
class WVMExtractor : public MediaExtractor {
public:
WVMExtractor(const sp<DataSource> &source);
@@ -49,20 +58,15 @@ public:
// is used.
void setAdaptiveStreamingMode(bool adaptive);
- // Retrieve the adaptive streaming mode used by the WV component.
- bool getAdaptiveStreamingMode() const;
-
protected:
virtual ~WVMExtractor();
private:
sp<DataSource> mDataSource;
- sp<MediaExtractor> mImpl;
- bool mUseAdaptiveStreaming;
+ sp<WVMLoadableExtractor> mImpl;
WVMExtractor(const WVMExtractor &);
WVMExtractor &operator=(const WVMExtractor &);
-
};
} // namespace android
diff --git a/media/libstagefright/omx/SimpleSoftOMXComponent.cpp b/media/libstagefright/omx/SimpleSoftOMXComponent.cpp
index 179b2a0..f7330f3 100644
--- a/media/libstagefright/omx/SimpleSoftOMXComponent.cpp
+++ b/media/libstagefright/omx/SimpleSoftOMXComponent.cpp
@@ -45,7 +45,11 @@ SimpleSoftOMXComponent::SimpleSoftOMXComponent(
PRIORITY_AUDIO);
}
-SimpleSoftOMXComponent::~SimpleSoftOMXComponent() {
+void SimpleSoftOMXComponent::prepareForDestruction() {
+ // The looper's queue may still contain messages referencing this
+ // object. Make sure those are flushed before returning so that
+ // a subsequent dlunload() does not pull out the rug from under us.
+
mLooper->unregisterHandler(mHandler->id());
mLooper->stop();
}
diff --git a/media/libstagefright/omx/SoftOMXPlugin.cpp b/media/libstagefright/omx/SoftOMXPlugin.cpp
index 6bd6624..04ca39e 100644
--- a/media/libstagefright/omx/SoftOMXPlugin.cpp
+++ b/media/libstagefright/omx/SoftOMXPlugin.cpp
@@ -21,6 +21,7 @@
#include "SoftOMXPlugin.h"
#include "include/SoftOMXComponent.h"
+#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AString.h>
#include <dlfcn.h>
@@ -126,8 +127,11 @@ OMX_ERRORTYPE SoftOMXPlugin::destroyComponentInstance(
(SoftOMXComponent *)
((OMX_COMPONENTTYPE *)component)->pComponentPrivate;
+ me->prepareForDestruction();
+
void *libHandle = me->libHandle();
+ CHECK_EQ(me->getStrongCount(), 1);
me->decStrong(this);
me = NULL;