private void AudioThread() { try { NetworkStream ns = Client.GetStream(); BinaryReader reader = new BinaryReader(ns); while(Client.Connected) { int size = reader.ReadInt32(); byte[] bytes = reader.ReadBytes(size); AudioFrameReadyEventArgs args = new AudioFrameReadyEventArgs(); AudioFrameData afd = new AudioFrameData(); afd.AudioData = bytes; args.AudioFrame = afd; Context.Send(delegate { if(AudioFrameReady != null) AudioFrameReady(this, args); }, null); } } catch(IOException) { Client.Close(); } }
void AudioClient_FrameReady(object sender, FrameReadyEventArgs e) { AudioFrameReadyEventArgs args = new AudioFrameReadyEventArgs(); AudioFrameData afd = new AudioFrameData(); afd.AudioData = e.Data; args.AudioFrame = afd; AudioFrame = afd; if(AudioFrameReady != null) AudioFrameReady(this, args); }