FNA-XNA / FNA

FNA - Accuracy-focused XNA4 reimplementation for open platforms
https://fna-xna.github.io/
2.59k stars 261 forks source link

Expose FAudioContext or Device Handle #455

Open tomcashman opened 9 months ago

tomcashman commented 9 months ago

We're currently accessing the FAudioContext device pointer to set up some in-memory caching/streaming of music files on Nintendo Switch. To do this, we patch in the following function to SoundEffect.cs to get the device pointer.

        public static IntPtr DeviceHandle()
        {
            return Device().Handle;
        }

Ideally we could access this via an EXT method.

Would this be accepted as PR? If so, where/how do you recommend exposing it?

Or, if there's a better way to do the in-memory caching/streaming I'm open to suggestions.

flibitijibibo commented 9 months ago

We could possibly do SoundEffect.FromPointerEXT instead; the application can load all PCM data to a single host pointer and then call SoundEffect.FromPointerEXT with the offset pointer and the wave format, and all SoundEffect has to do on disposal is avoid freeing the host pointer.

tomcashman commented 9 months ago

I assume that approach wouldn't create the voice using FAUDIO_VOICE_MUSIC? Would there be any potential issues to that?

flibitijibibo commented 9 months ago

It likely would not, no... I actually haven't come across a use case for that flag yet (at least within XNA) so more details would help a lot here.