[英]Android AudioManager.setMode(MODE_NORMAL) fails
I have 2 VoIP apps I'm developing that need to work together; 我正在开发2个需要协同工作的VoIP应用程序; one is a softphone app (App A) that uses various audio modes as expected ie RINGTONE, IN_COMMUNICATION, etc. The other app (App B) needs audio mode NORMAL. 一个是软电话应用程序(App A),它使用各种音频模式,如RINGTONE,IN_COMMUNICATION等。另一个应用程序(App B)需要音频模式NORMAL。 I try to make sure they play nice with each other so when softphone App A completes a call, it returns the audio mode to NORMAL. 我尝试确保彼此玩得很好,所以当软电话App A完成一个电话时,它会将音频模式恢复为NORMAL。 Likewise, if App B needs to operate in the middle of something App A may be doing, it saves the audio mode it found and restores that when complete. 同样,如果App B需要在App A正在做的事情中间运行,它会保存它找到的音频模式并在完成后恢复。
For example, for an inbound call, App A might change audio modes like so: 例如,对于入站呼叫,App A可能会更改音频模式,如下所示:
If App B needs to do something while a call is connected (step 2 above) it will 如果App B在连接呼叫时需要做某事(上面的步骤2),它会
Both apps get the Android AudioManager using their application context. 两个应用程序都使用其应用程序上下文获取Android AudioManager。
The problem I have, and that I don't understand, is that once App B goes through the above steps, App A fails in its attempt to return the audio mode to NORMAL after the call is terminated. 我遇到的问题是,一旦App B完成上述步骤,App A就会在呼叫终止后尝试将音频模式恢复为NORMAL。
myAudioManagerReference.setMode(AudioManager.MODE_NORMAL);
if (myAudioManagerReference.getMode() != AudioManager.MODE_NORMAL)
Log.w(CLASSTAG, "failure to set audio mode to MODE_NORMAL);
Is it possible for my App B to have some sort of lock on the AudioManager mode? 我的App B是否可以对AudioManager模式进行某种锁定? Or to have changed the permissions for App A such that it cannot change mode back to NORMAL? 或者更改了App A的权限,使其无法将模式更改回NORMAL? I have found that once I exit from App B, then App A can successfully change the mode to NORMAL. 我发现一旦我退出App B,App A就可以成功地将模式更改为NORMAL。
This looks like it MAY very well be a firmware issue. 这看起来很可能是一个固件问题。 I'm seeing suspicious logs from the ALSA driver on this device (an industrial mobile device) that looks like the driver could be using the wrong PID at times to make audio mode changes. 我在这台设备(工业移动设备)上看到来自ALSA驱动程序的可疑日志,看起来驱动程序有时会使用错误的PID来改变音频模式。 I've also NOT been able to recreate the same problem on any other device, including some from the same manufacturer. 我也无法在任何其他设备上重新创建相同的问题,包括来自同一制造商的一些设备。
Unfortunately, I don't yet have confirmation from the manufacturer (and ALSA driver writer) that this is the case. 不幸的是,我还没有得到制造商(以及ALSA驱动程序编写者)的确认,就是这种情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.