Backed out changeset 66710416d1e4 (bug 1562910) for MinGW bustages. CLOSED TREE

This commit is contained in:
Brindusan Cristian 2019-08-02 22:09:39 +03:00
parent 0b3e26149c
commit f58c7a50ae
7 changed files with 19 additions and 65 deletions

View File

@ -24,9 +24,6 @@ struct MediaRawDataIPDL
MediaDataIPDL base;
bool eos;
uint32_t discardPadding;
// Pass along buffer size since we're using ShmemPool
// and we can receive buffers larger than requested size.
int64_t bufferSize;
Shmem buffer;
};

View File

@ -31,9 +31,6 @@ struct RemoteAudioDataIPDL
uint32_t channels;
uint32_t rate;
uint32_t channelMap;
// Pass along buffer size since we're using ShmemPool
// and we can receive buffers larger than requested size.
int64_t audioDataBufferSize;
Shmem buffer;
};
@ -57,8 +54,6 @@ parent:
async Input(MediaRawDataIPDL data);
async DoneWithOutput(Shmem outputShmem);
async Flush();
async Drain();
async Shutdown();
@ -76,8 +71,6 @@ child:
async FlushComplete();
async ShutdownComplete();
async DoneWithInput(Shmem inputShmem);
// Each output may include a SurfaceDescriptorGPUVideo that represents the decoded
// frame. This SurfaceDescriptor can be used on the Layers IPDL protocol, but
// must be released explicitly using DeallocateSurfaceDescriptorGPUVideo

View File

@ -23,15 +23,11 @@ mozilla::ipc::IPCResult RemoteAudioDecoderChild::RecvOutput(
const RemoteAudioDataIPDL& aData = aDecodedData.get_RemoteAudioDataIPDL();
AlignedAudioBuffer alignedAudioBuffer;
// Use std::min to make sure we can't overrun our buffer in case someone is
// fibbing about buffer sizes.
alignedAudioBuffer.SetLength(
std::min((unsigned long)aData.audioDataBufferSize(),
(unsigned long)aData.buffer().Size<AudioDataValue>()));
alignedAudioBuffer.SetLength(aData.buffer().Size<AudioDataValue>());
PodCopy(alignedAudioBuffer.Data(), aData.buffer().get<AudioDataValue>(),
alignedAudioBuffer.Length());
Unused << SendDoneWithOutput(std::move(aData.buffer()));
DeallocShmem(aData.buffer());
RefPtr<AudioData> audio = new AudioData(
aData.base().offset(), aData.base().time(), std::move(alignedAudioBuffer),
@ -114,27 +110,26 @@ MediaResult RemoteAudioDecoderParent::ProcessDecodedData(
"Decoded audio must output an AlignedAudioBuffer "
"to be used with RemoteAudioDecoderParent");
ShmemBuffer buffer = mDecodedFramePool.Get(
this, audio->Data().Length() * sizeof(AudioDataValue));
if (!buffer.Valid()) {
Shmem buffer;
if (!AllocShmem(audio->Data().Length() * sizeof(AudioDataValue),
Shmem::SharedMemory::TYPE_BASIC, &buffer)) {
return MediaResult(NS_ERROR_OUT_OF_MEMORY,
"ShmemBuffer::Get failed in "
"AllocShmem failed in "
"RemoteAudioDecoderParent::ProcessDecodedData");
}
if (audio->Data().Length() > buffer.Get().Size<AudioDataValue>()) {
if (audio->Data().Length() > buffer.Size<AudioDataValue>()) {
return MediaResult(NS_ERROR_OUT_OF_MEMORY,
"ShmemBuffer::Get returned less than requested in "
"AllocShmem returned less than requested in "
"RemoteAudioDecoderParent::ProcessDecodedData");
}
PodCopy(buffer.Get().get<AudioDataValue>(), audio->Data().Elements(),
PodCopy(buffer.get<AudioDataValue>(), audio->Data().Elements(),
audio->Data().Length());
RemoteAudioDataIPDL output(
MediaDataIPDL(data->mOffset, data->mTime, data->mTimecode,
data->mDuration, data->mKeyframe),
audio->mChannels, audio->mRate, audio->mChannelMap,
audio->Data().Length(), std::move(buffer.Get()));
audio->mChannels, audio->mRate, audio->mChannelMap, std::move(buffer));
Unused << SendOutput(output);
}

View File

@ -11,8 +11,7 @@ namespace mozilla {
RemoteDecoderChild::RemoteDecoderChild(bool aRecreatedOnCrash)
: mThread(RemoteDecoderManagerChild::GetManagerThread()),
mRecreatedOnCrash(aRecreatedOnCrash),
mRawFramePool(4) {}
mRecreatedOnCrash(aRecreatedOnCrash) {}
RemoteDecoderChild::~RemoteDecoderChild() {
AssertOnManagerThread();
@ -81,12 +80,6 @@ mozilla::ipc::IPCResult RemoteDecoderChild::RecvShutdownComplete() {
return IPC_OK();
}
mozilla::ipc::IPCResult RemoteDecoderChild::RecvDoneWithInput(
Shmem&& aInputShmem) {
mRawFramePool.Put(ShmemBuffer(aInputShmem));
return IPC_OK();
}
void RemoteDecoderChild::ActorDestroy(ActorDestroyReason aWhy) {
MOZ_ASSERT(mCanSend);
// If the IPC channel is gone pending promises need to be resolved/rejected.
@ -129,7 +122,6 @@ void RemoteDecoderChild::ActorDestroy(ActorDestroyReason aWhy) {
}
}
mCanSend = false;
mRawFramePool.Cleanup(this);
RecordShutdownTelemetry(aWhy == AbnormalShutdown);
}
@ -190,20 +182,18 @@ RefPtr<MediaDataDecoder::DecodePromise> RemoteDecoderChild::Decode(
// TODO: It would be nice to add an allocator method to
// MediaDataDecoder so that the demuxer could write directly
// into shmem rather than requiring a copy here.
ShmemBuffer buffer = mRawFramePool.Get(this, aSample->Size());
if (!buffer.Valid()) {
Shmem buffer;
if (!AllocShmem(aSample->Size(), Shmem::SharedMemory::TYPE_BASIC, &buffer)) {
return MediaDataDecoder::DecodePromise::CreateAndReject(
NS_ERROR_DOM_MEDIA_DECODE_ERR, __func__);
}
memcpy(buffer.Get().get<uint8_t>(), aSample->Data(), aSample->Size());
memcpy(buffer.get<uint8_t>(), aSample->Data(), aSample->Size());
MediaRawDataIPDL sample(
MediaDataIPDL(aSample->mOffset, aSample->mTime, aSample->mTimecode,
aSample->mDuration, aSample->mKeyframe),
aSample->mEOS, aSample->mDiscardPadding, aSample->Size(),
std::move(buffer.Get()));
aSample->mEOS, aSample->mDiscardPadding, std::move(buffer));
SendInput(sample);
return mDecodePromise.Ensure(__func__);

View File

@ -6,9 +6,7 @@
#ifndef include_dom_media_ipc_RemoteDecoderChild_h
#define include_dom_media_ipc_RemoteDecoderChild_h
#include "mozilla/PRemoteDecoderChild.h"
#include "IRemoteDecoderChild.h"
#include "mozilla/ShmemPool.h"
namespace mozilla {
@ -36,7 +34,6 @@ class RemoteDecoderChild : public PRemoteDecoderChild,
IPCResult RecvInitFailed(const nsresult& aReason);
IPCResult RecvFlushComplete();
IPCResult RecvShutdownComplete();
IPCResult RecvDoneWithInput(Shmem&& aInputShmem);
void ActorDestroy(ActorDestroyReason aWhy) override;
@ -92,7 +89,6 @@ class RemoteDecoderChild : public PRemoteDecoderChild,
// Keep this instance alive during SendShutdown RecvShutdownComplete
// handshake.
RefPtr<RemoteDecoderChild> mShutdownSelfRef;
ShmemPool mRawFramePool;
};
} // namespace mozilla

View File

@ -18,8 +18,7 @@ RemoteDecoderParent::RemoteDecoderParent(RemoteDecoderManagerParent* aParent,
TaskQueue* aDecodeTaskQueue)
: mParent(aParent),
mManagerTaskQueue(aManagerTaskQueue),
mDecodeTaskQueue(aDecodeTaskQueue),
mDecodedFramePool(4) {
mDecodeTaskQueue(aDecodeTaskQueue) {
MOZ_COUNT_CTOR(RemoteDecoderParent);
MOZ_ASSERT(OnManagerThread());
// We hold a reference to ourselves to keep us alive until IPDL
@ -69,12 +68,8 @@ mozilla::ipc::IPCResult RemoteDecoderParent::RecvInput(
MOZ_ASSERT(OnManagerThread());
// XXX: This copies the data into a buffer owned by the MediaRawData. Ideally
// we'd just take ownership of the shmem.
// Use the passed bufferSize in MediaRawDataIPDL since we can get a Shmem
// buffer from ShmemPool larger than the requested size.
RefPtr<MediaRawData> data =
new MediaRawData(aData.buffer().get<uint8_t>(),
std::min((unsigned long)aData.bufferSize(),
(unsigned long)aData.buffer().Size<uint8_t>()));
RefPtr<MediaRawData> data = new MediaRawData(aData.buffer().get<uint8_t>(),
aData.buffer().Size<uint8_t>());
if (aData.buffer().Size<uint8_t>() && !data->Data()) {
// OOM
Error(NS_ERROR_OUT_OF_MEMORY);
@ -88,8 +83,7 @@ mozilla::ipc::IPCResult RemoteDecoderParent::RecvInput(
data->mEOS = aData.eos();
data->mDiscardPadding = aData.discardPadding();
// Send back to the child to reuse in ShmemPool
Unused << SendDoneWithInput(std::move(aData.buffer()));
DeallocShmem(aData.buffer());
RefPtr<RemoteDecoderParent> self = this;
mDecoder->Decode(data)->Then(
@ -171,12 +165,6 @@ mozilla::ipc::IPCResult RemoteDecoderParent::RecvSetSeekThreshold(
return IPC_OK();
}
mozilla::ipc::IPCResult RemoteDecoderParent::RecvDoneWithOutput(
Shmem&& aOutputShmem) {
mDecodedFramePool.Put(ShmemBuffer(aOutputShmem));
return IPC_OK();
}
void RemoteDecoderParent::ActorDestroy(ActorDestroyReason aWhy) {
MOZ_ASSERT(!mDestroyed);
MOZ_ASSERT(OnManagerThread());
@ -184,7 +172,6 @@ void RemoteDecoderParent::ActorDestroy(ActorDestroyReason aWhy) {
mDecoder->Shutdown();
mDecoder = nullptr;
}
mDecodedFramePool.Cleanup(this);
}
void RemoteDecoderParent::Error(const MediaResult& aError) {

View File

@ -7,8 +7,6 @@
#define include_dom_media_ipc_RemoteDecoderParent_h
#include "mozilla/PRemoteDecoderParent.h"
#include "mozilla/ShmemPool.h"
namespace mozilla {
class RemoteDecoderManagerParent;
@ -35,7 +33,6 @@ class RemoteDecoderParent : public PRemoteDecoderParent {
IPCResult RecvDrain();
IPCResult RecvShutdown();
IPCResult RecvSetSeekThreshold(const media::TimeUnit& aTime);
IPCResult RecvDoneWithOutput(Shmem&& aOutputShmem);
void ActorDestroy(ActorDestroyReason aWhy) override;
@ -56,7 +53,6 @@ class RemoteDecoderParent : public PRemoteDecoderParent {
// Can only be accessed from the manager thread
bool mDestroyed = false;
ShmemPool mDecodedFramePool;
};
} // namespace mozilla