Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken audio SIP->GSM #44

Closed
Infactum opened this issue Sep 13, 2017 · 7 comments
Closed

Broken audio SIP->GSM #44

Infactum opened this issue Sep 13, 2017 · 7 comments

Comments

@Infactum
Copy link

Infactum commented Sep 13, 2017

Sadly issue openwrt/telephony#7 is back.
Patch 53e83a4 by @micmac1 is not working anymore for some reason.

Test system:
Netgear WNDR3800
Huawei E1550 dongle
LEDE Reboot (17.01.2, r3435-65eec8bd5f)
Asterisk 13.9.1

Audio from asterisk to GSM is loud and noisy. Something similar to voice can be heard with about -300 txgain in dongle.conf
Same dongle works fine on X86 LEDE system (same version).

@wdoekes
Copy link
Owner

wdoekes commented Sep 13, 2017

Okay. It just merged it, I cannot vouch for its validity.

I can revert if you want.

Could it be that it conflicts with ab93953 ( bg111#201 ) "fix Sparc loud noise problem"?

@Infactum
Copy link
Author

Infactum commented Sep 13, 2017

Tried to compile without ab93953 and it worked.
Unfortunately I can't make proper pull request, since reverting ab93953 will break package on other systems.

@wdoekes
Copy link
Owner

wdoekes commented Sep 13, 2017

Unfortunately I can't make proper pull request, since reverting ab93953 will break package on other systems.

What do you mean? I have no system to test against. If you have a big endian one, and it works, then we should go with that. The fix recently added was originally made against a 2015 build, which recieved the "sparc loud noise fix" in 2016. So one of the two fixes likely has to go.

Relevant commits:

commit 020ca572109509e0b7f8b1798f3f2ce606394f26
Author: [email protected] <[email protected]>
Date:   Fri May 27 22:18:22 2011 +0000

    added be platforms

diff --git a/channel.c b/channel.c
index c7a174b..c293c6a 100644
--- a/channel.c
+++ b/channel.c
@@ -651,6 +651,7 @@ static struct ast_frame* channel_read (struct ast_channel* channel)
 
                cpvt->a_read_frame.samples      = res / 2;
                cpvt->a_read_frame.datalen      = res;
+               ast_frame_byteswap_le (&cpvt->a_read_frame);
 /*
                cpvt->a_read_frame.ts;
                cpvt->a_read_frame.len;
@@ -855,6 +856,7 @@ static int channel_write (struct ast_channel* channel, struct ast_frame* f)
                        int iovcnt;
                        struct iovec iov[2];
 
+                       ast_frame_byteswap_le (f);
                        iov[0].iov_base = f->data.ptr;
                        iov[0].iov_len = FRAME_SIZE;
commit ab939532c71b991de2f66582d7ee2c553b6a918e
Author: bg111 <[email protected]>
Date:   Sun Sep 25 12:38:12 2016 +0800

    fix Sparc loud noise problem #201

diff --git a/channel.c b/channel.c
index 0c96fa4..f695d99 100644
--- a/channel.c
+++ b/channel.c
@@ -820,6 +820,7 @@ static int channel_write (struct ast_channel* channel, struct ast_frame* f)
                        }
                }
 
+               ast_frame_byteswap_le(f);
 
                if (pvt->a_timer)
                {

And now 53e83a4 from openwrt.

There are now too many swaps for sure:

diff --git a/channel.c b/channel.c
index e689e9f..4e84bc4 100644
--- a/channel.c
+++ b/channel.c
@@ -576,7 +576,7 @@ static void timing_write(struct pvt* pvt)
                        iovcnt = mixb_read_n_iov (&pvt->a_write_mixb, iov, FRAME_SIZE);
                        mixb_read_n_iov (&pvt->a_write_mixb, iov, FRAME_SIZE);
                        mixb_read_upd (&pvt->a_write_mixb, FRAME_SIZE);
-                       change_audio_endianness_to_le(iov, iovcnt);
+                       change_audio_endianness_to_le(iov, iovcnt); // XXX
                }
                else if (used > 0)
                {
@@ -590,7 +590,7 @@ static void timing_write(struct pvt* pvt)
                        iov[iovcnt].iov_base    = silence_frame;
                        iov[iovcnt].iov_len     = FRAME_SIZE - used;
                        iovcnt++;
-                       change_audio_endianness_to_le(iov, iovcnt);
+                       change_audio_endianness_to_le(iov, iovcnt); // XXX
                }
                else
                {
@@ -679,7 +679,7 @@ static struct ast_frame* channel_read (struct ast_channel* channel)
        if (pvt->a_timer && ast_channel_fdno(channel) == 1)
        {
                ast_timer_ack (pvt->a_timer, 1);
-               timing_write (pvt);
+               timing_write (pvt); // XXX
                ast_debug (7, "[%s] *** timing ***\n", PVT_ID(pvt));
        }
 
@@ -727,7 +727,7 @@ static struct ast_frame* channel_read (struct ast_channel* channel)
 
                cpvt->a_read_frame.samples      = res / 2;
                cpvt->a_read_frame.datalen      = res;
-               ast_frame_byteswap_le (&cpvt->a_read_frame);
+               ast_frame_byteswap_le (&cpvt->a_read_frame); // XXX
 /*
                cpvt->a_read_frame.ts;
                cpvt->a_read_frame.len;
@@ -910,7 +910,7 @@ static int channel_write (struct ast_channel* channel, struct ast_frame* f)
                        }
                }
 
-               ast_frame_byteswap_le(f);
+               ast_frame_byteswap_le(f); // XXX (added in ab939532c7)
 
                if (pvt->a_timer)
                {
@@ -945,7 +945,7 @@ static int channel_write (struct ast_channel* channel, struct ast_frame* f)
                        int iovcnt;
                        struct iovec iov[2];
 
-                       ast_frame_byteswap_le (f);
+                       ast_frame_byteswap_le (f); // XXX
                        iov[0].iov_base = f->data.ptr;
                        iov[0].iov_len = FRAME_SIZE;
 

@micmac1
Copy link

micmac1 commented Sep 13, 2017 via email

@wdoekes
Copy link
Owner

wdoekes commented Sep 13, 2017

There. Reverted. Let me know if additional fixage is needed.

@Infactum
Copy link
Author

Doen't work in my setup.
Reverting ab93953 was fine.

@wdoekes
Copy link
Owner

wdoekes commented Sep 13, 2017

Hah, too fast. Okay. Hang on while I rewrite history.

wdoekes added a commit that referenced this issue Sep 13, 2017
This reverts commit ab93953.

Apparently there was too much byteswapping (on big-endian machines)
going on with both ab93953 and 53e83a4. Reverting ab93953 appears to
work for @Infactum.

Closes #44.
shalzz pushed a commit to shalzz/asterisk-chan-dongle that referenced this issue Apr 23, 2022
# This is the 1st commit message:

Create DONATIONS.txt
# This is the commit message wdoekes#2:

Update README.md
# This is the commit message wdoekes#3:

Update DONATIONS.txt
# This is the commit message wdoekes#4:

Update DONATIONS.txt
# This is the commit message wdoekes#5:

Update DONATIONS.txt
# This is the commit message wdoekes#6:

Update chan_quectel.h
# This is the commit message wdoekes#7:

Update README.md
# This is the commit message wdoekes#8:

Update cpvt.h
# This is the commit message wdoekes#9:

Add files via upload
# This is the commit message wdoekes#10:

Delete DONATIONS.txt
# This is the commit message wdoekes#11:

Update README.md
# This is the commit message wdoekes#12:

Update README.md
# This is the commit message wdoekes#13:

Update README.md
# This is the commit message wdoekes#14:

Add files via upload
# This is the commit message wdoekes#15:

Update README.md
# This is the commit message wdoekes#16:

Update README.md
# This is the commit message wdoekes#17:

Update README.md
# This is the commit message wdoekes#18:

Update README.md
# This is the commit message wdoekes#19:

Update README.md
# This is the commit message wdoekes#20:

Update README.md
# This is the commit message wdoekes#21:

Update README.md
# This is the commit message wdoekes#22:

Update README.md
# This is the commit message wdoekes#23:

Add files via upload

Added Simcom support
# This is the commit message wdoekes#24:

Update README.md
# This is the commit message wdoekes#25:

Update README.md
# This is the commit message wdoekes#26:

Added support for Quectel UAC configuration
# This is the commit message wdoekes#27:

Conf file when using UAC
# This is the commit message wdoekes#28:

Update README.md
# This is the commit message wdoekes#29:

Update README.md
# This is the commit message wdoekes#30:

Quectel CREG correction

chan_dongle code assumes 4 parameters in response to command and 3 for URC. However quectel provides 5 and 4 respectively. This fix helps pass on correct status of registration.
# This is the commit message wdoekes#31:

No force registration status

Due to CREG parse issues, earlier registration status was always kept on, now will show unregistered if not connected to network
# This is the commit message wdoekes#32:

Create readme.md
# This is the commit message wdoekes#33:

For compilation with openwrt sdk
# This is the commit message wdoekes#34:

Support for openwrt sdk compilation
# This is the commit message wdoekes#35:

Fix for lac and cell id

Ref IchthysMaranatha#6
Post fix values may have a trailing double quote for quectel devices
# This is the commit message wdoekes#36:

Updated call ids for simcom

Add call termination for call ids 1 and 2
# This is the commit message wdoekes#37:

comment for simcom audio

Added default audio port for simcom in comment
# This is the commit message wdoekes#38:

Integrated ALSA support for UAC

Integrated driver for ALSA added, no need for bridging additional Asterisk ALSA channel when using UAC mode. Please use non-ALSA integrated branch if there is no need for UAC and you wish to avoid alsa dependency when compiling and running
# This is the commit message wdoekes#39:

Update COPYRIGHT.txt

Attribute copyright for alsa code copied from chan_alsa.c https://github.com/asterisk/asterisk/blob/master/channels/chan_alsa.c
# This is the commit message wdoekes#40:

Update README.md
# This is the commit message wdoekes#41:

Conf file with UAC device support
# This is the commit message wdoekes#42:

UAC mode conf file
# This is the commit message wdoekes#43:

Added alsa-lib for compilation
# This is the commit message wdoekes#44:

Delete Makefile.in
# This is the commit message wdoekes#45:

alsa-lib dependency addition
# This is the commit message wdoekes#46:

Fix for simcom audio issues with immediate answer in dialplan
# This is the commit message wdoekes#47:

Note for Quectel serial audio

Added remark to disable gps messages
# This is the commit message wdoekes#48:

Added note for Pi users
# This is the commit message wdoekes#49:

Quectel creg formatting fix

Removed trailing double quotes in reporting lac/cid
# This is the commit message wdoekes#50:

add gitattributes
# This is the commit message wdoekes#51:

Send DTMF using AT command

Corrected at command for dtmf generation
# This is the commit message wdoekes#52:

Fix for busy on call rejection for simcom

For those who receive 'busy' additionally on call rejection when dialling out. Author only receives 'no carrier' on rejection. Reported and solved by @mpmc here IchthysMaranatha#22
# This is the commit message wdoekes#53:

Removal of redundant closetty
# This is the commit message wdoekes#54:

Update busy fix for call rejection

Updated fix as submitted by @mpmc here IchthysMaranatha#22
Author does not receive busy response on call rejection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants