Crash on FMOD_System_Close with ASIO

Everything works fine in the project, except it crashes with FMOD_OUTPUTTYPE_ASIO when quitting. Switching to FMOD_OUTPUTTYPE_WASAPI, the issue is gone.

I stripped almost all code to find the issue. Crashes about 50% when testing:

EnableExplicit

#FMOD_VERSION = $00020223
Enumeration
  #FMOD_OUTPUTTYPE_AUTODETECT
  #FMOD_OUTPUTTYPE_UNKNOWN
  #FMOD_OUTPUTTYPE_NOSOUND
  #FMOD_OUTPUTTYPE_WAVWRITER
  #FMOD_OUTPUTTYPE_NOSOUND_NRT
  #FMOD_OUTPUTTYPE_WAVWRITER_NRT
  #FMOD_OUTPUTTYPE_WASAPI
  #FMOD_OUTPUTTYPE_ASIO
  #FMOD_OUTPUTTYPE_PULSEAUDIO
  #FMOD_OUTPUTTYPE_ALSA
  #FMOD_OUTPUTTYPE_COREAUDIO
  #FMOD_OUTPUTTYPE_AUDIOTRACK
  #FMOD_OUTPUTTYPE_OPENSL
  #FMOD_OUTPUTTYPE_AUDIOOUT
  #FMOD_OUTPUTTYPE_AUDIO3D
  #FMOD_OUTPUTTYPE_WEBAUDIO
  #FMOD_OUTPUTTYPE_NNAUDIO
  #FMOD_OUTPUTTYPE_WINSONIC
  #FMOD_OUTPUTTYPE_AAUDIO
  #FMOD_OUTPUTTYPE_AUDIOWORKLET
  #FMOD_OUTPUTTYPE_PHASE
;   #FMOD_OUTPUTTYPE_MAX
  EndEnumeration

#FMOD_OK = 0

CoInitializeEx_(0, #COINIT_APARTMENTTHREADED)
Define *hDLL = OpenLibrary(#PB_Any, "fmod.dll")
If *hDLL
  Define *hSystem
  If CallFunction(*hDLL, "FMOD_System_Create", @*hSystem, #FMOD_VERSION) = #FMOD_OK
    If *hSystem
      Sleep_(1)
      If CallFunction(*hDLL, "FMOD_System_SetOutput", *hSystem, #FMOD_OUTPUTTYPE_ASIO) = #FMOD_OK
        Sleep_(1)
        If CallFunction(*hDLL, "FMOD_System_SetDriver", *hSystem, 0) = #FMOD_OK
          Sleep_(1)
          If CallFunction(*hDLL, "FMOD_System_Init", *hSystem, 256, 0, 0) = #FMOD_OK
            Sleep_(1)
            Define.i hWin = OpenWindow(#PB_Any, 0, 0, 1024, 264, "LineSpec Test Window")
            Repeat
              Select WindowEvent()
                Case #PB_Event_CloseWindow
                  Break
                EndSelect
              ForEver
            EndIf
          EndIf
        EndIf
      Sleep_(1)
Debug "Releasing..."
      CallFunction(*hDLL, "FMOD_System_Close", *hSystem)
Debug "Released"
      Sleep_(1)
      CallFunction(*hDLL, "FMOD_System_Release", *hSystem)
      Sleep_(1)
      EndIf
    EndIf
  CloseLibrary(*hDLL)
  EndIf
CoUninitialize_()
Debug "Quit"

Hi,

Thank you for bringing this to our attention.

Unfortunately, testing in our core API examples I couldn’t reproduce the issue. Are you able to reproduce the issue in our examples? On a windows they can be found here: "C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\core\examples\vs2019\examples.sln".

How would I test your code? Any reproduction steps would be greatly appreciated.

Seems this error (sometimes?) has some big impact.
Didn’t crash anymore, but had no sound at all with the ASIO audio device. Sometimes no playback progress, or progress stopping after some time due no reason. After switching the device off, playback progress continued bumb

Finally decided to reboot the PC to fix this.

Now another reboot, immediately running VS…

I’d guess this could be some driver issue? Maybe any idea, or some info what’s the exact issue, so I can contact the vendor - so I wonder if the device is supported anymore.

/*==============================================================================
Play Sound Example
Copyright (c), Firelight Technologies Pty, Ltd 2004-2024.

This example shows how to simply load and play multiple sounds, the simplest 
usage of FMOD. By default FMOD will decode the entire file into memory when it
loads. If the sounds are big and possibly take up a lot of RAM it would be
better to use the FMOD_CREATESTREAM flag, this will stream the file in realtime
as it plays.

For information on using FMOD example code in your own programs, visit
https://www.fmod.com/legal
==============================================================================*/
#include "fmod.hpp"
#include "common.h"

int FMOD_Main()
{
    FMOD::System     *system;
    FMOD_RESULT       result;
    void             *extradriverdata = 0;
    
    Common_Init(&extradriverdata);

    /*
        Create a System object and initialize
    */
    result = FMOD::System_Create(&system, FMOD_VERSION);
    ERRCHECK(result);

    /* Changes ... Running VS22 community with VS19 build tools ... running x64 */
    // Added...
    result = system->setOutput(FMOD_OUTPUTTYPE_ASIO);
    ERRCHECK(result);

    // Added...
    result = system->setDriver(0);
    ERRCHECK(result);

    /* End changes */

    result = system->init(32, FMOD_INIT_NORMAL, extradriverdata);
    ERRCHECK(result);

//        Common_Update();
//        result = system->update();
//        ERRCHECK(result);

//        Common_Sleep(50);

    /*
        Shut down
    */
    result = system->close();
    ERRCHECK(result);
    result = system->release();
    ERRCHECK(result);

    Common_Close();

    return 0;
}

Thank you for the information and the code.

Would it be possible to run DxDiag? Instructions can be found here: Open and run DxDiag.exe - Microsoft Support. The results can be uploaded to your profile here: FMOD | Profile - Upload. Please note you will have to register a project with us to be able to upload files.

What device are you trying to output to with the call result = system->setDriver(0);? What version of the FMOD engine are you using?

DxDiag download link here:
Link

Notes:
Think this after the VS test crash issue. Did a quick check after the DxDiag, and sound output was ok, crash as usual. If you need a specific DxDiag.txt - before a crash, after a crash or when in no-sound-state - Let me know.

Page File: 16907MB used, 81577MB available
Aktually, Windows is set to: “Total paging file size for all drives: 386 MB”, and there only is a page file on drive C: with around 386 MB. No pagefile on any other drive. Guess this number includes the physical RAM? Have such wrong values since Windows XP.

+++ WER4 +++ Event Name: GDIObjectLeak P1: explorer.exe
Before having 96 GB Ram, the system sometimes had out of memory issues with explorer reserving up to 40 GB Ram. I want upgrade to 128 GB, but the BIOS has huge issues with RAM making it hard to get the latest setup working without memory corruptions occurring. No out of memory issues unless when heavy surfing with Firefox :slight_smile: !

Due the ASIO issues, the fmod.dll for the project was recently updated (from 2.02.18) to 2.02.23. The Visual Studio project test is 2.02.23 (fmodstudioapi20223win-installer.exe)

The device is “ADJ ASIO” (American Audio 14MXR)
[09:31:54] [Debug] FMOD: ASIO-device 0: ADJ ASIO
[09:31:54] [Debug] FMOD: ASIO-device 1: DUO-CAPTURE EX
Log excerp, modified

Some positive news: Tried the project yesterday when visiting a friend on a more professional gear, and there were no issues (so far). :smiley:

Thank you for the DxDiag, I was mainly looking into your connected output devices which FMOD may be trying to access. As you mentioned there are two that FMOD has identified.

Where did you get the log file from? I can see two FMOD systems attempting to initialize using both the ADJ ASIO device and the DUO-CAPTURE EX device.

FMOD: Creating system on ASIO-device 0: ADJ ASIO (channels 0/1)
FMOD: Creating system on AUTODETECT-device 0: OUT (DUO-CAPTURE EX)

FMOD: Closing system on AUTODETECT-device 0: OUT (DUO-CAPTURE EX)
FMOD: Closing system on ASIO-device 0: ADJ ASIO (channels 2/3)

Would it be possible that having two systems running simultaneously could be causing the issue?

That is good to hear! Is there anything immediately obvious that would not cause the crash on their device?

The real project uses FMOD multiple times. First temporarily for enumerating, two for audio players, two for tag reading / getting wave-data (no output, separate threads). No issues so far, except since the change to ASIO. BTW; using two ASIO system with FMOD.

To find the issues, we ended up creating the small test program. as posted above.
Could be a driver issue. Only had the device for a few days (for testing / coding ASIO subchannels support and reusing ASIO device / sound system) and will give it back on Thursday.
Are there some debug info files (pdb or so) to get further info?

Thank you for the information. Sounds like the multiple systems are not the issue.

Would it be possible to upload this program to your profile?

Unfortunately, we cannot share the PDBs. Rather, could I get a crash dump to go through on my side?

Here you go!
Minidump
Minidump with heap

1 Like

Thank you, I have been able to confirm the issue is with the 14 MXR drivers. I will pass on the issue to our development team to investigate further. Are you able to use any other drivers in the meantime?

Hello, only had the device for a few days for testing. If needed I can lend the device again. If you want I can contact the manufacturer about the issue, maybe with a link to this forum post. As it’s pretty obviously a driver issue, I don’t want to bother you to much with the issue.

1 Like

The issue is indeed with a non-compliant ASIO driver, but I have found a sufficient workaround. 2.02.25 will include the fix/workaround allowing interaction with the driver without crash.

1 Like