Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Unified Diff: media/video/capture/win/video_capture_device_win.cc

Issue 482413002: Fix some error states in VideoCaptureDeviceWin::AllocateAndStart. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Final fix. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/video/capture/win/video_capture_device_win.cc
diff --git a/media/video/capture/win/video_capture_device_win.cc b/media/video/capture/win/video_capture_device_win.cc
index 29ccf5afcdb8e753d1aa24757387f9ea8d42e6a2..a7d1f104cdc2bbaf16f2ec9849809dc77bf6cb4d 100644
--- a/media/video/capture/win/video_capture_device_win.cc
+++ b/media/video/capture/win/video_capture_device_win.cc
@@ -312,9 +312,14 @@ void VideoCaptureDeviceWin::AllocateAndStart(
ScopedMediaType media_type;
// Get the windows capability from the capture device.
+ // GetStreamCaps can return S_FALSE which we consider an error. Therefore the
+ // FAILED macro can't be used.
hr = stream_config->GetStreamCaps(
found_capability.stream_index, media_type.Receive(), caps.get());
- if (SUCCEEDED(hr)) {
+ if (hr != S_OK) {
+ SetErrorState("Failed to get capture device capabilities");
+ return;
+ } else {
if (media_type->formattype == FORMAT_VideoInfo) {
VIDEOINFOHEADER* h =
reinterpret_cast<VIDEOINFOHEADER*>(media_type->pbFormat);
@@ -325,11 +330,13 @@ void VideoCaptureDeviceWin::AllocateAndStart(
sink_filter_->SetRequestedMediaFormat(format);
// Order the capture device to use this format.
hr = stream_config->SetFormat(media_type.get());
+ if (FAILED(hr)) {
+ // TODO(grunell): Log the error. http://crbug.com/405016.
+ SetErrorState("Failed to set capture device output format");
+ return;
+ }
}
- if (FAILED(hr))
- SetErrorState("Failed to set capture device output format");
-
if (format.pixel_format == PIXEL_FORMAT_MJPEG && !mjpg_filter_.get()) {
// Create MJPG filter if we need it.
hr = mjpg_filter_.CreateInstance(CLSID_MjpegDec, NULL, CLSCTX_INPROC);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698