CoreAudioMBS returns code -1

Hi,

I need to get the volume of the default sound output on iOS. GetSoundVolumeMBS raises an exception (not supported on iOS), although the documentation says iOS is supported (:heavy_check_mark:).

So I’m trying another approach, with CoreAudioMBS:

Var CoreAudio As new CoreAudioMBS

Var m As MemoryBlock=CoreAudio.AudioHardwareGetPropertyMemory(CoreAudio.kAudioHardwarePropertyDefaultOutputDevice)
if CoreAudio.Lasterror<>0 then Break
Var DfltOut As Integer
if m<>nil then DfltOut=m.Int32Value(0)

With this code, m is nil and LastErrorCode=-1. The same code works on Mac OS (I tested on the emulator). Is it an entitlement issue? Or something else?

Sorry for the documentation error.
I’ll fix the checkmark. The function doesn’t work on iOS as the API we use isn’t available as far as I see.

1 Like

Thanks. Do you happen to know another way (or API)?

Let me check if I can improve the function.

Seems like I could return AVAudioSession.sharedInstance.outputVolume, but that seems to only be valid while you have an active audio session.