Skip to content

Commit 1b560f2

Browse files
disposing of media seems to raise binding exceptions
1 parent a96b7d4 commit 1b560f2

File tree

3 files changed

+7
-28
lines changed

3 files changed

+7
-28
lines changed

Samples/StyleTransfer/AppModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class AppModel : INotifyPropertyChanged
2020
{
2121
public AppModel()
2222
{
23-
this._useGPU = true;
23+
this._useGPU = false;
2424
this._modelSource = "candy";
2525
this._selectedCameraIndex = 0;
2626
this._outputCaptureElement = new CaptureElement();

Samples/StyleTransfer/AppViewModel.cs

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ public async Task SetMediaSource(string src)
129129
{
130130
_appModel.InputMedia = src;
131131

132-
CleanupCameraAsync();
133-
134132
CleanupInputImage();
135133
NotifyUser(true);
136134
SaveEnabled = true;
@@ -337,28 +335,6 @@ public async Task ChangeLiveStream()
337335
}
338336
}
339337

340-
// Preview the input and output media
341-
private void StartPreview()
342-
{
343-
Debug.WriteLine("StartPreview");
344-
_selectedMediaFrameSource = _mediaCapture.FrameSources.FirstOrDefault(source => source.Value.Info.MediaStreamType == MediaStreamType.VideoPreview
345-
&& source.Value.Info.SourceKind == MediaFrameSourceKind.Color).Value;
346-
if (_selectedMediaFrameSource == null)
347-
{
348-
_selectedMediaFrameSource = _mediaCapture.FrameSources.FirstOrDefault(source => source.Value.Info.MediaStreamType == MediaStreamType.VideoRecord
349-
&& source.Value.Info.SourceKind == MediaFrameSourceKind.Color).Value;
350-
}
351-
352-
// If no preview stream are available, bail
353-
if (_selectedMediaFrameSource == null)
354-
{
355-
return;
356-
}
357-
358-
//_appModel.OutputCaptureElement = MediaSource.CreateFromMediaFrameSource(_selectedMediaFrameSource);
359-
//_appModel.InputMediaSource = MediaSource.CreateFromMediaFrameSource(_selectedMediaFrameSource);
360-
}
361-
362338
private async Task LoadModelAsync()
363339
{
364340

@@ -423,6 +399,7 @@ private async Task CleanupCameraAsync()
423399
if (isPreviewing)
424400
{
425401
await _mediaCapture.StopPreviewAsync();
402+
isPreviewing = false;
426403
}
427404
await DispatcherHelper.RunAsync(() =>
428405
{
@@ -433,8 +410,10 @@ await DispatcherHelper.RunAsync(() =>
433410
{
434411
displayRequest.RequestRelease();
435412
}
436-
_mediaCapture.Dispose();
413+
414+
MediaCapture m = _mediaCapture;
437415
_mediaCapture = null;
416+
m.Dispose();
438417
});
439418
}
440419
if (videoEffect != null)

Samples/StyleTransfer/VideoEffect/StyleTransferEffectCpp/StyleTransferEffect.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ namespace winrt::StyleTransferEffectCpp::implementation
5757
}
5858

5959
void StyleTransferEffect::SetProperties(IPropertySet config) {
60-
Processing.lock();
60+
//Processing.lock();
6161
this->configuration = config;
6262
hstring modelName;
6363
IInspectable val = config.TryLookup(L"ModelName");
@@ -76,6 +76,6 @@ namespace winrt::StyleTransferEffectCpp::implementation
7676

7777
InputImageDescription = L"inputImage";
7878
OutputImageDescription = L"outputImage";
79-
Processing.unlock();
79+
//Processing.unlock();
8080
}
8181
}

0 commit comments

Comments
 (0)