private void SetMediaState(MediaManagerState state, string message)
        {
            bool   lockTaken = false;
            object obj;

            try
            {
                Monitor.Enter(obj = this._lock, ref lockTaken);
                if (state == this._mediaState)
                {
                    return;
                }
                Debug.WriteLine("SingleStreamMediaState.SetMediaState() {0} -> {1}", (object)this._mediaState, (object)state);
                this._mediaState = state;
                if (null != message)
                {
                    this._mediaStateMessage = message;
                }
            }
            finally
            {
                if (lockTaken)
                {
                    Monitor.Exit(obj);
                }
            }
            this._reportStateTask.Fire();
        }
Exemplo n.º 2
0
 private void SetMediaState(MediaManagerState state, string message)
 {
     lock (_lock)
     {
         if (state == _mediaState)
         {
             return;
         }
         Debug.WriteLine("SmMediaManager.SetMediaState() {0} -> {1}", _mediaState, state);
         _mediaState = state;
         if (null != message)
         {
             _mediaStateMessage = message;
         }
     }
     _reportStateTask.Fire();
 }
Exemplo n.º 3
0
        private void CheckConfigurationCompleted()
        {
            MediaManagerState state = this.State;

            if (MediaManagerState.Opening != state && MediaManagerState.OpenMedia != state || (this._readers == null || Enumerable.Any <IMediaReader>((IEnumerable <IMediaReader>) this._readers, (Func <IMediaReader, bool>)(r => !r.IsConfigured))))
            {
                return;
            }
            this._playTask = MediaStreamSourceExtensions.PlayAsync(this._mediaStreamConfigurator, Enumerable.SelectMany <IMediaReader, IMediaParserMediaStream>((IEnumerable <IMediaReader>) this._readers, (Func <IMediaReader, IEnumerable <IMediaParserMediaStream> >)(r => (IEnumerable <IMediaParserMediaStream>)r.MediaStreams)), this._readerManager.Duration, this._closeCancellationTokenSource.Token);
            this.State     = MediaManagerState.Playing;
            int openCount = this._openCount;

            this._playTask.ContinueWith <Task>((Func <Task, Task>)(async t =>
            {
                AggregateException taskException = t.Exception;
                if (null != taskException)
                {
                    Debug.WriteLine("SmMediaManager.CheckConfigurationComplete() play task failed: " + taskException.Message);
                }
                try
                {
                    using (await this._asyncLock.LockAsync(CancellationToken.None).ConfigureAwait(false))
                    {
                        if (openCount == this._openCount)
                        {
                            await this.CloseAsync().ConfigureAwait(false);
                        }
                        else
                        {
                            goto label_11;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("SmMediaManager.CheckConfigurationComplete() play continuation failed: " + ex.Message);
                }
                label_11:;
            }));
        }
Exemplo n.º 4
0
        private void CheckConfigurationCompleted()
        {
            MediaManagerState state = State;

            if (MediaManagerState.Opening != state && MediaManagerState.OpenMedia != state || (_readers == null || _readers.Any(r => !r.IsConfigured)))
            {
                return;
            }
            _playTask = _mediaStreamConfigurator.PlayAsync(_readers.SelectMany(r => r.MediaStreams), _readerManager.Duration, _closeCancellationTokenSource.Token);
            State     = MediaManagerState.Playing;
            int openCount = _openCount;

            _playTask.ContinueWith(async t =>
            {
                AggregateException taskException = t.Exception;
                if (null != taskException)
                {
                    Debug.WriteLine("SmMediaManager.CheckConfigurationComplete() play task failed: " + taskException.Message);
                }
                try
                {
                    using (await _asyncLock.LockAsync(CancellationToken.None).ConfigureAwait(false))
                    {
                        if (openCount == _openCount)
                        {
                            await CloseAsync().ConfigureAwait(false);
                        }
                        else
                        {
                            return;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("SmMediaManager.CheckConfigurationComplete() play continuation failed: " + ex.Message);
                }
            });
        }
Exemplo n.º 5
0
 public MediaManagerStateEventArgs(MediaManagerState state, string message = null)
 {
     State = state;
     Message = message;
 }
 public MediaManagerStateEventArgs(MediaManagerState state, string message = null)
 {
     this.State   = state;
     this.Message = message;
 }
Exemplo n.º 7
0
        void SetMediaState(MediaManagerState state, string message)
        {
            lock (_lock)
            {
                if (state == _mediaState)
                    return;

                Debug.WriteLine("SingleStreamMediaState.SetMediaState() {0} -> {1}", _mediaState, state);

                _mediaState = state;

                if (null != message)
                    _mediaStateMessage = message;
            }

            _reportStateTask.Fire();
        }