[Home]

Summary:ASTERISK-14942: [patch] App_jack.so JACK_HOOK half works
Reporter:fabien comte (fabien comte)Labels:patch
Date Opened:2009-10-06 04:57:05Date Closed:
Priority:MinorRegression?No
Status:Open/NewComponents:Applications/app_jack
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) app_jack.patch
Description:Hello,

My configuration is :
Card 0 - kernel dummy sound card
Card 1 - my soundcard

I have a jackd running in background. My jackd launch command is :
jackd --port-max 16 --realtime --no-mlock -d alsa --playback hw:1,0 --capture hw:1,0 --rate 8000 --period 1024 --shorts --inchannels 2 --outchannels 2 --dither triangular &

1 ) I open asterisk with chan_alsa.so connected (with asoundrc) to the kernel dummy sound card (allow me dial command). I do a call with a JACK_HOOK from app_jack.so, sound is sent but no one is received.

My extensions.conf :
exten => _0.,1,Answer
exten => _0.,n,Set(JACK_HOOK(manipulate,c(asterisk))i(from_voip:input)o(to_voip:output)))=on)
exten => _0.,n,Dial(SIP/freephonie-out/${EXTEN:1})

Asterisk command :
console dial 0xxxxxxxx

2) Jackd works well with anothers applications when I force them to use jack as input/output. -> probably not a jack configuration problem.

3) If I kill jackd and I use chan_alsa.so with the real soundcard, it works. -> probably not a network or sip configuration problem.


4) If I replace "f_buf[i] = s_buf[i] * (1.0 / SHRT_MAX);" with "f_buf[i] = 0.5 * sin(0.3454 * ((float) i));" in app_jack.c and I retry the test 2, I get test sound.
It looks like no sound was read in channel...
Comments:By: fabien comte (fabien comte) 2009-10-06 05:02:13

Bug was that queue_voice_frame was not called in right place.
Optimization are about removing / moving some useless memset.

Fabien

By: Russell Bryant (russell) 2009-10-06 10:25:48

I haven't looked at the code yet, but first I wanted to make sure that we're on the same page about how JACK_HOOK is supposed to work.  It hooks into the audio stream coming from the channel you enable it on.  It does _not_ do anything with the audio received from the other side.  So, in ASCII art, if you set JACK_HOOK on channel A ...

{noformat}
 channel A                                      channel B
-----------                                    -----------
  rx ----(in)JACK_HOOK(out) -- [bridge] ------------> tx
  tx <------------------------ [bridge] ------------- rx
{noformat}

If you want to get the audio from channel B to JACK, as well, you can enable a JACK_HOOK on channel B by running a macro on the called channel using the M() option to Dial.



By: fabien comte (fabien comte) 2009-10-07 09:41:18

Ok, that's probably the response.

I wanted to do this (ASCII art is more difficult)

{noformat}
channel A......(in)JACK_HOOK(out).............channel B
-----------.....|.................|...............-----------
...rx ----------+------------|-- [bridge] --------> tx
...tx <----------------------+-- [bridge] --------- rx
{noformat}

With jack_hook, I wanted to plug a software element that analyse incoming sound and add some sound to the transmitted.

The problem is the patch I proposed works is this case :

{noformat}
; do a call with console
exten => _0.,1,Answer
exten => _0.,n,Set(JACK_HOOK(manipulate,c(asterisk)i(from_voip:input)o(to_voip:output))))=on)
exten => _0.,n,Dial(SIP/sip-out/${EXTEN:1})
{noformat}

But not in this one :

{noformat}
; answer a call with console
exten => _0.,1,Answer
exten => _0.,n,Set(JACK_HOOK(manipulate,c(asterisk)i(from_voip:input)o(to_voip:output))))=on)
exten => _0.,n,Dial(console/alsa/1)
{noformat}

Do you have you have any examples or links to understand how to to use the M() command. I will test it with a your approach.

The problem is that there are not a lot of exemples... Do you have any exemples with JACK() too ?



By: fabien comte (fabien comte) 2009-10-07 10:17:12

I come back to the original sources (asterisk V1.6.1.6)

I tried the simplest test and it does not worked.

; answer to incoming calls and create a jack client named toto
exten => _3.,1,Answer
exten => _3.,n,JACK(c(toto))

I call with a softphone this machine ex 300. The machine is responding.


During the call is running, I lanched the commands :

jack_lsp -> ok, toto exists

then

jack_connect toto:input toto:output
To do an echo. A simple way to test jack, very useful.

The problem is I do not have any echo.

Is it normal ? Do I have not understood something ?