Skip to content

Commit

Permalink
Fix media::Status dcheck from D3d11VideoDecoder
Browse files Browse the repository at this point in the history
Causal statuses are required to be non-ok-statuses, but the conditions
as written could allow a causal status to be generated from a successful
HRESULT. This breaks the conditions up, and moves one of the checks from
!SUCCEEDED() to FAILED() for consistency

Bug: 1120094
Change-Id: I47c2524c2ee5ae4984f1616fb26f02386bfbe6f0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2369434
Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800720}
  • Loading branch information
tm-chromium authored and Commit Bot committed Aug 21, 2020
1 parent 8606649 commit 89d1d57
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions media/gpu/windows/d3d11_video_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,14 @@ D3D11VideoDecoder::CreateD3D11Decoder() {
UINT config_count = 0;
hr = video_device_->GetVideoDecoderConfigCount(
decoder_configurator_->DecoderDescriptor(), &config_count);
if (FAILED(hr) || config_count == 0) {
if (FAILED(hr)) {
return Status(StatusCode::kGetDecoderConfigCountFailed)
.AddCause(HresultToStatus(hr));
}

if (config_count == 0)
return Status(StatusCode::kGetDecoderConfigCountFailed);

D3D11_VIDEO_DECODER_CONFIG dec_config = {};
bool found = false;

Expand Down Expand Up @@ -277,7 +280,11 @@ D3D11VideoDecoder::CreateD3D11Decoder() {
Microsoft::WRL::ComPtr<ID3D11VideoDecoder> video_decoder;
hr = video_device_->CreateVideoDecoder(
decoder_configurator_->DecoderDescriptor(), &dec_config, &video_decoder);
if (!video_decoder.Get() || FAILED(hr)) {

if (!video_decoder.Get())
return Status(StatusCode::kDecoderCreationFailed);

if (FAILED(hr)) {
return Status(StatusCode::kDecoderCreationFailed)
.AddCause(HresultToStatus(hr));
}
Expand Down Expand Up @@ -368,7 +375,7 @@ void D3D11VideoDecoder::Initialize(const VideoDecoderConfig& config,
if (!base::FeatureList::IsEnabled(kD3D11VideoDecoderSkipMultithreaded)) {
ComD3D11Multithread multi_threaded;
hr = device_->QueryInterface(IID_PPV_ARGS(&multi_threaded));
if (!SUCCEEDED(hr)) {
if (FAILED(hr)) {
NotifyError(Status(StatusCode::kQueryID3D11MultithreadFailed)
.AddCause(HresultToStatus(hr)));
return;
Expand Down

0 comments on commit 89d1d57

Please sign in to comment.