sharpdx / SharpDX

SharpDX GitHub Repository
http://sharpdx.org
MIT License
1.7k stars 639 forks source link

DeviceCount fails on Windows 10 machine with xaudio2 version 28 #753

Open bbfe opened 8 years ago

bbfe commented 8 years ago
System.InvalidOperationException was unhandled
  HResult=-2146233079
  Message=This method is only valid on the XAudio 2.7 requestedVersion [Current is: Version28]
  Source=SharpDX.XAudio2
  StackTrace:
       at SharpDX.XAudio2.XAudio2.CheckVersion27()
       at SharpDX.XAudio2.XAudio2.get_DeviceCount()
       at BigBlue.XAudio2Player..ctor(Single volume) in D:\bbspeech\FrontEndFreddie\XAudio2Player.cs:line 73
       at BigBlueFrontend.MainWindow.initializeFrontEnd() in D:\bbspeech\FrontEndFreddie\MainWindow.xaml.cs:line 10538
       at BigBlueFrontend.MainWindow.startFrontend() in D:\bbspeech\FrontEndFreddie\MainWindow.xaml.cs:line 11851
       at BigBlueFrontend.App.Main(String[] args) in D:\bbspeech\FrontEndFreddie\App.xaml.cs:line 101
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
maurocos commented 8 years ago

The same error occurs on windows phone 8.1 "This method is only valid on the XAudio 2.7 requestedVersion [Current is: Version28]"

xoofx commented 8 years ago

So as it is stated, the property XAudio2.DedviceCount is no longer available in XAudio 2.8, so you cannot use it.

maurocos commented 8 years ago

Thanks, but I am using these commands in c #. What should I change?

Volume = Convert.ToSingle(App.slideEffects / 100); XAudio2 xAudio = new XAudio2(); var masteringVoice = new MasteringVoice(xAudio); NativeFileStream nativeFileStream = new NativeFileStream(strPath, NativeFileMode.Open, NativeFileAccess.Read, NativeFileShare.Read); SoundStream stream = new SoundStream(nativeFileStream); var waveFormat = stream.Format; AudioBuffer buffer = new AudioBuffer { Stream = stream.ToDataStream(), AudioBytes = (int)stream.Length, Flags = BufferFlags.EndOfStream };

                var sourceVoice = new SourceVoice(xAudio, waveFormat, true);

                sourceVoice.SubmitSourceBuffer(buffer, stream.DecodedPacketsInfo);
                sourceVoice.SetVolume(Volume);
                sourceVoice.Start();
xoofx commented 8 years ago

@maurocos open another issue for this as I'm not sure it is related. Give more details with exceptions...etc.

maurocos commented 8 years ago

@xoofx Ok. Thanks for reply (the exception is the same about DeviceCount). Bye