简体   繁体   English

Android AudioManager.setMode(MODE_NORMAL)失败

[英]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可能会更改音频模式,如下所示:

  1. MODE_RINGTONE when call comes in 当呼叫进来时,MODE_RINGTONE
  2. MODE_IN_COMMUNICATION when call is connected 连接呼叫时MODE_IN_COMMUNICATION
  3. MODE_NORMAL after call is terminated 呼叫终止后MODE_NORMAL

If App B needs to do something while a call is connected (step 2 above) it will 如果App B在连接呼叫时需要做某事(上面的步骤2),它会

  1. save MODE_IN_COMMUNICATION 保存MODE_IN_COMMUNICATION
  2. set MODE_NORMAL 设置MODE_NORMAL
  3. do what it needs to do 做它需要做的事情
  4. restore MODE_IN_COMMUNICAITON 恢复MODE_IN_COMMUNICAITON

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.

相关问题 如何在调用AudioManager.setMode(MODE_NORMAL)时使用Android 8.0和8.1.0特定的SecurityException修复Samsung? - How to fix a Samsung with Android 8.0 and 8.1.0 specific SecurityException when calling AudioManager.setMode(MODE_NORMAL)? 我调用了 audiomanager.setMode(MODE_IN_CALL) 方法,我的耳机不再工作了 - I call the method audiomanager.setMode(MODE_IN_CALL) and my earphone doens't work anymore Android AudioManager setMode() 权限拒绝 - Android AudioManager setMode() permission Denial AudioManager 在 setMode(MODE_IN_COMMUNICATION) 中引入延迟 - AudioManager is introducing delay in the setMode(MODE_IN_COMMUNICATION) Android 5.0+ AudioManager setMode无法正常工作 - Android 5.0+ AudioManager setMode not working 华硕fonepad7,Android Audiomanager不能使用setMode() - Asus fonepad7, Android Audiomanager can't use setMode() android audiomanager 中 MODE_IN_COMMUNICATION 中的错误? - Bug in the MODE_IN_COMMUNICATION in android audiomanager? AudioManager类。 “ RINGER_MODE_NORMAL无法解析或不是字段” - AudioManager class. “RINGER_MODE_NORMAL cannot be resolved or is not a field” Android:无法在 AudioManager.MODE_IN_COMMUNICATION 中使用蓝牙 - Android: can't use Bluetooth in AudioManager.MODE_IN_COMMUNICATION Android:当 AudioManager 中的当前模式改变时得到通知 - Android: Get Notified when the current Mode inside AudioManager gets changed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM