microsoft / psi

Platform for Situated Intelligence
https://github.com/microsoft/psi/wiki
Other
529 stars 93 forks source link

Exposing the HoloLens 2's PhotoVideoCamera's MediaCaptureTask #248

Closed austinbhale closed 1 year ago

austinbhale commented 1 year ago

Hi, would it be possible to expose initMediaCaptureTask with a public getter?

This async Task begins for every new PhotoVideoCamera instance, then it is awaited when starting a pipeline to ensure that it has finished initializing a MediaCapture instance. https://github.com/microsoft/psi/blob/5f8a282a06145e87aeacd86af6e119c875fc9330/Sources/MixedReality/Microsoft.Psi.MixedReality.UniversalWindows/PhotoVideoCamera.cs#L65

It might be useful to expose this property since there are times when we want to dispose of a pipeline without running the pipeline. In this case, the developer can ensure that they safely release the MediaCapture instance after it has been created.

The addition could be something like: public Task InitMediaCaptureTask { get => this.initMediaCaptureTask; }

Another solution, without exposing the task, could be to await the task inside the PhotoVideoCamera's Dispose method. It may not be safe to dispose of the MediaCapture instance if it is currently being initialized asynchronously here: https://github.com/microsoft/psi/blob/5f8a282a06145e87aeacd86af6e119c875fc9330/Sources/MixedReality/Microsoft.Psi.MixedReality.UniversalWindows/PhotoVideoCamera.cs#L256

Thanks!