Ejemplo n.º 1
0
        private void StartReadBuffer()
        {
            Debug.Assert(_readBuffer == null);

            // OnAudioFilterRead reads the variable concurrently, but the update is atomic
            // so we don't need a lock.
            _readBuffer = _source.CreateReadBuffer();
        }
Ejemplo n.º 2
0
 private void StopReadBuffer()
 {
     lock (_readBufferLock)
     {
         // Under lock so OnAudioFilterRead won't use the buffer while/after it is disposed.
         _readBuffer.Dispose();
         _readBuffer = null;
     }
 }
Ejemplo n.º 3
0
        // Must be called within Unity main thread.
        private void StartStreaming()
        {
            Debug.Assert(_readBuffer == null);

            // OnAudioFilterRead reads the variable concurrently, but the update is atomic
            // so we don't need a lock.
            _readBuffer = Track.CreateReadBuffer();

            _isLive     = true;
            IsStreaming = true;
            AudioStreamStarted.Invoke(this);
        }
Ejemplo n.º 4
0
        // Must be called within Unity main thread.
        private void StopStreaming()
        {
            _isLive = false;
            AudioStreamStopped.Invoke(this);
            IsStreaming = false;

            lock (_readBufferLock)
            {
                // Under lock so OnAudioFilterRead won't use the buffer while/after it is disposed.
                _readBuffer.Dispose();
                _readBuffer = null;
            }
        }