yashsingh1/xdaforums huggingface dataset:
[Miscellaneous Android Development] ottmi:
It was the same here. I've changed it to 95 now which seems to be ok. Thanks!

That's really odd. I tried to find out where in the code the use case is actually selected, but I couldn't find it. The whole audio HAL is a total black box to me. I still didn't understand the connection between ACDB, Use Cases, and PCM IDs..

EDIT: It seems that the selection of the use case depends on the SIM card that is being used for the call and the settings for each SIM card. Similar to what is discussed here:

http://review.cyanogenmod.org/#/c/105333/

Obviously this doesn't apply directly to us as this is not a Samsung device, but the concept is the same. I usually have Sim1 in 2G mode and Sim2 in LTE and that gives me voice2-call. However, when I turn it around, I get voice-call. This could also explain why people have different experiences with echo, etc..
[Miscellaneous Android Development] siljaer:
really interesting, thanks! I will make some experiments :)
[Miscellaneous Android Development] siljaer:
YES!!!!! We found the culprit at last! :)

* echo DEFINITELY occurs when using voice2-call instead of voice-call usercase. I've tried alone, with speakerphone, with my personal guinea pig caller and it's incredible: no echo even with high volume settings. Furthermore, my voice appears much clearer to the other party.

* I have activated echo cancellation in audio_effects.conf, differently from last release. I don't know whether it matters, though (I think so). However, there's nothing special in it, just the preprocessing part at the end.

* Unfortunately, I haven't been able to use voice-call by only swapping SIMs. However, my situation is a bit peculiar: one SIM that I use only for phone calls and with data disabled by the operator (I asked for it); another SIM that I use only for data (I don't even know whether phone calls are possible with that). I made the experiments with only the first SIM in (the slot does not matter).

So, we only need to figure out how CM13 "choose" voice-call or voice2-call and how we can force a usecase. Once we have the last piece of the puzzle, we can get rid of the dirty workaround in mixer_paths.xml and enjoy normal conversation volume without any echo.

Naturally, if someone is hasty, then they can fix the issue by themselves.

* follow the link given by @ottmi: http://review.cyanogenmod.org/#/c/105333/ and try to find whatever works for you to make the phone use voice-call during a call (use logcat to check it), swapping, using LTE, 3G etc.

* Once you're sure voice-call usecase is selected for your phone calls, you can just use the old versions of mixer_paths_qrd_skuh.xml and audio_effects.conf. They should work fine.

EDIT: it really sucks (for me) but it seems that a way to force usecase voice-call is to select LTE for the SIM you use for calls. Unfortunately I can select LTE for one SIM only. And my data SIM cannot even use 2G (the operator only supports 3G/LTE). However, since with stock rom I have not this problem, I guess it's not a hardware limit.
[Miscellaneous Android Development] siljaer:
Ok, I found a way. I'm writing down the steps just in case someone has a similar problem.

* set both the SIMs to LTE (it's normally this way, but I had set the SIM I use for calls to 2G, so I could only set one SIM to LTE)

- if you cannot, turn off the phone, then pull out the SIM set to LTE. Turn on the phone, set the other SIM to LTE. Turn off the phone, insert the second SIM and turn on again the phone. Now all of them should be set to LTE.

* From the ottmi's link: "... the logic is: if slot0 nw_mode isn't set to 2G (is set to LTE/3G) then voice_slot is slot0. We know that if slot0 is 2G, most likely slot1 is LTE/3G and then voice_slot is slot1."

So, you should put the SIM you use for calls in the slot #1. But you have to be sure that SIM #1 also connects first to the network. I found a simple way: just lock them both with a PIN. You will unlock SIM #1, then SIM #2.

Unfortunately, I cannot test the behaviour of the SIM #2 (which usecase will it use?).

And, yes, the Dual Sim code of CM13 is buggy :( But this solution is much better than before.
[Miscellaneous Android Development] Sampierdarena:
:good: Heartfelt thanks for the solution. I set the value to "95", result: perfectly efficient!

It may be helpful, I would give my feedback on the eco issue: Sim 1 (4G) TIM, Sim 2 (2G) Wind. (Tim and wind, for the uninitiated, are Italian operators).

I have no particular problems on the phone, even with the many changes in the various release, I always called good, without noise or loud noises.
[Miscellaneous Android Development] ottmi:
I think our modem doesn't allow for 3G/LTE on both SIMs. The fact that you can set it when you pull a stunt like turning off the phone and removing the SIM card is probably just a flaw in the configuration dialogue and eventually will also lead to one SIM working in 2G but less predictable. I guess it's safer to set it explicitly.

It seems that voice-call is used only for 3G/LTE, wheras voice2-call is used for 2G. I spent another few hours searching the source code, but didn't find a clue where this is enforced. In the link I mentioned above they do it explicitly in the Audio HAL for the HTC and Samsung devices, but somewhere there must be similar generic logic. Could also be that it's hidden somewhere in the vendor blobs, probably in the RIL.

Next question is: why do they do it? You mentioned that this is not the case for the stock ROM so it can't be a hardware limitation. But there must be some reasoning behind this.

Did you try the audio_policy.conf hack to change the path for voice2-call to voice-call?
[Miscellaneous Android Development] siljaer:
You're welcome :)

Thanks. Which card do you use for phone calls? If you use both, can you notice any difference?

---------- Post added at 15:48 ---------- Previous post was at 15:32 ----------

Yes, I've just realized it... the second card is working 2G mode only.

Vendor blobs? Swift's or Trunk's? Because I think it's not in the Trunk's blobs.

I am wondering too. The kind of talk they do suggests that there must be an obvious reason...

Do you mean

<path name="voice2-call">
<path name="voice-call">
</path>

in mixer_paths_qrd_skuh.xml? Yes, it lead to a bootloop :(

I also tried to activate aec on voice2-call (audio_effects.conf). Bootloop.

I will try something else.
[Miscellaneous Android Development] siljaer:
After all, even if we could choose the usecase we would have aec for one SIM only. We'd better enable aec also for voice2-call. However, there's something interesting in mixer_paths:

<path name="echo-reference">
<ctl name="AUDIO_REF_EC_UL1 MUX" value="I2S_RX" />
</path>

it looks like "audio signal that can be fed back (reference) in uplink 1"

Yes, but "why uplink 1?", I've always wondered. Because we have uplink 2,4,5,6,8,9. Can one of them be useful with voice2-call? Something more to experiment with...
[Miscellaneous Android Development] Sampierdarena:
The operator who mainly use for phone calls is TIM. To call a friend using Wind (sim # 2), there are no problems of distortion, communication is excellent with all operators (tim - wind).
[Miscellaneous Android Development] siljaer:
And which SIM is 2G and which one is 3G/LTE?

---------- Post added at 20:29 ---------- Previous post was at 19:54 ----------

OK, I have no echo with voice2-call too. Changes:

from

<!-- EC_REF -->
<ctl name="AUDIO_REF_EC_UL1 MUX" value="None" />

to

<!-- EC_REF -->
<ctl name="AUDIO_REF_EC_UL1 MUX" value="None" />
<ctl name="AUDIO_REF_EC_UL2 MUX" value="None" />
<ctl name="AUDIO_REF_EC_UL4 MUX" value="None" />
<ctl name="AUDIO_REF_EC_UL5 MUX" value="None" />
<ctl name="AUDIO_REF_EC_UL6 MUX" value="None" />
<ctl name="AUDIO_REF_EC_UL8 MUX" value="None" />
<ctl name="AUDIO_REF_EC_UL9 MUX" value="None" />

and from

<path name="echo-reference">
<ctl name="AUDIO_REF_EC_UL1 MUX" value="I2S_RX" />
</path>

to

<path name="echo-reference">
<ctl name="AUDIO_REF_EC_UL1 MUX" value="I2S_RX" />
<ctl name="AUDIO_REF_EC_UL2 MUX" value="I2S_RX" />
<ctl name="AUDIO_REF_EC_UL4 MUX" value="I2S_RX" />
<ctl name="AUDIO_REF_EC_UL5 MUX" value="I2S_RX" />
<ctl name="AUDIO_REF_EC_UL6 MUX" value="I2S_RX" />
<ctl name="AUDIO_REF_EC_UL8 MUX" value="I2S_RX" />
<ctl name="AUDIO_REF_EC_UL9 MUX" value="I2S_RX" />
</path>

Naturally, in order to trigger the echo, you have to raise volumes:

<path name="handset">
<!-- RX1 -> RX1 -->
<ctl name="RX1 MIX1 INP1" value="RX1" />
<!-- connect RX1 to RDAC2 -->
<ctl name="RDAC2 MUX" value="RX1" />
<!-- set volume and gain to prevent echo-->
<ctl name="RX1 Digital Volume" value="90" />
<!-- set earpiece gain -->
<ctl name="EAR PA Gain" value="POS_6_DB" />
<ctl name="EAR_S" value="Switch" />
</path>

<path name="handset-mic">
<!-- use ADC1 -->
<path name="adc1" />
<!-- feed ADC1 output to IIR1 for sidetone -->
<ctl name="IIR1 INP1 MUX" value="DEC1" />
<!-- set volume and gain to prevent echo-->
<ctl name="ADC1 Volume" value="6" />
<ctl name="DEC1 Volume" value="90" />
</path>

and you have to enable aec in audio_effects.conf adding the processor section:

pre_processing {
voice_communication {
aec {
}
}
voice_call {
aec {
}
}
}

This way it works. However, I have to make several tests:

* funny, but I've realized that I haven't tried the last release without any changes (apart from raising volumes). It's possible it was already working without the dirty workaround volumes.

* I have to check whether enabling aec for voice_call is really necessary.

* some more accurate testing: my guinea pig was in a train :)

I will need to arrange a test session tomorrow :)
[Miscellaneous Android Development] ottmi:
Great stuff, thanks a lot for experimenting with this.

One comment on the audio_effects.conf: Are you sure that the voice_call input source actually exists? According to the sample conf file 'Valid input source names are:

"mic", "camcorder", "voice_recognition", "voice_communication"'.

Some other thoughts on voice-call vs voice2-call: Is it possible that you only saw the voice-call on the stock ROM because you accidentally had chosen the right SIM configuration? Maybe the stock ROM also uses voice2-call..
[Miscellaneous Android Development] siljaer:
it's the same old story about documentation: VAGUE. Because here: https://developer.android.com/reference/android/media/MediaRecorder.AudioSource.html and here: https://source.android.com/devices/audio/implement.html#preprocessingI found some other LIKELY sources. Well, it boots with voice_call, while it does not boot if I try with voice2_call.

Actually, that's something I have to check...

UPDATE: Yes, you were right :)
[Miscellaneous Android Development] Sampierdarena:
SIM 1 (tim) LTE ; SIM 2 (wind) 2G
[Miscellaneous Android Development] siljaer:
Test results: it looks like the changes in the two last releases (acdb data and sound system) have already solved the echo problem without any need for the changes to mixer_path_qrd_skuh.xml and audio_effects.conf I suggested in my last posts. I've probably skipped some test because of the surfaceflinger bug, sorry.

So, voice-call and voice2-call usecases are equivalent and there's no need to care about them. Besides, I also figured out the simple logic behind them: if one SIM is 3G/4G and the other one 2G only, and they are soft swappable, you have to use voice2-call for the 2G card, that is actually what has been added to the single SIM 3G/4G phone case. However, that has nothing to do with echo.

I really hope I will not change my mind again :) I am sorry, but testing for echo cannot be done by themselves, and you have to rely on someone else's experience. Good for me I have found a reliable "ear" at the other end.

Quite surprisingly, there's no need for the preprocessing section in audio_effects.conf either, not even the section that was in the stock rom file. Possibly, aec for phone calls is already enabled by default and that section only helps for voip.

Now, it's up to you [MENTION=7319300]ottmi[/MENTION] : you can get rid of my dirty changes to mixer_path_qrd_skuh.xml (at last!) and go back to stock settings or wenderer's. Maybe stock file finally works fine with everything because acdb loader is working (it displays many error messages, but it does the same with stock rom...), even audio recordings. I will stop testing the echo for a while, in order to keep at least a few friends ;). But if any of you reading now has a problem with echo with the next release, please report it. It's something personal between me and the echo, now :)

EDIT: I've checked with stock settings: audio recordings are loud! So, calibration data have helped for audio recordings too (and that's why they became so distorted with the two last release).
[Miscellaneous Android Development] 21prods:
Superb!! Thank you for all your work!

Enviado desde mi Nexus 5 mediante Tapatalk
[Miscellaneous Android Development] siljaer:
Thanks. It's really strange that you've never suffered from echo, though...
[Miscellaneous Android Development] ottmi:
Thanks for all your effort in testing this, it's much appreciated!

So what I will do for the next release:

Get rid of audio_effects.conf, i.e. use the CM13 default

Revert to stock mixer_path_qrd_skuh.xml, although only for the actual values. I would like to keep your comments for future reference and documentation purposed

Anything I forgot?
[Miscellaneous Android Development] siljaer:
Many thanks to you, ottmi, as per usual.

I don't know whether CM13 default can cause problems: I have never seen that file. But I guess it's nothing special.

Yes, it's a good idea to keep comments for future reference. I would also comment out the lines (now useless, at last!) where volumes of the different sections (handset, handset-mic and so on) are modified, in order to leave a template for anyone willing to modify those values. If you like, I can edit mixer_paths_qrd_skuh.xml and make a pull request, so I can edit the comments and remove references to the echo problem (hopefully, the problem is solved).

EDIT: and maybe also some comments about the voice-call and voice2-call usecases are needed. They were not important for the echo, but maybe in the future someone will wonder about which SIM is using what, and it's better to leave a simple explanation in place instead of forcing them to reinvent the wheel...
[Miscellaneous Android Development] ottmi:
It has significantly more effects than the stock conf file and the file I have been using previously (which I think was from Crackling). I'm inclined to use this as the effects it provides may be needed somewhere else in CM13. Unless we know all the details on the inner workings of the effect libraries I think it should be safe to use the default CyanogenMod deems worthy for the MSM8916 default :)

That would be great. Thank you!
[Miscellaneous Android Development] siljaer:
We'll see what CM13 stock conf does, then :) I think the aec it's kind of "hard-wired" (so to speak) somewhere else.

Ok, I will write something in mixer_paths....
[Miscellaneous Android Development] ottmi:
Thanks for the new file. I've just compiled a new ROM:

http://xdaforums.com/devdb/project/dl/?id=19760

I think it shouldn't hurt to have the audio effects in place. From how I interpret https://source.android.com/devices/audio/implement.html they can also be used within applications..
[Miscellaneous Android Development] robot666:
ottmi helfen lieber uns, die Auto-Rotation auf unserer Sammlung Kernel für x32 Cayanogenmod 13 Auto reparieren drehen ständig fällt , welche Linien zu bearbeiten ( Sie hatte es bereits , und man konnte zu beheben )
[Miscellaneous Android Development] ottmi:
Although I'm a native German speaker I didn't understand a single word of this. What's wrong with auto rotation?
[Miscellaneous Android Development] 21prods:
Isn't it a robot?

Enviado desde mi Nexus 5 mediante Tapatalk
[Miscellaneous Android Development] siljaer:
So far, so good: my guinea pig has just confirmed, still no echo :)
[Miscellaneous Android Development] robot666:
durch kakoeto Zeit aufhört Autorotation zu betreiben. ( Sie bereits auf Ihrem Kernel haben ist ) , wie behebe wir es ( ein guter Kerl hat für unsere Kern x32 Maschine aber nach einer Weile nach dem Sperrbildschirm Autorotation stoppt raotat

---------- Post added at 10:35 AM ---------- Previous post was at 10:33 AM ----------

after a while no longer work autoturn . ( you already had on your kernel is ) how do we fix it ( a good guy did for our core x32 machine but it after a while , after the lock screen auto-rotation stops raotat
[Miscellaneous Android Development] ottmi:
I don't know. I never had such problems. For me it either worked or it didn't right after the boot. In any case it's most likely because the acceleration sensor stopped working..
[Miscellaneous Android Development] ik8vwa:
I downloaded the rom, installed on the sd card and then launched the twrp but it gives me back an error in red and the process stops!

What's wrong?

I wanted to try this rom cause it seems to have the sip voip unblocked.

I also own another trunk with stock rom and would like to activate the voip sip client, any chance the develper here or any other can help me telling which files and where need to be modified? I would appreciate that.
[Miscellaneous Android Development] ottmi:
What response did you expect with this kind of error description? Unless you quote the exact error message nobody will be able to help you.

As for the SIP client, I think the stock ROM has been compiled without. I don't think there's any easy way to enable it. Why don't you just use some 3rd party client?
[Miscellaneous Android Development] ik8vwa:
Ok thanks for your reply. You are right. I solved the rom installation related problem and you answered the voip question. I am now testing android 6 of your cm 13 on my backup trunk. As for the sip client, well normally embedded sip clients are far better under almost any circumstances (power drain, speed, interactions and so on) so I would have preferred a native solution.
[Miscellaneous Android Development] siljaer:
I use CSipSimple (Fdroid version). It can integrate with the dialer and the power drain is negligible (it does not even appear in the list, then it's under 1%). What really affects power drain is choosing to receive calls. AFAIK, stock sip client does not work with 3G, and it requires a hack to do so (I don't know about CM13 version, though).

However, when dealing with voip, having many configurable options can make the difference between being able to call and not, and the native client has really a few of them.
[Miscellaneous Android Development] ik8vwa:
Hi, when I had the thl W100 I used the native client but 3G was not the best due to hi latency. Since now I have 4G, an embedded client would be fantastic anyway I am using now Zoiper and so far it is working better, far better, than csip simple. As word goes, I have read that Bria should be even better.

Once again, thanks for your reply.
[Miscellaneous Android Development] josoft86:
TWRP 3.0.2-4 x64

[MENTION=7319300]ottmi[/MENTION] Thank you for your work, we have information where to find the TWRP version 3.0.2-4 updated x64.: o
[Miscellaneous Android Development] ik8vwa:
I am using this rom since this morning and I am absolutely shocked at the way the user interface has been conceived:

1 it does not show the carrier if you are using a roaming sim;

2 it is impossible to specify the frequency for each sim and the phone says that BOTH are in 4 G. This is nonsense;

3 the band selection compared to the standard rom is totally castrated.

I am totally and utterly disappointed. Simply pulling down the upper side of the screen doesn't even provide such basic and necessary info. How do you know which sim is using 3g and which 2 g?

Is there anyone who noticed this and is so kind to explain?

Thanks
[Miscellaneous Android Development] ottmi:
No idea. What's wrong with [MENTION=4729636]hisname[/MENTION]'s TWRP?
[Miscellaneous Android Development] ottmi:
Totally and utterly disappointed. Really? Isn't that a bit strong?

Only one SIM can be in 3G mode, the other one will be in 2G. You can set this in Settings->SIM cards. Not sure what kind of options the stock ROM offers for this but this is how it is in CM13.
[Miscellaneous Android Development] 21prods:
It always strikes me how people can sometimes be so...

Some good people have done a terrific job porting CM13 to our phone and sharing it with us here, ironing out some persistent problems like the echo during phone calls. They have not been paid, yet they have put their best endeavours to make it work. You don't like their job or CM13, ok, it's up to you. But you should never forget that you had the choice to install it or not and for free. Maybe next time you should double check whether the ROM you intend to install is what you really want or need.
[Miscellaneous Android Development] ik8vwa:
Sure, but what I pointed out are specific issues and at this stage I don't really grasp all the fuss about the cm when it lacks the most important options for a phone. Is it normal for you that you cannot see in any moment what's the roaming carrier of your sim card? Is it ok for you that the only options are lte, 3g, 2g? The sim "control room" is so complicated and messy that even the basic and most important informations are lost! I am upset because I used up more than 2 gb of mobile data to configure the phone and it was not worth it. If you have a dual sim, you want to be able to manage the two sims. Here instead when you pull down the menu, it shows the second sim! Let's say: stock roms are the best.