XNA Creators Club Online
Page 1 of 1 (3 items)
Sort Posts: Previous Next

XAudio2 and MFC

Last post 4/16/2009 3:21 PM by Goz. 2 replies.
  • 4/16/2009 1:08 PM

    XAudio2 and MFC

    I have an MFC app that I am trying to port over to XAudio2 rather than waveOut* (waveOut has SERIOUS problems under Vista and Windows 7 that don't exist under XP :()

    Now I note that XAudio2 requires that you initialise COM with the Multithreaded model.  MFC (OLE specifically it seems), on the other hand, requires that you initialise COM as apartment threaded.  Is there any way around this problem?

    I'm assuming this is the cause of my crash as it seems somewhere internal to XAudio its crashing.  It seems that one of the 4 threads created when I initialise XAudio2 is making an invalid jump.  In fact the thread that is going wrong is the thread whose stack, after initialisation, points to the XAudio dll.  I have spent many hours going over this code and I can only guess that the invalid is occurring as a result of the threading model.

    Might I have to do something truly silly like seperating all audio calls into a seperate thread and pushing messages across to that thread?  I'd really rather not do this.

    Any help would be HUGELY appreciated.
  • 4/16/2009 3:14 PM In reply to

    Re: XAudio2 and MFC

    Well I've gone ahead and implemented the system whereby any calling thread will set a command and then "unwait" a worker thread to execute the command while "waiting" for the return.  Its an entirely lock stepped piece of threading so I just have the thread switching overhead.  I'd rather I didn't have to do this but if it works I'll live.

    Am going to test it now.  Will post back if it appears to fix my problems.
  • 4/16/2009 3:21 PM In reply to

    Re: XAudio2 and MFC

    Hmm am beginning to wonder if my waveOut* problems weren't caused by the same thing ...

    Have so far managed to run for much longer than i've managed up until this point ...
Page 1 of 1 (3 items) Previous Next