ERR_INVALID_HANDLE on createStream() on Linux

When I call createSound() on Linux, it returns ERR_INVALID_HANDLE. Windows and Android work fine. I am using 12.7 version of FMOD.

My code:

    public static Sound LoadStreamedSound(string path)
	{
	    var buffer = FileLoader.LoadFileAsBuffer(path);
		// Internal FMOD pointer points to this memory, so we don't want it to go anywhere.
		var handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);

		var info = new FMOD.CREATESOUNDEXINFO();
		info.length = (uint)buffer.Length;
		info.cbsize = Marshal.SizeOf(info);

		var r = Native.createStream(
				buffer,
				FMOD.MODE.OPENMEMORY | FMOD.MODE.CREATESTREAM,
				ref info,
				out FMOD.Sound newSound
		);
		Console.WriteLine("LOAD RESULTS:" + r); // ERR_INVALID_HANDLE
		return new Sound(newSound, buffer, handle);
	}

Tested some more – and this behavior only happens if I initialize FMOD Studio (which wortks fine by itself). If I just initialize Core library, everything works as intended.

This is how I initialize:

			FMOD.INITFLAGS coreInitFlags = FMOD.INITFLAGS.CHANNEL_LOWPASS | FMOD.INITFLAGS.CHANNEL_DISTANCEFILTER;
			FMOD.Studio.INITFLAGS studioInitFlags = FMOD.Studio.INITFLAGS.NORMAL;

			var r = FMOD.Studio.System.create(out StudioSystem.Native);
			Console.WriteLine("STUDIO CREATE: " + r);

			r = StudioSystem.Native.getCoreSystem(out CoreSystem.Native);
			Console.WriteLine("CORE SYSTEM: " + r);

			// This also will init core system. 
			StudioSystem.Native.initialize(maxChannels, studioInitFlags, coreInitFlags, (IntPtr)0);

Can you try the logging version of FMOD instead, you should get some information output on the TTY as to what is going wrong.

Tried the logger library. This is what it outputted in the console (along with some dotnet stuff). There isn’t anything out of ordinary, it seems. I see some thread permission errors, tho. Running with sudo fixes them, but my game crashes anyway with same error.

[LOG] System::create : Header version = 2.01.07. Current version = 2.01.07.
STUDIO CREATE: OK
fmodstudioL |
CORE SYSTEM: OK
fmodstudioL |
[LOG] Manager::init : maxchannels = 256 studioflags = 00000000 flags 00000300 extradriverdata (nil).
[LOG] SystemI::init : Initialize version=20107 (113487), maxchannels=256, flags=0x00020300
[LOG] SystemI::setOutputInternal : Setting output to ‘FMOD PulseAudio Output’
[LOG] OutputPulseAudio::registerLib : Loaded PulseAudio version 13.99.0.
[LOG] OutputPulseAudio::enumOutput : Found output device NAME:alsa_output.pci-0000_00_05.0.analog-stereo DESC:Built-in Audio Analog Stereo CHANNELS:2 RATE:48000.
[LOG] OutputPulseAudio::enumInput : Found input device NAME:alsa_output.pci-0000_00_05.0.analog-stereo.monitor DESC:Monitor of Built-in Audio Analog Stereo CHANNELS:2 RATE:48000.
[LOG] OutputPulseAudio::enumInput : Found input device NAME:alsa_input.pci-0000_00_05.0.analog-stereo DESC:Built-in Audio Analog Stereo CHANNELS:2 RATE:44100.
[LOG] Thread::initThread : Init FMOD stream thread. Affinity: 0x8000000000000003, Priority: 0xFFFF7FFB, Stack Size: 98304, Semaphore: No, Sleep Time: 10, Looping: Yes.
[WRN] FMOD_OS_Thread_Callback : Cannot set real-time thread priorities due to insufficient privileges
[LOG] Thread::initThread : Init FMOD mixer thread. Affinity: 0x8000000000000001, Priority: 0xFFFF7FFA, Stack Size: 81920, Semaphore: Yes, Sleep Time: 0, Looping: Yes.
[WRN] FMOD_OS_Thread_Callback : Cannot set real-time thread priorities due to insufficient privileges
[LOG] AsyncManager::init : manager 0xd635f8 isAsync 1 updatePeriod 0.02
[LOG] Thread::initThread : Init FMOD Studio update thread. Affinity: 0x8000000000000002, Priority: 0xFFFF7FFD, Stack Size: 98304, Semaphore: No, Sleep Time: 1, Looping: No.
[WRN] OutputPulseAudio::streamUnderflowCallback : Buffer underrun detected in PulseAudio.
[LOG] OutputPulseAudio::streamUnderflowCallback : Increasing buffer size - new block count = 5.
[WRN] FMOD_OS_Thread_Callback : Cannot set real-time thread priorities due to insufficient privileges
[LOG] AsyncManager::init : done
[LOG] PlaybackSystem::init :
[LOG] Thread::initThread : Init FMOD Studio sample load thread. Affinity: 0x8000000000000003, Priority: 0xFFFF7FFD, Stack Size: 98304, Semaphore: No, Sleep Time: 1, Looping: No.
[WRN] FMOD_OS_Thread_Callback : Cannot set real-time thread priorities due to insufficient privileges
[LOG] PlaybackSystem::init : done
[LOG] Thread::initThread : Init FMOD Studio bank load thread. Affinity: 0x8000000000000003, Priority: 0xFFFF7FFD, Stack Size: 98304, Semaphore: No, Sleep Time: 1, Looping: No.
[WRN] FMOD_OS_Thread_Callback : Cannot set real-time thread priorities due to insufficient privileges
[LOG] Manager::init : done.
fmodL |
fmodstudioL |
fmodL |
fmodL |
fmodL |
PLAY RESULTS:ERR_INVALID_HANDLE | FMOD.Channel
fmodL |
fmodL |
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at ChaiFoxes.FMODAudio.Channel…ctor(Sound sound, Channel channel) in D:_Projects\ChaiFoxes.FMODAudio\ChaiFoxes.FMODAudio\ChaiFoxes.FMODAudio.Shared\Channel.cs:line 402
at ChaiFoxes.FMODAudio.Sound.Play(ChannelGroup group, Boolean paused) in D:_Projects\ChaiFoxes.FMODAudio\ChaiFoxes.FMODAudio\ChaiFoxes.FMODAudio.Shared\Sound.cs:line 255
at ChaiFoxes.FMODAudio.Sound.Play(Boolean paused) in D:_Projects\ChaiFoxes.FMODAudio\ChaiFoxes.FMODAudio\ChaiFoxes.FMODAudio.Shared\Sound.cs:line 244
at ChaiFoxes.FMODAudio.Demos.Scenes.CoreDemoScene.Enter() in D:_Projects\ChaiFoxes.FMODAudio\ChaiFoxes.FMODAudio.Demos\ChaiFoxes.FMODAudio.Demos\Scenes\CoreDemoScene.cs:line 40
at ChaiFoxes.FMODAudio.Demos.Scenes.SceneController.ChangeScene(Scene scene) in D:_Projects\ChaiFoxes.FMODAudio\ChaiFoxes.FMODAudio.Demos\ChaiFoxes.FMODAudio.Demos\Scenes\SceneController.cs:line 22
at ChaiFoxes.FMODAudio.Demos.Scenes.DemoSelectorScene.<>c.b__3_2() in D:_Projects\ChaiFoxes.FMODAudio\ChaiFoxes.FMODAudio.Demos\ChaiFoxes.FMODAudio.Demos\Scenes\DemoSelectorScene.cs:line 32
at ChaiFoxes.FMODAudio.Demos.UI.Button.Update() in D:_Projects\ChaiFoxes.FMODAudio\ChaiFoxes.FMODAudio.Demos\ChaiFoxes.FMODAudio.Demos\UI\Button.cs:line 54
at ChaiFoxes.FMODAudio.Demos.UI.UIController.Update() in D:_Projects\ChaiFoxes.FMODAudio\ChaiFoxes.FMODAudio.Demos\ChaiFoxes.FMODAudio.Demos\UI\UIController.cs:line 27
at ChaiFoxes.FMODAudio.Demos.Game1.Update(GameTime gameTime) in D:_Projects\ChaiFoxes.FMODAudio\ChaiFoxes.FMODAudio.Demos\ChaiFoxes.FMODAudio.Demos\Game1.cs:line 106
at Microsoft.Xna.Framework.Game.DoUpdate(GameTime gameTime)
at Microsoft.Xna.Framework.Game.Tick()
at Microsoft.Xna.Framework.SdlGamePlatform.RunLoop()
at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior)
at ChaiFoxes.FMODAudio.Demos.DesktopGL.Program.Main() in D:_Projects\ChaiFoxes.FMODAudio\ChaiFoxes.FMODAudio.Demos\ChaiFoxes.FMODAudio.Demos.DesktopGL\Program.cs:line 11
Aborted (core dumped)

According to your output I see:
PLAY RESULTS:ERR_INVALID_HANDLE | FMOD.Channel

However I don’t see any
LOAD RESULTS:

Also, in the log I don’t see any Sounds being loaded by FMOD, is it possible the load isn’t being called at all?

That’s because I don’t output them. Load results are OK. Besides, it works on both Windows and Android. I’ll doublecheck when I’ll get home.

Regardless of the LOAD RESULTS, there should also be logging from FMOD when you create a sound which appears to be missing unless you snipped it out of the log provided?