Backed out changeset 01abd1d12b2c (bug 1155432) for Windows build bustage

CLOSED TREE
This commit is contained in:
Phil Ringnalda 2015-04-19 22:42:22 -07:00
Родитель c4b402a786
Коммит e6cf21241e
2 изменённых файлов: 34 добавлений и 91 удалений

Просмотреть файл

@ -27,14 +27,13 @@ WMFMediaDataDecoder::WMFMediaDataDecoder(MFTManager* aMFTManager,
: mTaskQueue(aTaskQueue)
, mCallback(aCallback)
, mMFTManager(aMFTManager)
, mMonitor("WMFMediaDataDecoder")
, mIsDecodeTaskDispatched(false)
, mIsFlushing(false)
{
MOZ_COUNT_CTOR(WMFMediaDataDecoder);
}
WMFMediaDataDecoder::~WMFMediaDataDecoder()
{
MOZ_COUNT_DTOR(WMFMediaDataDecoder);
}
nsresult
@ -49,17 +48,12 @@ WMFMediaDataDecoder::Init()
nsresult
WMFMediaDataDecoder::Shutdown()
{
nsresult rv = mTaskQueue->Dispatch(
DebugOnly<nsresult> rv = mTaskQueue->FlushAndDispatch(
NS_NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessShutdown));
#ifdef DEBUG
if (NS_FAILED(rv)) {
NS_WARNING("WMFMediaDataDecoder::Shutdown() dispatch of task failed!");
}
{
MonitorAutoLock mon(mMonitor);
// The MP4Reader should have flushed before calling Shutdown().
MOZ_ASSERT(!mIsDecodeTaskDispatched);
}
#endif
return NS_OK;
}
@ -67,73 +61,36 @@ WMFMediaDataDecoder::Shutdown()
void
WMFMediaDataDecoder::ProcessShutdown()
{
if (mMFTManager) {
mMFTManager->Shutdown();
mMFTManager = nullptr;
}
mMFTManager->Shutdown();
mMFTManager = nullptr;
mDecoder = nullptr;
}
void
WMFMediaDataDecoder::EnsureDecodeTaskDispatched()
{
mMonitor.AssertCurrentThreadOwns();
if (!mIsDecodeTaskDispatched) {
mTaskQueue->Dispatch(
NS_NewRunnableMethod(this,
&WMFMediaDataDecoder::Decode));
mIsDecodeTaskDispatched = true;
}
}
// Inserts data into the decoder's pipeline.
nsresult
WMFMediaDataDecoder::Input(MediaRawData* aSample)
{
MonitorAutoLock mon(mMonitor);
mInput.push(aSample);
EnsureDecodeTaskDispatched();
mTaskQueue->Dispatch(
NS_NewRunnableMethodWithArg<nsRefPtr<MediaRawData>>(
this,
&WMFMediaDataDecoder::ProcessDecode,
nsRefPtr<MediaRawData>(aSample)));
return NS_OK;
}
void
WMFMediaDataDecoder::Decode()
WMFMediaDataDecoder::ProcessDecode(MediaRawData* aSample)
{
while (true) {
nsRefPtr<MediaRawData> input;
{
MonitorAutoLock mon(mMonitor);
MOZ_ASSERT(mIsDecodeTaskDispatched);
if (mInput.empty()) {
if (mIsFlushing) {
if (mDecoder) {
mDecoder->Flush();
}
mIsFlushing = false;
}
mIsDecodeTaskDispatched = false;
mon.NotifyAll();
return;
}
input = mInput.front();
mInput.pop();
}
HRESULT hr = mMFTManager->Input(input);
if (FAILED(hr)) {
NS_WARNING("MFTManager rejected sample");
{
MonitorAutoLock mon(mMonitor);
PurgeInputQueue();
}
mCallback->Error();
return;
}
mLastStreamOffset = input->mOffset;
ProcessOutput();
HRESULT hr = mMFTManager->Input(aSample);
if (FAILED(hr)) {
NS_WARNING("MFTManager rejected sample");
mCallback->Error();
return;
}
mLastStreamOffset = aSample->mOffset;
ProcessOutput();
}
void
@ -151,33 +108,24 @@ WMFMediaDataDecoder::ProcessOutput()
}
} else if (FAILED(hr)) {
NS_WARNING("WMFMediaDataDecoder failed to output data");
{
MonitorAutoLock mon(mMonitor);
PurgeInputQueue();
}
mCallback->Error();
}
}
void
WMFMediaDataDecoder::PurgeInputQueue()
{
mMonitor.AssertCurrentThreadOwns();
while (!mInput.empty()) {
mInput.pop();
}
}
nsresult
WMFMediaDataDecoder::Flush()
{
MonitorAutoLock mon(mMonitor);
PurgeInputQueue();
mIsFlushing = true;
EnsureDecodeTaskDispatched();
while (mIsDecodeTaskDispatched || mIsFlushing) {
mon.Wait();
}
// Flush the input task queue. This cancels all pending Decode() calls.
// Note this blocks until the task queue finishes its current job, if
// it's executing at all. Note the MP4Reader ignores all output while
// flushing.
mTaskQueue->Flush();
// Order the MFT to flush; drop all internal data.
NS_ENSURE_TRUE(mDecoder, NS_ERROR_FAILURE);
HRESULT hr = mDecoder->Flush();
NS_ENSURE_TRUE(SUCCEEDED(hr), NS_ERROR_FAILURE);
return NS_OK;
}

Просмотреть файл

@ -74,9 +74,9 @@ public:
private:
void Decode();
void EnsureDecodeTaskDispatched();
void PurgeInputQueue();
// Called on the task queue. Inserts the sample into the decoder, and
// extracts output if available.
void ProcessDecode(MediaRawData* aSample);
// Called on the task queue. Extracts output if available, and delivers
// it to the reader. Called after ProcessDecode() and ProcessDrain().
@ -97,11 +97,6 @@ private:
// The last offset into the media resource that was passed into Input().
// This is used to approximate the decoder's position in the media resource.
int64_t mLastStreamOffset;
Monitor mMonitor;
std::queue<nsRefPtr<MediaRawData>> mInput;
bool mIsDecodeTaskDispatched;
bool mIsFlushing;
};
} // namespace mozilla