From 7b01715a1124c07becb28dd7e432b7085a33367d Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 5 Oct 2021 09:54:02 -0700 Subject: [PATCH] Safer way of detecing platform --- RedBookPlayer.GUI/RedBookPlayer.GUI.csproj | 1 + RedBookPlayer.Models/Hardware/SoundOutput.cs | 13 +++++-------- RedBookPlayer.Models/RedBookPlayer.Models.csproj | 12 ++---------- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/RedBookPlayer.GUI/RedBookPlayer.GUI.csproj b/RedBookPlayer.GUI/RedBookPlayer.GUI.csproj index 22e946e..c0be0a2 100644 --- a/RedBookPlayer.GUI/RedBookPlayer.GUI.csproj +++ b/RedBookPlayer.GUI/RedBookPlayer.GUI.csproj @@ -9,6 +9,7 @@ WindowsDebug + %(Filename) diff --git a/RedBookPlayer.Models/Hardware/SoundOutput.cs b/RedBookPlayer.Models/Hardware/SoundOutput.cs index ed6c71d..27a1047 100644 --- a/RedBookPlayer.Models/Hardware/SoundOutput.cs +++ b/RedBookPlayer.Models/Hardware/SoundOutput.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using System.Runtime.InteropServices; using System.Threading.Tasks; using ReactiveUI; using RedBookPlayer.Models.Discs; @@ -118,7 +119,6 @@ namespace RedBookPlayer.Models.Hardware Volume = defaultVolume; _filterStage = new FilterStage(); } - /// /// Initialize the output with a given image @@ -367,13 +367,10 @@ namespace RedBookPlayer.Models.Hardware { _source = new PlayerSource(ProviderRead); -#if LINUX - _soundOut = new Linux.AudioBackend(_source); -#elif MACOS - _soundOut = new Mac.AudioBackend(_source); -#elif WINDOWS - _soundOut = new Windows.AudioBackend(_source); -#endif + if(RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + _soundOut = new Linux.AudioBackend(_source); + else if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + _soundOut = new Windows.AudioBackend(_source); } else { diff --git a/RedBookPlayer.Models/RedBookPlayer.Models.csproj b/RedBookPlayer.Models/RedBookPlayer.Models.csproj index 4b505f2..c0a4c68 100644 --- a/RedBookPlayer.Models/RedBookPlayer.Models.csproj +++ b/RedBookPlayer.Models/RedBookPlayer.Models.csproj @@ -2,19 +2,11 @@ netcoreapp3.1 + win-x64;linux-x64 + linux-x64 true - - LINUX - - - MAC - - - WINDOWS - -