/// <summary> /// Releases the resources used by the <see cref="MediaCodec"/> object. /// </summary> /// <param name="disposing"> /// true to release both managed and unmanaged resources; false to release only unmanaged resources. /// </param> /// <since_tizen> 3 </since_tizen> protected virtual void Dispose(bool disposing) { if (!_isDisposed) { if (_handle != IntPtr.Zero) { Native.Destroy(_handle).ThrowIfFailed("Failed to destry media codec."); _handle = IntPtr.Zero; } _isDisposed = true; } }
private void RegisterOutputAvailableCallback() { _outputBufferAvailableCb = (packetHandle, _) => { if (_outputAvailable == null) { try { Native.Destroy(packetHandle).ThrowIfFailed("Failed to destroy packet."); } catch (Exception) { // Do not throw exception in pinvoke callback. } return; } OutputAvailableEventArgs args = null; try { args = new OutputAvailableEventArgs(packetHandle); } catch (Exception e) { try { Native.Destroy(packetHandle).ThrowIfFailed("Failed to destroy packet."); } catch { // Do not throw exception in pinvoke callback. } MultimediaLog.Error(typeof(MediaCodec).FullName, "Failed to raise OutputAvailable event", e); } if (args != null) { _outputAvailable?.Invoke(this, args); } }; Native.SetOutputBufferAvailableCb(_handle, _outputBufferAvailableCb). ThrowIfFailed("Failed to set output buffer available callback."); }