public Instance(int deviceID, string modeString, uint textureHandle, EnumEntry format, EnumEntry usage, SyncLoop syncLoop) { IDeckLink device = null; WorkerThread.Singleton.PerformBlocking(() => { device = DeviceRegister.Singleton.GetDeviceHandle(deviceID); }); try { ModeRegister.Mode mode = null; WorkerThread.Singleton.PerformBlocking(() => { mode = ModeRegister.Singleton.Modes[modeString]; }); bool useCallback = syncLoop != SyncLoop.DeckLink; this.Source = new Source(device, mode, useCallback); this.ReadTexture = new ReadTexture(mode.CompressedWidth, mode.Height, textureHandle, format, usage); this.FBuffer = new byte[this.ReadTexture.BufferLength]; if (useCallback) { this.Source.NewFrame += Source_NewFrame; } } catch { if (this.Source != null) { this.Source.Dispose(); } if (this.ReadTexture != null) { this.ReadTexture.Dispose(); } if (this.FBuffer != null) { this.FBuffer = null; } throw; } }
public Instance(int deviceID, string modeString, uint textureHandle, EnumEntry format, EnumEntry usage, SyncLoop syncLoop) { IDeckLink device = null; WorkerThread.Singleton.PerformBlocking(() => { device = DeviceRegister.Singleton.GetDeviceHandle(deviceID); }); try { ModeRegister.Mode mode = null; WorkerThread.Singleton.PerformBlocking(() => { mode = ModeRegister.Singleton.Modes[modeString]; }); bool useCallback = syncLoop != SyncLoop.DeckLink; this.Source = new Source(device, mode, useCallback); this.ReadTexture = new ReadTexture(mode.CompressedWidth, mode.Height, textureHandle, format, usage); this.FBuffer = new byte[this.ReadTexture.BufferLength]; if (useCallback) { this.Source.NewFrame += Source_NewFrame; } } catch { if (this.Source != null) this.Source.Dispose(); if (this.ReadTexture != null) this.ReadTexture.Dispose(); if (this.FBuffer != null) this.FBuffer = null; throw; } }