Ejemplo n.º 1
0
 public Cookie(
     MamaSourceGroup mGroup,
     MamaSourceStateChangeCallback mCallback,
     IntPtr registrationHandle,
     IntPtr mKey)
 {
     this.mGroup    = mGroup;
     this.mCallback = mCallback;
     this.mHandle   = registrationHandle;
     this.mKey      = mKey;
 }
Ejemplo n.º 2
0
        private void onStateChange(IntPtr sourceGroup, IntPtr topWeightSource, IntPtr closure)
        {
            int    mKey   = closure.ToInt32();
            Cookie cookie = mRegistrations[mKey] as Cookie;

            if (cookie != null && cookie.Key != 0)
            {
                MamaSourceStateChangeCallback mCallback = cookie.SourceStateChangeCallback;
                if (mCallback != null)
                {
                    mCallback.onStateChanged(this, new MamaSource(topWeightSource));
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// The mCallback interface registered here will receive a mCallback whenever the
        /// state of sources in the mGroup changes.
        /// </summary>
        /// <param name="mCallback">The mCallback object</param>
        public StateChangedRegistration registerStateChangeCallback(MamaSourceStateChangeCallback mCallback)
        {
#if MAMA_WRAPPERS_CHECK_ARGUMENTS
            if (mCallback == null)
            {
                throw new ArgumentNullException("mCallback");
            }
#endif // MAMA_WRAPPERS_CHECK_ARGUMENTS
            EnsurePeerCreated();
            IntPtr cookieKey = new IntPtr(mNextKey);
            IntPtr regCookie = IntPtr.Zero;
            int    code      = NativeMethods.mamaSourceGroup_registerStageChangeCallback(
                nativeHandle,
                new MamaSourceGroupOnStateChangeDelegate(onStateChange),
                ref regCookie,
                cookieKey);
            CheckResultCode(code);
            StateChangedRegistration reg = new Cookie(this, mCallback, regCookie, cookieKey);
            GC.KeepAlive(mCallback);
            mRegistrations[mNextKey] = reg;
            ++mNextKey;
            return(reg);
        }
Ejemplo n.º 4
0
			public Cookie(
				MamaSourceGroup mGroup, 
				MamaSourceStateChangeCallback mCallback, 
				IntPtr registrationHandle,
				IntPtr mKey)
			{
				this.mGroup = mGroup;
				this.mCallback = mCallback;
				this.mHandle = registrationHandle;
				this.mKey = mKey;
			}
Ejemplo n.º 5
0
		/// <summary>
		/// The mCallback interface registered here will receive a mCallback whenever the 
		/// state of sources in the mGroup changes.
		/// </summary>
		/// <param name="mCallback">The mCallback object</param>
		public StateChangedRegistration registerStateChangeCallback(MamaSourceStateChangeCallback mCallback)
		{
#if MAMA_WRAPPERS_CHECK_ARGUMENTS
			if (mCallback == null)
			{
				throw new ArgumentNullException("mCallback");
			}
#endif // MAMA_WRAPPERS_CHECK_ARGUMENTS
			EnsurePeerCreated();
			IntPtr cookieKey = new IntPtr(mNextKey);
			IntPtr regCookie = IntPtr.Zero;
			int code = NativeMethods.mamaSourceGroup_registerStageChangeCallback(
				nativeHandle,
				new MamaSourceGroupOnStateChangeDelegate(onStateChange),
				ref regCookie,
				cookieKey);
			CheckResultCode(code);
			StateChangedRegistration reg = new Cookie(this, mCallback, regCookie, cookieKey);
			GC.KeepAlive(mCallback);
			mRegistrations[mNextKey] = reg;
			++mNextKey;
			return reg;
		}