| @@ -41,7 +41,7 @@ namespace ScreamReader · 40 unmodified lines |
| 41 | | 41 | |
| 42 | private UdpClient udpClient; | 42 | private UdpClient udpClient; |
| 43 | | 43 | |
| 44 | private WaveOut output; | 44 | private WasapiOut output; |
| 45 | | 45 | |
| 46 | private int volume; | 46 | private int volume; |
| 47 | #endregion | 47 | #endregion |
| @@ -122,10 +122,7 @@ namespace ScreamReader · 74 unmodified lines |
| 122 | | 122 | |
| 123 | var rsws = new BufferedWaveProvider(new WaveFormat(44100, currentWidth, currentChannels)) { BufferDuration = TimeSpan.FromMilliseconds(200), DiscardOnBufferOverflow = true }; | 123 | var rsws = new BufferedWaveProvider(new WaveFormat(44100, currentWidth, currentChannels)) { BufferDuration = TimeSpan.FromMilliseconds(200), DiscardOnBufferOverflow = true }; |
| 124 | | 124 | |
| 125 | this.output = new WaveOut() | 125 | this.output = new WasapiOut(); |
| 126 | { | | |
| 127 | DesiredLatency = 200 | | |
| 128 | }; | | |
| 129 | this.Volume = 100; | 126 | this.Volume = 100; |
| 130 | | 127 | |
| 131 | this.output.Init(rsws); | 128 | this.output.Init(rsws); |
| @@ -151,20 +148,22 @@ namespace ScreamReader · 19 unmodified lines |
| 151 | // TODO find a way to set a channel map in NAudio. I was not able to find any. | 148 | // TODO find a way to set a channel map in NAudio. I was not able to find any. |
| 152 | // In practice if both the source and the receiver windows machine have the same speakers configuration setted this doesn't matter, | 149 | // In practice if both the source and the receiver windows machine have the same speakers configuration setted this doesn't matter, |
| 153 | // but in all other cases the channels will be possibly mismatched. | 150 | // but in all other cases the channels will be possibly mismatched. |
| 154 | | | |
| 155 | this.output.Stop(); | 151 | this.output.Stop(); |
| 156 | var rate = ((currentRate >= 128) ? 44100 : 48000) * (currentRate % 128); | 152 | var rate = ((currentRate >= 128) ? 44100 : 48000) * (currentRate % 128); |
| | 153 | |
| 157 | rsws = new BufferedWaveProvider(new WaveFormat(rate, currentWidth, currentChannels)) { BufferDuration = TimeSpan.FromMilliseconds(200), DiscardOnBufferOverflow = true }; | 154 | rsws = new BufferedWaveProvider(new WaveFormat(rate, currentWidth, currentChannels)) { BufferDuration = TimeSpan.FromMilliseconds(200), DiscardOnBufferOverflow = true }; |
| 158 | this.output = new WaveOut() | 155 | this.output = new WasapiOut(); |
| 159 | { | | |
| 160 | DesiredLatency = 200 | | |
| 161 | }; | | |
| 162 | this.Volume = 100; | 156 | this.Volume = 100; |
| 163 | this.output.Init(rsws); | 157 | this.output.Init(rsws); |
| 164 | this.output.Play(); | 158 | this.output.Play(); |
| 165 | } | 159 | } |
| 166 | rsws.AddSamples(data, 5, data.Length - 5); | 160 | rsws.AddSamples(data, 5, data.Length - 5); |
| 167 | } catch (SocketException) { } // Usually when interrupted | 161 | } catch (SocketException) { } // Usually when interrupted |
| | 162 | catch(Exception e) |
| | 163 | { |
| | 164 | System.Windows.Forms.MessageBox.Show(e.StackTrace, e.Message); |
| | 165 | |
| | 166 | } |
| 168 | } | 167 | } |
| 169 | }, this.cancellationTokenSource.Token); | 168 | }, this.cancellationTokenSource.Token); |
| 170 | | 169 | |