// This file was generated by the Gtk# code generator.
// Any changes made will be lost if regenerated.

namespace Gst.Audio {

	using System;
	using System.Collections;
	using System.Collections.Generic;
	using System.Runtime.InteropServices;

#region Autogenerated code
	public partial class AudioBaseSink : Gst.Base.BaseSink {

		public AudioBaseSink (IntPtr raw) : base(raw) {}

		protected AudioBaseSink() : base(IntPtr.Zero)
		{
			CreateNativeObject (new string [0], new GLib.Value [0]);
		}

		[DllImport("gstaudio-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern ulong gst_audio_base_sink_get_alignment_threshold(IntPtr raw);

		[DllImport("gstaudio-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_audio_base_sink_set_alignment_threshold(IntPtr raw, ulong alignment_threshold);

		[GLib.Property ("alignment-threshold")]
		public ulong AlignmentThreshold {
			get  {
				ulong raw_ret = gst_audio_base_sink_get_alignment_threshold(Handle);
				ulong ret = raw_ret;
				return ret;
			}
			set  {
				gst_audio_base_sink_set_alignment_threshold(Handle, value);
			}
		}

		[GLib.Property ("buffer-time")]
		public long BufferTime {
			get {
				GLib.Value val = GetProperty ("buffer-time");
				long ret = (long) val;
				val.Dispose ();
				return ret;
			}
			set {
				GLib.Value val = new GLib.Value(value);
				SetProperty("buffer-time", val);
				val.Dispose ();
			}
		}

		[GLib.Property ("can-activate-pull")]
		public bool CanActivatePull {
			get {
				GLib.Value val = GetProperty ("can-activate-pull");
				bool ret = (bool) val;
				val.Dispose ();
				return ret;
			}
			set {
				GLib.Value val = new GLib.Value(value);
				SetProperty("can-activate-pull", val);
				val.Dispose ();
			}
		}

		[DllImport("gstaudio-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern ulong gst_audio_base_sink_get_discont_wait(IntPtr raw);

		[DllImport("gstaudio-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_audio_base_sink_set_discont_wait(IntPtr raw, ulong discont_wait);

		[GLib.Property ("discont-wait")]
		public ulong DiscontWait {
			get  {
				ulong raw_ret = gst_audio_base_sink_get_discont_wait(Handle);
				ulong ret = raw_ret;
				return ret;
			}
			set  {
				gst_audio_base_sink_set_discont_wait(Handle, value);
			}
		}

		[DllImport("gstaudio-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern long gst_audio_base_sink_get_drift_tolerance(IntPtr raw);

		[DllImport("gstaudio-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_audio_base_sink_set_drift_tolerance(IntPtr raw, long drift_tolerance);

		[GLib.Property ("drift-tolerance")]
		public long DriftTolerance {
			get  {
				long raw_ret = gst_audio_base_sink_get_drift_tolerance(Handle);
				long ret = raw_ret;
				return ret;
			}
			set  {
				gst_audio_base_sink_set_drift_tolerance(Handle, value);
			}
		}

		[GLib.Property ("latency-time")]
		public long LatencyTime {
			get {
				GLib.Value val = GetProperty ("latency-time");
				long ret = (long) val;
				val.Dispose ();
				return ret;
			}
			set {
				GLib.Value val = new GLib.Value(value);
				SetProperty("latency-time", val);
				val.Dispose ();
			}
		}

		[DllImport("gstaudio-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern bool gst_audio_base_sink_get_provide_clock(IntPtr raw);

		[DllImport("gstaudio-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_audio_base_sink_set_provide_clock(IntPtr raw, bool provide);

		[GLib.Property ("provide-clock")]
		public bool ProvideClock {
			get  {
				bool raw_ret = gst_audio_base_sink_get_provide_clock(Handle);
				bool ret = raw_ret;
				return ret;
			}
			set  {
				gst_audio_base_sink_set_provide_clock(Handle, value);
			}
		}

		[DllImport("gstaudio-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern int gst_audio_base_sink_get_slave_method(IntPtr raw);

		[DllImport("gstaudio-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_audio_base_sink_set_slave_method(IntPtr raw, int method);

		[GLib.Property ("slave-method")]
		public Gst.Audio.AudioBaseSinkSlaveMethod SlaveMethod {
			get  {
				int raw_ret = gst_audio_base_sink_get_slave_method(Handle);
				Gst.Audio.AudioBaseSinkSlaveMethod ret = (Gst.Audio.AudioBaseSinkSlaveMethod) raw_ret;
				return ret;
			}
			set  {
				gst_audio_base_sink_set_slave_method(Handle, (int) value);
			}
		}

		public Gst.Audio.AudioRingBuffer Ringbuffer {
			get {
				unsafe {
					IntPtr* raw_ptr = (IntPtr*)(((byte*)Handle) + abi_info.GetFieldOffset("ringbuffer"));
					return GLib.Object.GetObject((*raw_ptr)) as Gst.Audio.AudioRingBuffer;
				}
			}
		}

		public ulong BufferTimeField {
			get {
				unsafe {
					ulong* raw_ptr = (ulong*)(((byte*)Handle) + abi_info.GetFieldOffset("buffer_time"));
					return (*raw_ptr);
				}
			}
		}

		public ulong LatencyTimeField {
			get {
				unsafe {
					ulong* raw_ptr = (ulong*)(((byte*)Handle) + abi_info.GetFieldOffset("latency_time"));
					return (*raw_ptr);
				}
			}
		}

		public ulong NextSample {
			get {
				unsafe {
					ulong* raw_ptr = (ulong*)(((byte*)Handle) + abi_info.GetFieldOffset("next_sample"));
					return (*raw_ptr);
				}
			}
		}

		public Gst.Clock ProvidedClock {
			get {
				unsafe {
					IntPtr* raw_ptr = (IntPtr*)(((byte*)Handle) + abi_info.GetFieldOffset("provided_clock"));
					return GLib.Object.GetObject((*raw_ptr)) as Gst.Clock;
				}
			}
		}

		public bool EosRendering {
			get {
				unsafe {
					bool* raw_ptr = (bool*)(((byte*)Handle) + abi_info.GetFieldOffset("eos_rendering"));
					return (*raw_ptr);
				}
			}
		}

		static CreateRingbufferNativeDelegate CreateRingbuffer_cb_delegate;
		static CreateRingbufferNativeDelegate CreateRingbufferVMCallback {
			get {
				if (CreateRingbuffer_cb_delegate == null)
					CreateRingbuffer_cb_delegate = new CreateRingbufferNativeDelegate (CreateRingbuffer_cb);
				return CreateRingbuffer_cb_delegate;
			}
		}

		static void OverrideCreateRingbuffer (GLib.GType gtype)
		{
			OverrideCreateRingbuffer (gtype, CreateRingbufferVMCallback);
		}

		static void OverrideCreateRingbuffer (GLib.GType gtype, CreateRingbufferNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("create_ringbuffer"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate((Delegate) callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr CreateRingbufferNativeDelegate (IntPtr inst);

		static IntPtr CreateRingbuffer_cb (IntPtr inst)
		{
			try {
				AudioBaseSink __obj = GLib.Object.GetObject (inst, false) as AudioBaseSink;
				Gst.Audio.AudioRingBuffer __result;
				__result = __obj.OnCreateRingbuffer ();
				return __result == null ? IntPtr.Zero : __result.Handle;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gst.Audio.AudioBaseSink), ConnectionMethod="OverrideCreateRingbuffer")]
		protected virtual Gst.Audio.AudioRingBuffer OnCreateRingbuffer ()
		{
			return InternalCreateRingbuffer ();
		}

		private Gst.Audio.AudioRingBuffer InternalCreateRingbuffer ()
		{
			CreateRingbufferNativeDelegate unmanaged = null;
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) this.LookupGType().GetThresholdType().GetClassPtr()) + (long) class_abi.GetFieldOffset("create_ringbuffer"));
				unmanaged = (CreateRingbufferNativeDelegate) Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(CreateRingbufferNativeDelegate));
			}
			if (unmanaged == null) return null;

			IntPtr __result = unmanaged (this.Handle);
			return GLib.Object.GetObject(__result) as Gst.Audio.AudioRingBuffer;
		}

		static PayloadNativeDelegate Payload_cb_delegate;
		static PayloadNativeDelegate PayloadVMCallback {
			get {
				if (Payload_cb_delegate == null)
					Payload_cb_delegate = new PayloadNativeDelegate (Payload_cb);
				return Payload_cb_delegate;
			}
		}

		static void OverridePayload (GLib.GType gtype)
		{
			OverridePayload (gtype, PayloadVMCallback);
		}

		static void OverridePayload (GLib.GType gtype, PayloadNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("payload"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate((Delegate) callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr PayloadNativeDelegate (IntPtr inst, IntPtr buffer);

		static IntPtr Payload_cb (IntPtr inst, IntPtr buffer)
		{
			try {
				AudioBaseSink __obj = GLib.Object.GetObject (inst, false) as AudioBaseSink;
				Gst.Buffer __result;
				__result = __obj.OnPayload (buffer == IntPtr.Zero ? null : (Gst.Buffer) GLib.Opaque.GetOpaque (buffer, typeof (Gst.Buffer), false));
				return __result == null ? IntPtr.Zero : __result.OwnedCopy;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gst.Audio.AudioBaseSink), ConnectionMethod="OverridePayload")]
		protected virtual Gst.Buffer OnPayload (Gst.Buffer buffer)
		{
			return InternalPayload (buffer);
		}

		private Gst.Buffer InternalPayload (Gst.Buffer buffer)
		{
			PayloadNativeDelegate unmanaged = null;
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) this.LookupGType().GetThresholdType().GetClassPtr()) + (long) class_abi.GetFieldOffset("payload"));
				unmanaged = (PayloadNativeDelegate) Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(PayloadNativeDelegate));
			}
			if (unmanaged == null) return null;

			IntPtr __result = unmanaged (this.Handle, buffer == null ? IntPtr.Zero : buffer.Handle);
			return __result == IntPtr.Zero ? null : (Gst.Buffer) GLib.Opaque.GetOpaque (__result, typeof (Gst.Buffer), true);
		}


		// Internal representation of the wrapped structure ABI.
		static GLib.AbiStruct _class_abi = null;
		static public new GLib.AbiStruct class_abi {
			get {
				if (_class_abi == null)
					_class_abi = new GLib.AbiStruct (new List<GLib.AbiField>{ 
						new GLib.AbiField("create_ringbuffer"
							, Gst.Base.BaseSink.class_abi.Fields
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // create_ringbuffer
							, null
							, "payload"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("payload"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // payload
							, "create_ringbuffer"
							, "_gst_reserved"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("_gst_reserved"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) * 4 // _gst_reserved
							, "payload"
							, null
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
					});

				return _class_abi;
			}
		}


		// End of the ABI representation.

		[DllImport("gstaudio-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr gst_audio_base_sink_get_type();

		public static new GLib.GType GType { 
			get {
				IntPtr raw_ret = gst_audio_base_sink_get_type();
				GLib.GType ret = new GLib.GType(raw_ret);
				return ret;
			}
		}

		[DllImport("gstaudio-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr gst_audio_base_sink_create_ringbuffer(IntPtr raw);

		public Gst.Audio.AudioRingBuffer CreateRingbuffer() {
			IntPtr raw_ret = gst_audio_base_sink_create_ringbuffer(Handle);
			Gst.Audio.AudioRingBuffer ret = GLib.Object.GetObject(raw_ret) as Gst.Audio.AudioRingBuffer;
			return ret;
		}

		[DllImport("gstaudio-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_audio_base_sink_report_device_failure(IntPtr raw);

		public void ReportDeviceFailure() {
			gst_audio_base_sink_report_device_failure(Handle);
		}

		[DllImport("gstaudio-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_audio_base_sink_set_custom_slaving_callback(IntPtr raw, Gst.AudioSharp.AudioBaseSinkCustomSlavingCallbackNative cb, IntPtr user_data, GLib.DestroyNotify notify);

		public Gst.Audio.AudioBaseSinkCustomSlavingCallback CustomSlavingCallback { 
			set {
				Gst.AudioSharp.AudioBaseSinkCustomSlavingCallbackWrapper value_wrapper = new Gst.AudioSharp.AudioBaseSinkCustomSlavingCallbackWrapper (value);
				IntPtr user_data;
				GLib.DestroyNotify notify;
				if (value == null) {
					user_data = IntPtr.Zero;
					notify = null;
				} else {
					user_data = (IntPtr) GCHandle.Alloc (value_wrapper);
					notify = GLib.DestroyHelper.NotifyHandler;
				}
				gst_audio_base_sink_set_custom_slaving_callback(Handle, value_wrapper.NativeDelegate, user_data, notify);
			}
		}


		static AudioBaseSink ()
		{
			GtkSharp.GstreamerSharp.ObjectManager.Initialize ();
		}

		// Internal representation of the wrapped structure ABI.
		static GLib.AbiStruct _abi_info = null;
		static public new GLib.AbiStruct abi_info {
			get {
				if (_abi_info == null)
					_abi_info = new GLib.AbiStruct (new List<GLib.AbiField>{ 
						new GLib.AbiField("ringbuffer"
							, Gst.Base.BaseSink.abi_info.Fields
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // ringbuffer
							, null
							, "buffer_time"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("buffer_time"
							, -1
							, (uint) Marshal.SizeOf(typeof(ulong)) // buffer_time
							, "ringbuffer"
							, "latency_time"
							, (long) Marshal.OffsetOf(typeof(GstAudioBaseSink_buffer_timeAlign), "buffer_time")
							, 0
							),
						new GLib.AbiField("latency_time"
							, -1
							, (uint) Marshal.SizeOf(typeof(ulong)) // latency_time
							, "buffer_time"
							, "next_sample"
							, (long) Marshal.OffsetOf(typeof(GstAudioBaseSink_latency_timeAlign), "latency_time")
							, 0
							),
						new GLib.AbiField("next_sample"
							, -1
							, (uint) Marshal.SizeOf(typeof(ulong)) // next_sample
							, "latency_time"
							, "provided_clock"
							, (long) Marshal.OffsetOf(typeof(GstAudioBaseSink_next_sampleAlign), "next_sample")
							, 0
							),
						new GLib.AbiField("provided_clock"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // provided_clock
							, "next_sample"
							, "eos_rendering"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("eos_rendering"
							, -1
							, (uint) Marshal.SizeOf(typeof(bool)) // eos_rendering
							, "provided_clock"
							, "priv"
							, (long) Marshal.OffsetOf(typeof(GstAudioBaseSink_eos_renderingAlign), "eos_rendering")
							, 0
							),
						new GLib.AbiField("priv"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // priv
							, "eos_rendering"
							, "_gst_reserved"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("_gst_reserved"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) * 4 // _gst_reserved
							, "priv"
							, null
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
					});

				return _abi_info;
			}
		}

		[StructLayout(LayoutKind.Sequential)]
		public struct GstAudioBaseSink_buffer_timeAlign
		{
			sbyte f1;
			private ulong buffer_time;
		}

		[StructLayout(LayoutKind.Sequential)]
		public struct GstAudioBaseSink_latency_timeAlign
		{
			sbyte f1;
			private ulong latency_time;
		}

		[StructLayout(LayoutKind.Sequential)]
		public struct GstAudioBaseSink_next_sampleAlign
		{
			sbyte f1;
			private ulong next_sample;
		}

		[StructLayout(LayoutKind.Sequential)]
		public struct GstAudioBaseSink_eos_renderingAlign
		{
			sbyte f1;
			private bool eos_rendering;
		}


		// End of the ABI representation.

#endregion
	}
}
