private bool Initialize(Action <PlaybackEngine> created, PlaybackEngine engine, Connection conneciton)
        {
            this.createdHandler = (handle, result, message) =>
            {
                this.Handle = handle;

                if (this.Handle != Plugin.InvalidHandle)
                {
                    this.sizeChangedHandler        = OnFrameSizeUpdated;
                    this.sizeChangedCallbackHandle = GCHandle.Alloc(this.sizeChangedHandler);
                    Plugin.CheckResult(
                        Wrapper.exAddSizeChanged(this.Handle, this.sizeChangedHandler, ref this.sizeChangedToken),
                        "PlaybackEngine.AddSizeChanged");

                    this.sampleUpdatedHandler        = OnSampleUpdatedHandler;
                    this.sampleUpdatedCallbackHandle = GCHandle.Alloc(this.sampleUpdatedHandler);
                    Plugin.CheckResult(
                        Wrapper.exAddSampleUpdated(this.Handle, this.sampleUpdatedHandler, ref this.sampleUpdatedToken),
                        "PlaybackEngine.AddSampleUpdated");
                }
                else
                {
                    engine.Close();
                    engine.Dispose();
                    engine = null;
                }

                created(engine);
            };
            this.createdCallbackHandle = GCHandle.Alloc(this.createdHandler);

            return(Wrapper.exCreate(conneciton.Handle, this.createdHandler) == 0);
        }
Пример #2
0
        // playback events
        private void OnPlaybackInitialized(PlaybackEngine engine)
        {
            this.plugin.QueueAction(() =>
            {
                this.PlayerState = PlayerState.Initialized;

                PlaybackInitialized(engine);
            });
        }
Пример #3
0
        private void PlaybackInitialized(PlaybackEngine engine)
        {
            this.playbackEngine = engine;
            if (this.playbackEngine != null)
            {
                this.PlaybackStart();
            }

            if (this.playerState != PlayerState.Starting)
            {
                this.PlayerState = PlayerState.Failed;

                this.Shutdown();
            }
        }
Пример #4
0
        private void PlaybackClosed()
        {
            if (this.playbackEngine != null)
            {
                this.playbackEngine.Closed -= this.OnPlaybackClosed;
                this.playbackEngine.Dispose();
            }
            this.playbackEngine = null;

            if (this.playerState != PlayerState.Closed)
            {
                this.PlayerState = PlayerState.Failed;
            }

            Shutdown();
        }
        public static bool Create(Connection connection, Action <PlaybackEngine> created)
        {
            if (created == null)
            {
                return(false);
            }

            PlaybackEngine engine = new PlaybackEngine();

            if (engine == null)
            {
                return(false);
            }

            if (!engine.Initialize(created, engine, connection))
            {
                return(false);
            }

            return(true);
        }
Пример #6
0
        private void PlaybackInitialize(Connection connection)
        {
            if (connection == null)
            {
                return;
            }

            this.networkConnection = connection;
            this.networkConnection.Disconnected += this.OnDisconnected;
            this.networkConnection.Closed       += this.OnConnectionClosed;
            this.ConnectionState = ConnectionState.Connected;

            if (PlaybackEngine.Create(this.networkConnection, this.OnPlaybackInitialized))
            {
                this.PlayerState = PlayerState.Initializing;
            }
            else
            {
                this.PlayerState = PlayerState.Failed;

                Shutdown();
            };
        }