Skip to content

Commit

Permalink
MediaFoundationReader the default for AudioFileReader to use for MP3s…
Browse files Browse the repository at this point in the history
… going forwards
  • Loading branch information
markheath committed May 10, 2022
1 parent a01a0a6 commit d66e682
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
5 changes: 4 additions & 1 deletion NAudio/AudioFileReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ private void CreateReaderStream(string fileName)
}
else if (fileName.EndsWith(".mp3", StringComparison.OrdinalIgnoreCase))
{
readerStream = new Mp3FileReader(fileName);
if (Environment.OSVersion.Version.Major < 6)
readerStream = new Mp3FileReader(fileName);
else // make MediaFoundationReader the default for MP3 going forwards
readerStream = new MediaFoundationReader(fileName);
}
else if (fileName.EndsWith(".aiff", StringComparison.OrdinalIgnoreCase) || fileName.EndsWith(".aif", StringComparison.OrdinalIgnoreCase))
{
Expand Down
2 changes: 1 addition & 1 deletion NAudioDemo/AudioPlaybackDemo/DirectSoundOutPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public bool IsAvailable

public int Priority
{
get { return 2; }
get { return 3; }
}
}
}
2 changes: 1 addition & 1 deletion NAudioDemo/AudioPlaybackDemo/WasapiOutPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public bool IsAvailable

public int Priority
{
get { return 3; }
get { return 1; }
}
}
}
8 changes: 8 additions & 0 deletions NAudioDemo/AudioPlaybackDemo/WasapiOutSettingsPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,24 @@ private void InitialiseWasapiControls()
var enumerator = new MMDeviceEnumerator();
var endPoints = enumerator.EnumerateAudioEndPoints(DataFlow.Render, DeviceState.Active);
var comboItems = new List<WasapiDeviceComboItem>();
var defaultEndPoint = enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);

foreach (var endPoint in endPoints)
{
var comboItem = new WasapiDeviceComboItem();
comboItem.Description = string.Format("{0} ({1})", endPoint.FriendlyName, endPoint.DeviceFriendlyName);
comboItem.Device = endPoint;
comboItems.Add(comboItem);

}
comboBoxWaspai.DisplayMember = "Description";
comboBoxWaspai.ValueMember = "Device";
comboBoxWaspai.DataSource = comboItems;
var defaultItemIndex = comboItems.FindIndex(ci => ci.Device.ID == defaultEndPoint.ID);
if (defaultItemIndex != -1)
comboBoxWaspai.SelectedIndex = defaultItemIndex;


}

public MMDevice SelectedDevice { get { return (MMDevice)comboBoxWaspai.SelectedValue; } }
Expand Down
2 changes: 1 addition & 1 deletion NAudioDemo/AudioPlaybackDemo/WaveOutPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public bool IsAvailable

public int Priority
{
get { return 1; }
get { return 2; }
}
}
}
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### 2.1 (29 Apr 2022)

* `AudioFileReader` will use `MediaFoundationReader` as the default for MP3s
* Minimum supported Win 10 version is now uap10.0.18362 (SDK version 1903)
* `IWavePlayer` now has an `OuputWaveFormat` property
* `WasapiCapture` and `WasapiLoopbackCapture` support sample rate conversion so you can capture at a sample rate of your choice
Expand Down

0 comments on commit d66e682

Please sign in to comment.