gstreamer/gstreamer-sharp/Clock.custom
Sebastian Dröge e67cf80368 The GMutex and GCond API uses macros to function tables instead of real function
We need to add real functions for these macros. Fixes bug #647529.
2011-04-13 17:33:05 +02:00

151 lines
4.3 KiB
Text

public static readonly ulong Second = 1000000000;
public static readonly ulong MSecond = 1000000;
public static readonly ulong USecond = 1000;
public static readonly ulong NSecond = 1;
public static readonly ulong TimeNone = 0xffffffffffffffff;
public static bool TimeIsValid (ulong time) {
return (time != TimeNone);
}
[DllImport ("gstreamersharpglue-0.10.dll") ]
extern static uint gstsharp_gst_clock_get_entries_changed_offset ();
static uint entries_changed_offset = gstsharp_gst_clock_get_entries_changed_offset ();
private IntPtr EntriesChangedPtr {
get {
unsafe {
IntPtr* raw_ptr = (IntPtr*) ( ( (byte*) Handle) + entries_changed_offset);
return (*raw_ptr);
}
}
}
[DllImport ("gstreamersharpglue-0.10.dll") ]
static extern void gstsharp_g_cond_wait (IntPtr cond, IntPtr mutex);
[DllImport ("gstreamersharpglue-0.10.dll") ]
static extern bool gstsharp_g_cond_timed_wait (IntPtr cond, IntPtr mutex, ref _TimeVal abs_time);
[DllImport ("gstreamersharpglue-0.10.dll") ]
static extern void gstsharp_g_cond_broadcast (IntPtr cond);
public void Wait () {
gstsharp_g_cond_wait (EntriesChangedPtr, LockPtr);
}
[StructLayout (LayoutKind.Sequential) ]
private struct _TimeVal {
public IntPtr sec;
public IntPtr usec;
}
public bool Wait (uint mseconds) {
_TimeVal tv = new _TimeVal ();
long sec = mseconds / 1000;
long usec = 1000 * (mseconds - sec * 1000);
tv.sec = (IntPtr) (sec);
tv.usec = (IntPtr) (usec);
return gstsharp_g_cond_timed_wait (EntriesChangedPtr, LockPtr, ref tv);
}
public bool Wait (TimeSpan timespan) {
_TimeVal tv = new _TimeVal ();
long sec = (long) timespan.TotalSeconds;
long usec = 1000 * ( ( (long) timespan.TotalMilliseconds) - sec * 1000);
tv.sec = (IntPtr) (sec);
tv.usec = (IntPtr) (usec);
return gstsharp_g_cond_timed_wait (EntriesChangedPtr, LockPtr, ref tv);
}
public void Broadcast () {
gstsharp_g_cond_broadcast (EntriesChangedPtr);
}
[DllImport ("gstreamersharpglue-0.10.dll") ]
extern static uint gstsharp_gst_clock_get_slave_lock_offset ();
static uint slave_lock_offset = gstsharp_gst_clock_get_slave_lock_offset ();
private IntPtr SlaveLockPtr {
get {
unsafe {
IntPtr* raw_ptr = (IntPtr*) ( ( (byte*) Handle) + slave_lock_offset);
return (*raw_ptr);
}
}
}
[DllImport ("gstreamersharpglue-0.10.dll") ]
static extern void gstsharp_g_mutex_lock (IntPtr mutex);
[DllImport ("gstreamersharpglue-0.10.dll") ]
static extern void gstsharp_g_mutex_unlock (IntPtr mutex);
[DllImport ("gstreamersharpglue-0.10.dll") ]
static extern bool gstsharp_g_mutex_trylock (IntPtr mutex);
public void SlaveLock () {
gstsharp_g_mutex_lock (SlaveLockPtr);
}
public void SlaveUnlock () {
gstsharp_g_mutex_unlock (SlaveLockPtr);
}
public bool TrySlaveLock () {
return gstsharp_g_mutex_trylock (SlaveLockPtr);
}
[DllImport ("libgstreamer-0.10.dll") ]
static extern IntPtr gst_clock_get_master (IntPtr raw);
[DllImport ("libgstreamer-0.10.dll") ]
static extern bool gst_clock_set_master (IntPtr raw, IntPtr master);
public Gst.Clock Master {
get {
IntPtr raw_ret = gst_clock_get_master (Handle);
Gst.Clock ret = Gst.GLib.Object.GetObject (raw_ret, true) as Gst.Clock;
return ret;
} set {
if (!gst_clock_set_master (Handle, value == null ? IntPtr.Zero : value.Handle))
throw new Exception ();
}
}
[DllImport ("gstreamersharpglue-0.10.dll") ]
extern static uint gstsharp_gst_clock_get_entries_offset ();
static uint entries_offset = gstsharp_gst_clock_get_entries_offset ();
private IntPtr EntriesPtr {
get {
unsafe {
IntPtr* raw_ptr = (IntPtr*) ( ( (byte*) Handle) + entries_offset);
return (*raw_ptr);
}
}
}
protected Gst.ClockEntry[] Entries {
get {
return (Gst.ClockEntry[]) Gst.GLib.Marshaller.ListPtrToArray (EntriesPtr, typeof (Gst.GLib.List), false, false, typeof (Gst.ClockEntry));
}
}
[DllImport ("gstreamersharpglue-0.10.dll") ]
extern static uint gstsharp_gst_clock_get_times_offset ();
static uint times_offset = gstsharp_gst_clock_get_times_offset ();
private IntPtr TimesPtr {
get {
unsafe {
IntPtr* raw_ptr = (IntPtr*) ( ( (byte*) Handle) + times_offset);
return (*raw_ptr);
}
}
}
protected ulong[] Times {
get {
ulong[] ret = new ulong[4 * WindowSize];
for (int i = 0; i < 4 * WindowSize; i++)
ret[i] = (ulong) Marshal.ReadInt64 (TimesPtr, 8 * i);
return ret;
}
}