// RefClock.idl : IDL source for RefClock.dll
//

// This file will be processed by the MIDL tool to
// produce the type library (RefClock.tlb) and marshalling code.

//=====================================================================
//=====================================================================
// time information
//
// This represents a time (either reference or stream) in 100ns units
// The class library contains a CRefTime helper class
// that supports simple comparison and arithmetic operations
//=====================================================================
//=====================================================================


// Win32 HANDLEs have to be cast to these as the MIDL compiler doesn't
// like the HANDLE type or in fact anything remotely associated with
// them. If this ever gets ported to a MAC environment then these will
// have to become an alertable synchronisation object that it supports

//typedef DWORD_PTR HSEMAPHORE;
//typedef DWORD_PTR HEVENT;

typedef unsigned long HSEMAPHORE;
typedef unsigned long HEVENT;
typedef __int64 REFERENCE_TIME;
typedef double REFTIME;

import "oaidl.idl";
import "ocidl.idl";
    [
        object,
        uuid(56a86897-0ad4-11ce-b03a-0020af0ba770),

        helpstring("IReferenceClock Interface"),
        pointer_default(unique)
    ]
    interface IReferenceClock : IUnknown
    {
            // get the time now
            HRESULT GetTime(
                [out] REFERENCE_TIME *pTime
            );

            // ask for an async notification that a time has elapsed
            HRESULT AdviseTime(
                [in] REFERENCE_TIME baseTime,       // base reference time
                [in] REFERENCE_TIME streamTime,     // stream offset time
                [in] HEVENT hEvent,                 // advise via this event
                [out] DWORD_PTR * pdwAdviseCookie   // where your cookie goes
            );

            // ask for an async periodic notification that a time has elapsed
            HRESULT AdvisePeriodic(
                [in] REFERENCE_TIME startTime,      // starting at this time
                [in] REFERENCE_TIME periodTime,     // time between notifications
                [in] HSEMAPHORE hSemaphore,         // advise via a semaphore
                [out] DWORD_PTR * pdwAdviseCookie   // where your cookie goes
            );

            // cancel a request for notification
            HRESULT Unadvise(
                [in] DWORD_PTR dwAdviseCookie);
    };

[
    uuid(600A1B0F-038E-48CD-8EAE-0E2CFA9D0FD4),
    version(1.0),
    helpstring("RefClock 1.0 Type Library")
]
library REFCLOCKLib
{
    importlib("stdole2.tlb");

    [
        uuid(CF8767F3-7913-4F90-A279-4CED5BF64B4F),
        helpstring("ReferenceClock Class")
    ]
    coclass ReferenceClock
    {
        [default] interface IReferenceClock;
    };
};
