android中 wfd 模式下,音量调节问题

Android设备使用wifi-direct,将屏幕投射到其他设备时,本地调节音量会从最大直接到最小,或者最小直接到最大。

究其原因:


   428     // Devices for which thevolume is fixed and VolumePanel slider should be disabled

>> 429     final int mFixedVolumeDevices =AudioSystem.DEVICE_OUT_AUX_DIGITAL |

  430            AudioSystem.DEVICE_OUT_DGTL_DOCK_HEADSET |

  431            AudioSystem.DEVICE_OUT_ALL_USB |

  432            AudioSystem.DEVICE_OUT_PROXY; // use fixed volume on proxy device(WiFidisplay)

 

 

 

在连接WFD的时候,音频调节是直接从最大到最小的。

在AudioService.java中

  794     public voidadjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags,

 

 

 

  862         flags &=~AudioManager.FLAG_FIXED_VOLUME;

  863         if ((streamTypeAlias== AudioSystem.STREAM_MUSIC) &&

>> 864                ((device & mFixedVolumeDevices) != 0)) {

>> 865             flags |=AudioManager.FLAG_FIXED_VOLUME;

  866

  867             // Always togglebetween max safe volume and 0 for fixed volume devices where safe

  868             // volume isenforced, and max and 0 for the others.

  869             // This issimulated by stepping by the full allowed volume range

  870             if(mSafeMediaVolumeState == SAFE_MEDIA_VOLUME_ACTIVE &&

  871                     (device& mSafeMediaVolumeDevices) != 0) {

  872                 step =mSafeMediaVolumeIndex;

  873             } else {

  874                 step =streamState.getMaxIndex();

  875             }

  876             if (aliasIndex !=0) {

  877                 aliasIndex =step;

  878             }

 

 

当为FLAG_FIXED_VOLUME时,单步调节值直接为最大。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值