зеркало из https://github.com/mozilla/gecko-dev.git
Bug 812881 - Ensure OMX plugins instantiate only one OMXClient instance r=sotaro
Samsung's OMX IL doesn't like being instantiated more than once, often leading to crashes. This patch changes the OMX plugin so that we statically instantiate one OMXClient to be shared between decoder instances.
This commit is contained in:
Родитель
c934b681ac
Коммит
a92877be31
|
@ -65,9 +65,6 @@ const int OMX_TI_COLOR_FormatYUV420PackedSemiPlanar = 0x7F000100;
|
|||
class OmxDecoder {
|
||||
PluginHost *mPluginHost;
|
||||
Decoder *mDecoder;
|
||||
#ifndef MOZ_WIDGET_GONK
|
||||
OMXClient mClient;
|
||||
#endif
|
||||
sp<MediaSource> mVideoTrack;
|
||||
sp<MediaSource> mVideoSource;
|
||||
sp<MediaSource> mAudioTrack;
|
||||
|
@ -143,6 +140,39 @@ public:
|
|||
bool ReadAudio(AudioFrame *aFrame, int64_t aSeekTimeUs);
|
||||
};
|
||||
|
||||
#if !defined(MOZ_WIDGET_GONK)
|
||||
static class OmxClientInstance {
|
||||
public:
|
||||
OmxClientInstance()
|
||||
: mClient(new OMXClient())
|
||||
, mStatus(mClient->connect())
|
||||
{
|
||||
}
|
||||
|
||||
status_t IsValid()
|
||||
{
|
||||
return mStatus == OK;
|
||||
}
|
||||
|
||||
OMXClient *get()
|
||||
{
|
||||
return mClient;
|
||||
}
|
||||
|
||||
~OmxClientInstance()
|
||||
{
|
||||
if (mStatus == OK) {
|
||||
mClient->disconnect();
|
||||
}
|
||||
delete mClient;
|
||||
}
|
||||
|
||||
private:
|
||||
OMXClient *mClient;
|
||||
status_t mStatus;
|
||||
} sClientInstance;
|
||||
#endif
|
||||
|
||||
OmxDecoder::OmxDecoder(PluginHost *aPluginHost, Decoder *aDecoder) :
|
||||
mPluginHost(aPluginHost),
|
||||
mDecoder(aDecoder),
|
||||
|
@ -184,9 +214,6 @@ OmxDecoder::~OmxDecoder()
|
|||
delete mColorConverter;
|
||||
}
|
||||
#endif
|
||||
#ifndef MOZ_WIDGET_GONK
|
||||
mClient.disconnect();
|
||||
#endif
|
||||
}
|
||||
|
||||
class AutoStopMediaSource {
|
||||
|
@ -429,7 +456,18 @@ static sp<MediaSource> CreateVideoSource(PluginHost* aPluginHost,
|
|||
nullptr, flags);
|
||||
}
|
||||
|
||||
bool OmxDecoder::Init() {
|
||||
bool OmxDecoder::Init()
|
||||
{
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
// OMXClient::connect() always returns OK and aborts fatally if
|
||||
// it can't connect. We may need to implement the connect functionality
|
||||
// ourselves if this proves to be an issue.
|
||||
if (!sClientInstance.IsValid()) {
|
||||
LOG("OMXClient failed to connect");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
//register sniffers, if they are not registered in this process.
|
||||
DataSource::RegisterDefaultSniffers();
|
||||
|
||||
|
@ -475,13 +513,7 @@ bool OmxDecoder::Init() {
|
|||
#ifdef MOZ_WIDGET_GONK
|
||||
sp<IOMX> omx = GetOMX();
|
||||
#else
|
||||
// OMXClient::connect() always returns OK and abort's fatally if
|
||||
// it can't connect. We may need to implement the connect functionality
|
||||
// ourselves if this proves to be an issue.
|
||||
if (mClient.connect() != OK) {
|
||||
LOG("OMXClient failed to connect");
|
||||
}
|
||||
sp<IOMX> omx = mClient.interface();
|
||||
sp<IOMX> omx = sClientInstance.get()->interface();
|
||||
#endif
|
||||
|
||||
sp<MediaSource> videoTrack;
|
||||
|
|
Загрузка…
Ссылка в новой задаче