Skip to content

Commit

Permalink
Cleaned up some descriptors when stop capture.
Browse files Browse the repository at this point in the history
  • Loading branch information
kekyo committed Jan 15, 2024
1 parent 1631894 commit ef5462e
Show file tree
Hide file tree
Showing 3 changed files with 244 additions and 216 deletions.
26 changes: 13 additions & 13 deletions FlashCap.Core/Devices/DirectShowDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,20 @@ protected override Task OnInitializeAsync(

return this.workingContext!.InvokeAsync(() =>
{
if (NativeMethods_DirectShow.EnumerateDeviceMoniker(
NativeMethods_DirectShow.CLSID_VideoInputDeviceCategory).
Where(moniker =>
moniker.GetPropertyBag() is { } pb &&
pb.SafeReleaseBlock(pb =>
pb.GetValue("DevicePath", default(string))?.Trim() is { } dp &&
dp.Equals(devicePath))).
Collect(moniker =>
moniker.BindToObject(null, null, in NativeMethods_DirectShow.IID_IBaseFilter, out var captureSource) == 0 ?
captureSource as NativeMethods_DirectShow.IBaseFilter : null).
FirstOrDefault() is { } captureSource)
{
try
if (NativeMethods_DirectShow.EnumerateDeviceMoniker(
NativeMethods_DirectShow.CLSID_VideoInputDeviceCategory).
Where(moniker =>
moniker.GetPropertyBag() is { } pb &&
pb.SafeReleaseBlock(pb =>
pb.GetValue("DevicePath", default(string))?.Trim() is { } dp &&
dp.Equals(devicePath))).
Collect(moniker =>
moniker.BindToObject(null, null, in NativeMethods_DirectShow.IID_IBaseFilter, out var captureSource) == 0 ?
captureSource as NativeMethods_DirectShow.IBaseFilter : null).
FirstOrDefault() is { } captureSource)
{
try
{
if (captureSource.EnumeratePins().
Collect(pin =>
pin.GetPinInfo() is { } pinInfo &&
Expand Down
Loading

0 comments on commit ef5462e

Please sign in to comment.