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

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

Issue 218673002: Fix video capture bug in a utility function, GetPin, and how it was being used. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Change GetPin to just return the object since the return value wasn't being used Created 6 years, 9 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 490c59dfac27e4f244f71f330208d0e3e045f313..2afb96860177ea648017597a2ce05ee34c0a5316 100644
--- a/media/video/capture/win/video_capture_device_win.cc
+++ b/media/video/capture/win/video_capture_device_win.cc
@@ -102,27 +102,28 @@ bool PinMatchesCategory(IPin* pin, REFGUID category) {
}
// Finds a IPin on a IBaseFilter given the direction an category.
-HRESULT GetPin(IBaseFilter* filter, PIN_DIRECTION pin_dir, REFGUID category,
- IPin** pin) {
- DCHECK(pin);
+ScopedComPtr<IPin> GetPin(IBaseFilter* filter, PIN_DIRECTION pin_dir,
+ REFGUID category) {
+ ScopedComPtr<IPin> pin;
ScopedComPtr<IEnumPins> pin_emum;
HRESULT hr = filter->EnumPins(pin_emum.Receive());
if (pin_emum == NULL)
- return hr;
+ return pin;
// Get first unconnected pin.
hr = pin_emum->Reset(); // set to first pin
- while ((hr = pin_emum->Next(1, pin, NULL)) == S_OK) {
+ while ((hr = pin_emum->Next(1, pin.Receive(), NULL)) == S_OK) {
PIN_DIRECTION this_pin_dir = static_cast<PIN_DIRECTION>(-1);
- hr = (*pin)->QueryDirection(&this_pin_dir);
+ hr = pin->QueryDirection(&this_pin_dir);
if (pin_dir == this_pin_dir) {
- if (category == GUID_NULL || PinMatchesCategory(*pin, category))
- return S_OK;
+ if (category == GUID_NULL || PinMatchesCategory(pin, category))
+ return pin;
}
- (*pin)->Release();
+ pin.Release();
}
- return E_FAIL;
+ DCHECK(!pin);
+ return pin;
}
// Release the format block for a media type.
@@ -383,9 +384,8 @@ void VideoCaptureDeviceWin::GetDeviceSupportedFormats(const Name& device,
return;
}
- base::win::ScopedComPtr<IPin> output_capture_pin;
- hr = GetPin(capture_filter, PINDIR_OUTPUT, PIN_CATEGORY_CAPTURE,
- output_capture_pin.Receive());
+ base::win::ScopedComPtr<IPin> output_capture_pin(
+ GetPin(capture_filter, PINDIR_OUTPUT, PIN_CATEGORY_CAPTURE));
if (!output_capture_pin) {
DVLOG(2) << "Failed to get capture output pin";
return;
@@ -472,8 +472,8 @@ bool VideoCaptureDeviceWin::Init() {
return false;
}
- hr = GetPin(capture_filter_, PINDIR_OUTPUT, PIN_CATEGORY_CAPTURE,
- output_capture_pin_.Receive());
+ output_capture_pin_ =
+ GetPin(capture_filter_, PINDIR_OUTPUT, PIN_CATEGORY_CAPTURE);
if (!output_capture_pin_) {
DVLOG(2) << "Failed to get capture output pin";
return false;
@@ -579,9 +579,8 @@ void VideoCaptureDeviceWin::AllocateAndStart(
hr = mjpg_filter_.CreateInstance(CLSID_MjpegDec, NULL, CLSCTX_INPROC);
if (SUCCEEDED(hr)) {
- GetPin(mjpg_filter_, PINDIR_INPUT, GUID_NULL, input_mjpg_pin_.Receive());
- GetPin(mjpg_filter_, PINDIR_OUTPUT, GUID_NULL,
- output_mjpg_pin_.Receive());
+ input_mjpg_pin_ = GetPin(mjpg_filter_, PINDIR_INPUT, GUID_NULL);
+ output_mjpg_pin_ = GetPin(mjpg_filter_, PINDIR_OUTPUT, GUID_NULL);
hr = graph_builder_->AddFilter(mjpg_filter_, NULL);
}
« 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