Commit 3599b7a3 authored by Kenneth Russell's avatar Kenneth Russell Committed by Commit Bot

Revert "Reland "Call MFShutdown in places where MFStartup is called""

This reverts commit 5019665f.

Reason for revert: broke capture_unittests on chromeos-amd64-generic-rel per http://crbug.com/1048934

Original change's description:
> Reland "Call MFShutdown in places where MFStartup is called"
> 
> This reverts commit 5be12bf8.
> 
> Reason for revert: Fixing the issue, and running on more trybots
> 
> Original change's description:
> > Revert "Call MFShutdown in places where MFStartup is called"
> > 
> > This reverts commit abf9a1f5.
> > 
> > Reason for revert: Broke tests on Win7 dbg, see linked bug
> > 
> > Original change's description:
> > > Call MFShutdown in places where MFStartup is called
> > > 
> > > Bug: 1012527
> > > Fixed: 1012527
> > > Change-Id: Id9ef248aadb0aa24704dec973b60ea23c9e1f1ed
> > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2032332
> > > Commit-Queue: Ted Meyer <tmathmeyer@chromium.org>
> > > Reviewed-by: Xiaohan Wang <xhwang@chromium.org>
> > > Cr-Commit-Position: refs/heads/master@{#738063}
> > 
> > TBR=xhwang@chromium.org,tmathmeyer@chromium.org
> > 
> > Change-Id: I267213cc06b42769736c7eb337432ade7953de20
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: 1012527
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2036057
> > Reviewed-by: Marc Treib <treib@chromium.org>
> > Commit-Queue: Marc Treib <treib@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#738130}
> 
> TBR=xhwang@chromium.org,treib@chromium.org,tmathmeyer@chromium.org
> 
> Change-Id: I8f87e933e133d0dcbf9904c002af7738af450f41
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 1012527
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2037811
> Reviewed-by: Xiaohan Wang <xhwang@chromium.org>
> Commit-Queue: Ted Meyer <tmathmeyer@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#738344}

TBR=xhwang@chromium.org,treib@chromium.org,tmathmeyer@chromium.org

Change-Id: Ieba1f172a5a2bed58e338f15c638c6deae8b0685
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1012527, 1048934
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2037855Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738410}
parent 5592e2ed
...@@ -25,7 +25,7 @@ class DXGIDeviceScopedHandleTest : public testing::Test { ...@@ -25,7 +25,7 @@ class DXGIDeviceScopedHandleTest : public testing::Test {
if (!test_supported_) if (!test_supported_)
return; return;
ASSERT_NE(nullptr, session_ = InitializeMediaFoundation()); ASSERT_TRUE(InitializeMediaFoundation());
// Get a shared DXGI Device Manager from Media Foundation. // Get a shared DXGI Device Manager from Media Foundation.
ASSERT_HRESULT_SUCCEEDED( ASSERT_HRESULT_SUCCEEDED(
...@@ -60,7 +60,6 @@ class DXGIDeviceScopedHandleTest : public testing::Test { ...@@ -60,7 +60,6 @@ class DXGIDeviceScopedHandleTest : public testing::Test {
} }
} }
MFSessionLifetime session_;
Microsoft::WRL::ComPtr<IMFDXGIDeviceManager> dxgi_device_man_ = nullptr; Microsoft::WRL::ComPtr<IMFDXGIDeviceManager> dxgi_device_man_ = nullptr;
UINT device_reset_token_ = 0; UINT device_reset_token_ = 0;
const bool test_supported_; const bool test_supported_;
......
...@@ -8,19 +8,13 @@ ...@@ -8,19 +8,13 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/optional.h"
namespace media { namespace media {
MFSessionLifetime InitializeMediaFoundation() { bool InitializeMediaFoundation() {
if (MFStartup(MF_VERSION, MFSTARTUP_LITE) == S_OK) static const bool success = MFStartup(MF_VERSION, MFSTARTUP_LITE) == S_OK;
return std::make_unique<MFSession>(); DVLOG_IF(1, !success)
DVLOG(1) << "Media Foundation unavailable or it failed to initialize"; << "Media Foundation unavailable or it failed to initialize";
return nullptr; return success;
}
MFSession::~MFSession() {
MFShutdown();
} }
} // namespace media } // namespace media
...@@ -5,25 +5,15 @@ ...@@ -5,25 +5,15 @@
#ifndef MEDIA_BASE_WIN_MF_INITIALIZER_H_ #ifndef MEDIA_BASE_WIN_MF_INITIALIZER_H_
#define MEDIA_BASE_WIN_MF_INITIALIZER_H_ #define MEDIA_BASE_WIN_MF_INITIALIZER_H_
#include <mfapi.h>
#include "base/logging.h"
#include "media/base/win/mf_initializer_export.h" #include "media/base/win/mf_initializer_export.h"
namespace media { namespace media {
// Handy-dandy wrapper struct that kills MediaFoundation on destruction. // Makes sure MFStartup() is called exactly once. Returns true if Media
struct MF_INITIALIZER_EXPORT MFSession { // Foundation is available and has been initialized successfully. Note that it
~MFSession(); // is expected to return false on an "N" edition of Windows, see
}; // https://en.wikipedia.org/wiki/Windows_7_editions#Special-purpose_editions.
MF_INITIALIZER_EXPORT bool InitializeMediaFoundation();
using MFSessionLifetime = std::unique_ptr<MFSession>;
// Make sure that MFShutdown is called for each MFStartup that is successful.
// The public documentation stating that it needs to have a corresponding
// shutdown for all startups (even failed ones) is wrong.
MF_INITIALIZER_EXPORT MFSessionLifetime InitializeMediaFoundation()
WARN_UNUSED_RESULT;
} // namespace media } // namespace media
......
...@@ -146,8 +146,10 @@ bool PrepareVideoCaptureAttributesMediaFoundation( ...@@ -146,8 +146,10 @@ bool PrepareVideoCaptureAttributesMediaFoundation(
// Once https://bugs.chromium.org/p/chromium/issues/detail?id=791615 is fixed, // Once https://bugs.chromium.org/p/chromium/issues/detail?id=791615 is fixed,
// we must make sure that this method succeeds in capture_unittests context // we must make sure that this method succeeds in capture_unittests context
// when MediaFoundation is enabled. // when MediaFoundation is enabled.
if (!VideoCaptureDeviceFactoryWin::PlatformSupportsMediaFoundation()) if (!VideoCaptureDeviceFactoryWin::PlatformSupportsMediaFoundation() ||
!InitializeMediaFoundation()) {
return false; return false;
}
if (FAILED(MFCreateAttributes(attributes, count))) if (FAILED(MFCreateAttributes(attributes, count)))
return false; return false;
...@@ -380,7 +382,6 @@ VideoCaptureDeviceFactoryWin::VideoCaptureDeviceFactoryWin() ...@@ -380,7 +382,6 @@ VideoCaptureDeviceFactoryWin::VideoCaptureDeviceFactoryWin()
LogVideoCaptureWinBackendUsed( LogVideoCaptureWinBackendUsed(
VideoCaptureWinBackendUsed::kUsingDirectShowAsFallback); VideoCaptureWinBackendUsed::kUsingDirectShowAsFallback);
} else if (use_media_foundation_) { } else if (use_media_foundation_) {
session_ = InitializeMediaFoundation();
LogVideoCaptureWinBackendUsed( LogVideoCaptureWinBackendUsed(
VideoCaptureWinBackendUsed::kUsingMediaFoundationAsDefault); VideoCaptureWinBackendUsed::kUsingMediaFoundationAsDefault);
} else { } else {
...@@ -435,8 +436,7 @@ void VideoCaptureDeviceFactoryWin::GetDeviceDescriptors( ...@@ -435,8 +436,7 @@ void VideoCaptureDeviceFactoryWin::GetDeviceDescriptors(
VideoCaptureDeviceDescriptors* device_descriptors) { VideoCaptureDeviceDescriptors* device_descriptors) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
if (use_media_foundation_ && session_) { if (use_media_foundation_) {
DCHECK(PlatformSupportsMediaFoundation());
GetDeviceDescriptorsMediaFoundation(device_descriptors); GetDeviceDescriptorsMediaFoundation(device_descriptors);
AugmentDescriptorListWithDirectShowOnlyDevices(device_descriptors); AugmentDescriptorListWithDirectShowOnlyDevices(device_descriptors);
} else { } else {
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "media/base/win/mf_initializer.h"
#include "media/capture/video/video_capture_device_factory.h" #include "media/capture/video/video_capture_device_factory.h"
namespace media { namespace media {
...@@ -95,7 +94,6 @@ class CAPTURE_EXPORT VideoCaptureDeviceFactoryWin ...@@ -95,7 +94,6 @@ class CAPTURE_EXPORT VideoCaptureDeviceFactoryWin
VideoCaptureFormats* formats); VideoCaptureFormats* formats);
bool use_media_foundation_; bool use_media_foundation_;
MFSessionLifetime session_;
// In production code, when Media Foundation libraries are available, // In production code, when Media Foundation libraries are available,
// |mf_enum_device_sources_func_| points to MFEnumDeviceSources. It enables // |mf_enum_device_sources_func_| points to MFEnumDeviceSources. It enables
// mock of Media Foundation API in unit tests. // mock of Media Foundation API in unit tests.
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include "media/base/media_log.h" #include "media/base/media_log.h"
#include "media/base/media_switches.h" #include "media/base/media_switches.h"
#include "media/base/win/mf_helpers.h" #include "media/base/win/mf_helpers.h"
#include "media/base/win/mf_initializer.h"
#include "media/filters/vp9_parser.h" #include "media/filters/vp9_parser.h"
#include "media/gpu/windows/d3d11_video_device_format_support.h" #include "media/gpu/windows/d3d11_video_device_format_support.h"
#include "media/gpu/windows/dxva_picture_buffer_win.h" #include "media/gpu/windows/dxva_picture_buffer_win.h"
...@@ -628,7 +629,7 @@ bool DXVAVideoDecodeAccelerator::Initialize(const Config& config, ...@@ -628,7 +629,7 @@ bool DXVAVideoDecodeAccelerator::Initialize(const Config& config,
RETURN_ON_FAILURE((state == kUninitialized), RETURN_ON_FAILURE((state == kUninitialized),
"Initialize: invalid state: " << state, false); "Initialize: invalid state: " << state, false);
RETURN_ON_FAILURE(session_ = InitializeMediaFoundation(), RETURN_ON_FAILURE(InitializeMediaFoundation(),
"Could not initialize Media Foundartion", false); "Could not initialize Media Foundartion", false);
config_ = config; config_ = config;
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "gpu/config/gpu_preferences.h" #include "gpu/config/gpu_preferences.h"
#include "media/base/video_color_space.h" #include "media/base/video_color_space.h"
#include "media/base/win/mf_initializer.h"
#include "media/gpu/gpu_video_decode_accelerator_helpers.h" #include "media/gpu/gpu_video_decode_accelerator_helpers.h"
#include "media/gpu/media_gpu_export.h" #include "media/gpu/media_gpu_export.h"
#include "media/gpu/windows/d3d11_com_defs.h" #include "media/gpu/windows/d3d11_com_defs.h"
...@@ -401,9 +400,6 @@ class MEDIA_GPU_EXPORT DXVAVideoDecodeAccelerator ...@@ -401,9 +400,6 @@ class MEDIA_GPU_EXPORT DXVAVideoDecodeAccelerator
// To expose client callbacks from VideoDecodeAccelerator. // To expose client callbacks from VideoDecodeAccelerator.
VideoDecodeAccelerator::Client* client_; VideoDecodeAccelerator::Client* client_;
// MediaFoundation session, calls MFShutdown on deletion.
MFSessionLifetime session_;
Microsoft::WRL::ComPtr<IMFTransform> decoder_; Microsoft::WRL::ComPtr<IMFTransform> decoder_;
Microsoft::WRL::ComPtr<IDirect3D9Ex> d3d9_; Microsoft::WRL::ComPtr<IDirect3D9Ex> d3d9_;
......
...@@ -359,7 +359,7 @@ bool MediaFoundationVideoEncodeAccelerator::CreateHardwareEncoderMFT() { ...@@ -359,7 +359,7 @@ bool MediaFoundationVideoEncodeAccelerator::CreateHardwareEncoderMFT() {
} }
} }
if (!(session_ = InitializeMediaFoundation())) if (!InitializeMediaFoundation())
return false; return false;
uint32_t flags = MFT_ENUM_FLAG_HARDWARE | MFT_ENUM_FLAG_SORTANDFILTER; uint32_t flags = MFT_ENUM_FLAG_HARDWARE | MFT_ENUM_FLAG_SORTANDFILTER;
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "media/base/win/mf_initializer.h"
#include "media/gpu/media_gpu_export.h" #include "media/gpu/media_gpu_export.h"
#include "media/video/video_encode_accelerator.h" #include "media/video/video_encode_accelerator.h"
...@@ -137,9 +136,6 @@ class MEDIA_GPU_EXPORT MediaFoundationVideoEncodeAccelerator ...@@ -137,9 +136,6 @@ class MEDIA_GPU_EXPORT MediaFoundationVideoEncodeAccelerator
Microsoft::WRL::ComPtr<IMFSample> input_sample_; Microsoft::WRL::ComPtr<IMFSample> input_sample_;
Microsoft::WRL::ComPtr<IMFSample> output_sample_; Microsoft::WRL::ComPtr<IMFSample> output_sample_;
// MediaFoundation session.
MFSessionLifetime session_;
// To expose client callbacks from VideoEncodeAccelerator. // To expose client callbacks from VideoEncodeAccelerator.
// NOTE: all calls to this object *MUST* be executed on // NOTE: all calls to this object *MUST* be executed on
// |main_client_task_runner_|. // |main_client_task_runner_|.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment