Ejemplo n.º 1
0
        internal static void OnCallback(IntPtr senderPtr, Wrapper.CallbackState args)
        {
            if (senderPtr == IntPtr.Zero)
            {
                Debug.LogError("OnCallback: senderPtr is null.");

                return;
            }

            GCHandle handle = default(GCHandle);

            try
            {
                handle = GCHandle.FromIntPtr(senderPtr);
            }
            catch (Exception ex)
            {
                Debug.LogError("OnCallback: " + ex.Message);

                return;
            }

            // check if this is of correct type
            //if (!(handle.Target is T))
            if (!(handle.Target is PlaybackEngine))
            {
                Debug.LogError("OnCallback: senderPtr is not null, but not of correct type.");

                return;
            }

            // cast to type
            //var thisObject = (T)handle.Target;
            var thisObject = (PlaybackEngine)handle.Target;

            // complete callback
#if UNITY_WSA_10_0
            if (!UnityEngine.WSA.Application.RunningOnAppThread())
            {
                UnityEngine.WSA.Application.InvokeOnAppThread(() =>
                {
                    thisObject.OnStateChanged(args);
                }, false);
            }
            else
            {
                thisObject.OnStateChanged(args);
            }
#else
            // there is still a chance the callback is on a non AppThread(callbacks genereated from WaitForEndOfFrame are not)
            // this will process the callback on AppThread on a FixedUpdate
            thisObject.OnStateChanged(args);
#endif
        }
Ejemplo n.º 2
0
        private void OnStateChanged(Wrapper.CallbackState args)
        {
            switch (args.Type)
            {
            case Wrapper.CallbackType.Failed:
                OnFailed(args.FailState);
                break;

            default:
                OnCallback(args.Type, args);
                break;
            }
        }
Ejemplo n.º 3
0
        internal void OnStateChanged(Wrapper.CallbackState args)
        {
            // TODO: validate callback is on the right thread
            // if not queue callback action(QueueCallback(() => { OnStateChanged(args); });)
            QueueCallback(() =>
            {
                switch (args.Type)
                {
                case Wrapper.CallbackType.Failed:
                    OnFailed(args.FailState);
                    break;

                default:
                    OnCallback(args.Type, args);
                    break;
                }
            });
        }
Ejemplo n.º 4
0
        internal static void StateChangedCallback(IntPtr targetObj, Wrapper.CallbackState args)
        {
            if (targetObj == IntPtr.Zero)
            {
                Debug.LogError("StateChangedCallback: targetObj is null.");

                return;
            }

            GCHandle gcHandle = GCHandle.FromIntPtr(targetObj);

            var thisObject = gcHandle.Target as PlaybackEngine;

            if (thisObject == null)
            {
                Debug.LogError("StateChangedCallback: targetObj is not null, but not of type PlaybackEngine");

                return;
            }

#if UNITY_WSA_10_0
            if (!UnityEngine.WSA.Application.RunningOnAppThread())
            {
                UnityEngine.WSA.Application.InvokeOnAppThread(() =>
                {
                    thisObject.OnStateChanged(args);
                }, false);
            }
            else
            {
                thisObject.OnStateChanged(args);
            }
#else
            // there is still a chance the callback is on a non AppThread(callbacks genereated from WaitForEndOfFrame are not)
            // this will process the callback on AppThread on a FixedUpdate
            thisObject.OnStateChanged(args);
#endif
        }
Ejemplo n.º 5
0
 protected override void OnCallback(Wrapper.CallbackType type, Wrapper.CallbackState args)
 {
     Debug.Log(args.PlaybackState);
 }
Ejemplo n.º 6
0
 protected abstract void OnCallback(Wrapper.CallbackType type, Wrapper.CallbackState args);