public void Stop() { if (at != null) { try { at.Disconnect(); } finally { at = null; } DisconnectedEvent(EventArgs.Empty); } if (m_Recorder != null) { try { //matt note: dispose fails m_Recorder.Dispose(); } finally { m_Recorder = null; } } }
public void Start() { Stop(); try { // Start Connection to Airport Express at = new RAOPClient(ip); at.Volume = Volume; try { at.Connect(); } catch (Exception ex) { at = null; ErrorEventArgs e = new ErrorEventArgs(); e.Error = ErrorEventArgs.ERRORNUMBER.ERRORCONNECTING; e.Exception = ex; ErrorEvent(e); //Console.WriteLine("Connect failed: {0}", e.Message); return; } string s = String.Format("JackStatus: {0}{1}JackType: {2}{3}", at.JackStatus == RAOPClient.JACK_STATUS_CONNECTED ? "connected" : "disconnected", Environment.NewLine, at.JackType == RAOPClient.JACK_TYPE_DIGITAL ? "digital" : "analog", Environment.NewLine); Console.WriteLine(s); // Start recorder //Get device here!!! WaveLib.WaveFormat fmt = new WaveLib.WaveFormat(44100, 16, 2); m_Recorder = new WaveLib.WaveInRecorder(deviceid, fmt, BufferSize, 16, new WaveLib.BufferDoneEventHandler(DataArrived)); ConnectedEvent(EventArgs.Empty); } catch (Exception ex) { ErrorEventArgs e = new ErrorEventArgs(); e.Error = ErrorEventArgs.ERRORNUMBER.ERRORRECORDING; e.Exception = ex; ErrorEvent(e); at = null; Stop(); //throw; } }
public void Stop() { if (at != null) { try { at.Disconnect(); } finally { at = null; } DisconnectedEvent(EventArgs.Empty); } if (m_Recorder != null) try { //matt note: dispose fails m_Recorder.Dispose(); } finally { m_Recorder = null; } }
public void Stop() { if (waveInStream != null) try { waveInStream.StopRecording(); waveInStream.Dispose(); } finally { waveInStream = null; } if (at != null) { try { at.Disconnect(); } finally { at = null; } DisconnectedEvent(EventArgs.Empty); } }
public void Start() { Stop(); try { // Start Connection to Airport Express at = new RAOPClient(ip); at.Volume = Volume; try { at.Connect(); } catch (Exception ex) { at = null; ErrorEventArgs e = new ErrorEventArgs(); e.Error = ErrorEventArgs.ERRORNUMBER.ERRORCONNECTING; e.Exception = ex; ErrorEvent(e); //Console.WriteLine("Connect failed: {0}", e.Message); return; } string s = String.Format("JackStatus: {0}{1}JackType: {2}{3}", at.JackStatus == RAOPClient.JACK_STATUS_CONNECTED ? "connected" : "disconnected", Environment.NewLine, at.JackType == RAOPClient.JACK_TYPE_DIGITAL ? "digital" : "analog", Environment.NewLine); //Console.WriteLine(s); // Start recorder //NAudio.Wave.WaveFormat fmt = new NAudio.Wave.WaveFormat(44100, 16, 2); //Player.BufferSize = fmt.AverageBytesPerSecond; //m_Recorder = new WaveLib.WaveInRecorder(-1, fmt, BufferSize, 3, new WaveLib.BufferDoneEventHandler(DataArrived)); waveInStream = new WaveIn(); waveInStream.NumberOfBuffers = 3; waveInStream.BufferSize = Player.BufferSize; waveInStream.PreferredBufferType = WaveIn.BufferType.Size; waveInStream.WaveFormat = new NAudio.Wave.WaveFormat(44100, 16, 2); waveInStream.DataAvailable += new EventHandler<WaveInEventArgs>(DataArrived); waveInStream.StartRecording(); ConnectedEvent(EventArgs.Empty); } catch (Exception ex) { ErrorEventArgs e = new ErrorEventArgs(); e.Error = ErrorEventArgs.ERRORNUMBER.ERRORRECORDING; e.Exception = ex; ErrorEvent(e); at = null; Stop(); //throw; } }