0

Like in subject, everything works fine in AnyCPU, but when I change to x86 -> application crash. I work under Win 7 x64.

Edit:

(Exception from HRESULT: 0x80070057 (E_INVALIDARG))"}  

Stack:

   at System.StubHelpers.InterfaceMarshaler.ConvertToManaged(IntPtr pUnk, IntPtr itfMT, IntPtr classMT, Int32 flags)  
   at NAudio.Wave.DirectSoundOut.IDirectSound.CreateSoundBuffer(BufferDescription desc, Object& dsDSoundBuffer, IntPtr pUnkOuter)  
   at NAudio.Wave.DirectSoundOut.InitializeDirectSound()  
   at NAudio.Wave.DirectSoundOut.PlaybackThreadFunc()  
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)  
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)  
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)  
   at System.Threading.ThreadHelper.ThreadStart()
apocalypse
  • 5,764
  • 9
  • 47
  • 95
  • Without any details about the code or the crash it's impossible to offer any advice. – Brian Rasmussen Jan 30 '13 at 05:25
  • Sry, I thoguht it's configuration issue. However, I added error message. Also I checked it @ Windows Xp in VirtualBox, and it works fine in 32 bit mode. – apocalypse Jan 30 '13 at 05:58

1 Answers1

1

Strange, the only input parameter of note is the buffer description (an instance of DSBUFFERDESC), but I can't see any x64/x86 issues with the NAudio interop for it. Maybe some of the secondary buffer flags aren't supported on your device:

bufferDesc2.dwFlags = DirectSoundBufferCaps.DSBCAPS_GETCURRENTPOSITION2
    | DirectSoundBufferCaps.DSBCAPS_CTRLPOSITIONNOTIFY
    | DirectSoundBufferCaps.DSBCAPS_GLOBALFOCUS
    | DirectSoundBufferCaps.DSBCAPS_CTRLVOLUME
    | DirectSoundBufferCaps.DSBCAPS_STICKYFOCUS;

The other odd thing about the stack trace is that the error is in ConvertToManaged, which suggests that it is the conversion of the sound buffer to a managed object which is going wrong, but I can't think why that would happen, as we don't try to cast to IDirectSoundBuffer until after the call to CreateSoundBuffer completes.

Any reason why your app can't use WaveOut or WaveOutEvent instead? You might find them more reliable.

Mark Heath
  • 48,273
  • 29
  • 137
  • 194
  • My application uses WaveOut (not event version), DirecSound, ASIO and WASAPI. However ASIO and WASAPI crashes application after random calls to stop/play. Anyway I dont understand your answer, too complicated for me. +1 – apocalypse Jan 31 '13 at 06:53