public void OnRecordingDataAvailable(byte[] dataToSend, WaveFormat format, int reduceLagThreshold)
 {
     if (streamingConnection != null)
     {
         if (streamingConnection.IsConnected())
         {
             if (deviceState != DeviceState.Paused)
             {
                 streamingConnection.SendData(dataToSend, format, reduceLagThreshold);
             }
         }
         else
         {
             Console.WriteLine(string.Format("Connection closed from {0}", streamingConnection.GetRemoteEndPoint()));
             streamingConnection = null;
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Stream the recorded data to the device.
        /// </summary>
        /// <param name="dataToSend">tha audio data</param>
        /// <param name="format">the wav format</param>
        /// <param name="reduceLagThreshold">lag value</param>
        /// <param name="streamFormat">the stream format</param>
        public void OnRecordingDataAvailable(byte[] dataToSend, WaveFormat format, int reduceLagThreshold, SupportedStreamFormat streamFormat)
        {
            if (streamingConnection == null || dataToSend == null || dataToSend.Length == 0)
            {
                return;
            }

            if (streamingConnection.IsConnected())
            {
                if (GetDeviceState() != DeviceState.NotConnected &&
                    GetDeviceState() != DeviceState.Paused) // When you keep streaming to a device when it is paused, the application stops streaming after a while (local buffers full?)
                {
                    streamingConnection.SendData(dataToSend, format, reduceLagThreshold, streamFormat);
                }
            }
            else
            {
                logger.Log($"Connection closed from {streamingConnection.GetRemoteEndPoint()}");
                streamingConnection = null;
            }
        }