Requirements for CAPlayThroughMBS?

Hi,

I’m trying the CAPlayThroughMBS class but it looks like even the example won’t work. I tried on a 2013 MacBook Air (MacOS 10.15), a Mac mini (M1, MacOS 12) and a 2012 iMac (MacOS 10.15).
I don’t get any error (and can actually hear the output device being “activated” if it was idle), but I can’t hear any signal. I tried many combinations, as well as adding “a.volume=100” in the example.

Is the CAPlayThroughMBS used for earlier OS versions only (deprecated)? Is the example still working for someone these days?

@Christian_Schmitz, may I ask you whether CAPlayThroughMBS works on your side, please?
What are the requirements for making it working?

I found something: on Mac OS 12, PlayThrough require the NSMicrophoneUsageDescription in the info.plist. This solves my issue on my computer, but since the target computer is running Mac OS 10.13 and that OS didn’t have all the restrictions added later, I don’t think it’ll help (will try on Saturday).

I may have to check later, but nothing shows up as error message in console.app, when you try it?

Thanks.
At the time of my original post, I didn’t checked the console. I expected that if something was acknowledgedly wrong, I’d forcibly get an error code at some point in code.

Later, I eventually checked the console, which contained strings about not having rights to open the input channel(s). This led me to the NSMicrophoneUsageDescription key in the info.plist (the error in the console told me straight about that missing key).

I have then added this key in my info.plist file and it worked on my Monterey system. Unexpectedly, it also worked on the 10.13 target Mac.
I still don’t know why that key made the difference, since 10.13 was released before Apple added these security enforcements (starting in 10.14).

I’m not sure you can do anything about it; it’s not your fault. But if you eventually mention in the documentation the fact that this key is needed for making the class working or if you can make so the call (CAPlayThroughMBS.start) returns an error code in such cases (don’t know why it currently doesn’t :man_shrugging:. Does it return any error code at all?), that would be great for possibly helping others.

Thank you.

Lasterror property isn’t set with some useful code, we could lookup?

But basically this should only fail if the device IDs are wrong or you have permissions.

In the case I encountered, missing permissions was indeed the problem (since the NSMicrophoneUsageDescription wasn’t provided). It looks weird the method returns OK (error=0) when this happens.

You should be able to replicate this yourself the same way I did:

Sample code:

  var apt As CAPlayThroughMBS=new CAPlayThroughMBS(app.Prefs.PlayThruInputID,app.Prefs.PlayThruOutputID) 'just use valid values here (e.g. source=microphone and target=line out)
  if apt.lasterror<>0 then
    MessageBox "Got an error: "+apt.Lasterror.ToString+"."
    apt=nil
  else
    apt.Start
    if apt.Lasterror<>0 then MessageBox "Apt with Start ("+apt.Lasterror.ToString+")."
  end if

If you try without code signing (in debug mode or as a built app), you won’t get an error other than 0 in both calls, yet the play through won’t work.