History

Support dynamic bitrate

duncanthrax committed 7 years ago

Commit 263da991 parent 9fe175e7 files · +46 −43Browse files

Unified · Split

7 files
  1. Install/driver/Scream.inf +1 −1
  2. Install/driver/Scream.sys +0 −0
  3. Install/driver/scream.cat +0 −0
  4. Receivers/dotnet-windows/ScreamReader/ScreamReader/App.config +3 −3
  5. Receivers/dotnet-windows/ScreamReader/ScreamReader/Properties/Settings.Designer.cs +9 −13
  6. Receivers/dotnet-windows/ScreamReader/ScreamReader/ScreamReader.csproj +7 −1
  7. Receivers/dotnet-windows/ScreamReader/ScreamReader/UdpWaveStreamPlayer.cs +28 −27
Install/driver/Scream.inf+1−1
@@ -3,7 +3,7 @@ Signature="$CHICAGO$" · 2 unmodified lines
33 Class=MEDIA
44 Provider=%SCR%
55 ClassGUID={4d36e96c-e325-11ce-bfc1-08002be10318}
6−DriverVer = 06/02/2018,23.38.3.982
6+DriverVer = 11/29/2018,21.2.39.303
77 CatalogFile=scream.cat
88
99 [SourceDisksNames]
Install/driver/Scream.sys+0−0

Binary file not shown.

Install/driver/scream.cat+0−0

Binary file not shown.

Receivers/dotnet-windows/ScreamReader/ScreamReader/App.config+3−3
@@ -1,6 +1,6 @@
1−<?xml version="1.0" encoding="utf-8" ?>
1+<?xml version="1.0" encoding="utf-8"?>
22 <configuration>
33 <startup>
4− <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
4+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
55 </startup>
6−</configuration>
6+</configuration>
Receivers/dotnet-windows/ScreamReader/ScreamReader/Properties/Settings.Designer.cs+9−13
@@ -8,21 +8,17 @@ · 7 unmodified lines
88 // </auto-generated>
99 //------------------------------------------------------------------------------
1010
11−namespace ScreamReader.Properties
12−{
13−
14−
11+namespace ScreamReader.Properties {
12+
13+
1514 [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16− [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17− internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18− {
19−
15+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
16+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17+
2018 private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21−
22− public static Settings Default
23− {
24− get
25− {
19+
20+ public static Settings Default {
21+ get {
2622 return defaultInstance;
2723 }
2824 }
Receivers/dotnet-windows/ScreamReader/ScreamReader/ScreamReader.csproj+7−1
@@ -8,9 +8,10 @@ · 7 unmodified lines
88 <OutputType>WinExe</OutputType>
99 <RootNamespace>ScreamReader</RootNamespace>
1010 <AssemblyName>ScreamReader</AssemblyName>
11− <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
11+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1212 <FileAlignment>512</FileAlignment>
1313 <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+ <TargetFrameworkProfile />
1415 </PropertyGroup>
1516 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1617 <PlatformTarget>AnyCPU</PlatformTarget>
@@ -21,6 +22,7 @@ · 4 unmodified lines
2122 <DefineConstants>DEBUG;TRACE</DefineConstants>
2223 <ErrorReport>prompt</ErrorReport>
2324 <WarningLevel>4</WarningLevel>
25+ <Prefer32Bit>false</Prefer32Bit>
2426 </PropertyGroup>
2527 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2628 <PlatformTarget>AnyCPU</PlatformTarget>
@@ -30,6 +32,10 @@ · 3 unmodified lines
3032 <DefineConstants>TRACE</DefineConstants>
3133 <ErrorReport>prompt</ErrorReport>
3234 <WarningLevel>4</WarningLevel>
35+ <Prefer32Bit>false</Prefer32Bit>
36+ </PropertyGroup>
37+ <PropertyGroup>
38+ <StartupObject />
3339 </PropertyGroup>
3440 <ItemGroup>
3541 <Reference Include="NAudio, Version=1.8.3.0, Culture=neutral, processorArchitecture=MSIL">
Receivers/dotnet-windows/ScreamReader/ScreamReader/UdpWaveStreamPlayer.cs+28−27
@@ -20,11 +20,6 @@ namespace ScreamReader · 19 unmodified lines
2020 /// The port scream is broadcasting on.
2121 /// </summary>
2222 public static readonly int ScreamMulticastPort = 4010;
23−
24− /// <summary>
25− /// Default <see cref="waveFormat"/> is 44.1 kHz, 16 bits, stereo.
26− /// </summary>
27− public static readonly WaveFormat ScreamWaveFormat = new WaveFormat();
2823 #endregion
2924
3025 #region instance variables
@@ -37,12 +32,7 @@ namespace ScreamReader · 6 unmodified lines
3732 /// The port to listen to.
3833 /// </summary>
3934 protected int multicastPort { get; set; }
40−
41− /// <summary>
42− /// The used <see cref="waveFormat"/>.
43− /// </summary>
44− protected WaveFormat waveFormat { get; set; }
45−
35+
4636 private Semaphore startLock;
4737
4838 private Semaphore shutdownLock;
@@ -81,7 +71,7 @@ namespace ScreamReader · 32 unmodified lines
8171 /// Default c'tor that supports Scream's default settings.
8272 /// </summary>
8373 public UdpWaveStreamPlayer()
84− : this(ScreamMulticastAddress, ScreamMulticastPort, ScreamWaveFormat)
74+ : this(ScreamMulticastAddress, ScreamMulticastPort)
8575 {
8676 }
8777
@@ -90,26 +80,18 @@ namespace ScreamReader · 2 unmodified lines
9080 /// </summary>
9181 /// <param name="multicastAddress"></param>
9282 /// <param name="multicastPort"></param>
93− /// <param name="waveFormat"></param>
94− public UdpWaveStreamPlayer(IPAddress multicastAddress, int multicastPort, WaveFormat waveFormat)
83+ public UdpWaveStreamPlayer(IPAddress multicastAddress, int multicastPort)
9584 {
9685 this.multicastAddress = multicastAddress;
9786 this.multicastPort = multicastPort;
98− this.waveFormat = waveFormat;
9987
10088 this.startLock = new Semaphore(1, 1);
10189 this.shutdownLock = new Semaphore(0, 1);
102− this.output = new WaveOut()
103− {
104− DesiredLatency = 80
105− };
106−
90+
10791 this.udpClient = new UdpClient
10892 {
10993 ExclusiveAddressUse = false
11094 };
111−
112− this.Volume = 100;
11395 }
11496
11597 /// <summary>
@@ -123,17 +105,21 @@ namespace ScreamReader · 7 unmodified lines
123105
124106 Task.Factory.StartNew(() =>
125107 {
108+ var currentRate = 129;
109+ var currentWidth = 16;
126110 var localEp = new IPEndPoint(IPAddress.Any, this.multicastPort);
127111
128112 this.udpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
129113 this.udpClient.Client.Bind(localEp);
130114 this.udpClient.JoinMulticastGroup(this.multicastAddress);
131115
116+ var rsws = new BufferedWaveProvider(new WaveFormat(44100, 16, 2)) { BufferDuration = TimeSpan.FromMilliseconds(200), DiscardOnBufferOverflow = true };
132117
133− var rsws = new BufferedWaveProvider(new WaveFormat())
118+ this.output = new WaveOut()
134119 {
135− BufferDuration = TimeSpan.FromMilliseconds(500)
120+ DesiredLatency = 200
136121 };
122+ this.Volume = 100;
137123
138124 this.output.Init(rsws);
139125 this.output.Play();
@@ -145,15 +131,31 @@ namespace ScreamReader · 5 unmodified lines
145131 try
146132 {
147133 Byte[] data = this.udpClient.Receive(ref localEp);
148− rsws.AddSamples(data, 0, data.Length);
134+
135+ if (data[0] != currentRate || data[1] != currentWidth)
136+ {
137+ currentRate = data[0];
138+ currentWidth = data[1];
139+ this.output.Stop();
140+ var rate = ((currentRate >= 128) ? 44100 : 48000) * (currentRate % 128);
141+ rsws = new BufferedWaveProvider(new WaveFormat(rate, currentWidth, 2)) { BufferDuration = TimeSpan.FromMilliseconds(200), DiscardOnBufferOverflow = true };
142+ this.output = new WaveOut()
143+ {
144+ DesiredLatency = 200
145+ };
146+ this.Volume = 100;
147+ this.output.Init(rsws);
148+ this.output.Play();
149+ }
150+ rsws.AddSamples(data, 2, data.Length - 2);
149151 } catch (SocketException) { } // Usually when interrupted
150152 }
151153 }, this.cancellationTokenSource.Token);
152154
153155 this.shutdownLock.WaitOne();
154156
155− this.udpClient.Close();
156157 this.output.Stop();
158+ this.udpClient.Close();
157159 }, this.cancellationTokenSource.Token);
158160 }
159161
@@ -177,7 +179,6 @@ namespace ScreamReader · 17 unmodified lines
177179 {
178180 if (disposing)
179181 {
180− this.udpClient.Dispose();
181182 this.startLock.Dispose();
182183 this.shutdownLock.Dispose();
183184 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t