JACK_HOOK issue, and finding working alternative

Hi, I’m trying to get the JACK_HOOK audiohook function working, which is part of the Jack() dialplan application. Jack() is working fine.

The issue I’ve been having with JACK_HOOK is that only the caller’s output (telephone microphone) is correctly routed; the caller’s input (telephone speaker) is silent. So in the dialplan example below I route the caller’s output to the input of SuperCollider (sound processing/composition language), and the output of Supercollider back to the caller’s input.

Currently, I can receive input from the caller’s microphone in SuperCollider, but I can’t receive the output back in Asterisk. The output of Supercollider appears correctly routed with Jack, but no audio is received on the active channel in Asterisk.

[from-internal]
exten = 514316XXXX,1,Answer()
same = n,Wait(1)
same => n,Dial(LOCAL/100@extensions,30)
same = n,Wait(1)
same = n,Hangup()

[extensions]
exten => 100,1,Answer()
same => n,Playback(hello)
same => n,Set(JACK_HOOK(manipulate,i(SuperCollider:in_1)o(SuperCollider:out_1))=on)
same => n,Wait(120)
same => n,Playback(goodbye)
same => n,Hangup()

It connects, but the output from SuperCollider is not received on the Asterisk channel.
JACK_jackhook_catia

On top of the routing problem, I am also unable to kill the channel. For instance in the dialplan below, I disconnect JACK_HOOK after 5 seconds…

[from-internal]
exten = 514316XXXX,1,Answer()
same = n,Wait(1)
same => n,Dial(LOCAL/100@extensions,60)
same = n,Wait(1)
same = n,Hangup()

[extensions]
exten => 100,1,Answer()
same => n,Playback(hello)
same => n,Set(JACK_HOOK(manipulate,i(SuperCollider:in_1)o(SuperCollider:out_1))=on)
same => n,Wait(5)
same => n,Set(JACK_HOOK(manipulate,i(SuperCollider:in_1)o(SuperCollider:out_1))=off)
same => n,Playback(goodbye)
same => n,Hangup()

But the channel does not actually disconnect. Instead it throws these Jack ringbuffer errors:

[2020-10-12 17:48:20] WARNING[17962]: app_jack.c:293 handle_input: Tried to write 4096 bytes to the ringbuffer, but only wrote 0
[2020-10-12 17:48:20] WARNING[17962]: app_jack.c:293 handle_input: Tried to write 4096 bytes to the ringbuffer, but only wrote 0
[2020-10-12 17:48:20] WARNING[17962]: app_jack.c:293 handle_input: Tried to write 4096 bytes to the ringbuffer, but only wrote 0

I should note that with the Jack() app, I currently have no problems, See the example dialplan below, which is working fine:

[from-internal]
exten = 514316XXXX,1,Answer()
same = n,Wait(1)
same => n,Dial(LOCAL/100@extensions,60)
same = n,Wait(1)
same = n,Hangup()

[extensions]
exten => 100,1,Answer()
same => n,Playback(hello)
same => n,JACK([i(SuperCollider:in_1), o(SuperCollider:out_1)])

My usage case: I need to send call channel audio out of Asterisk into Supercollider, and back out from Supercollider into Asterisk, via Jack without blocking other dialplan actions. My dialplan needs to communicate with Supercollider during the call, but the Jack() app runs as blocking, so no further actions can be taken on the dialplan until the Jack channel is closed.

JACK_HOOK is supposed to remedy the blocking issue, but it appears to have issues unless I’m misunderstanding its syntax/functionality.

There could be another solution to my problem, but I’m not sure how to set it up. Since we can dial multiple channels at the same time, it should be possible to parallel dial into two extensions. The first extension would connect to handle Jack() & SuperCollider, and the second extension could keep running to communicate with Supercollider, and could also run sound from within the dialplan on the same channel. They could be merged together with a conference bridge or similar.

I’ve been experimenting and trying to write a dialplan for the parallel dial solution, without luck. When I dial into two channels with “Dial(LOCAL/100@extensions&LOCAL/101@extensions,60)”, extension 100 picks up first and blocks extension 101. Could anyone offer an example parallel dialing dialplan solution, or any further info or ideas for working with Jack() or JACK_HOOK?

Thank you for your help.