播放ToneGenerator原因ANR

时间:2019-04-11 08:59:37

标签: android audio

单击拨号盘时,播放ToneGenerator,但会引起ANR。

日志:

01-02 04:02:48.209 392 2548 E audio_hw_primary: out_write: error -5, cannot write stream data: I/O error
01-02 04:02:48.209 392 2548 D audio_hw_primary: out_standby: enter: stream (0xae38a800) usecase(0: deep-buffer-playback)

01-02 04:02:48.249 392 3038 E audio_hw_primary: out_write: error -5, cannot write stream data: I/O error
01-02 04:02:48.249 392 3038 D audio_hw_primary: out_standby: enter: stream (0xae3ed000) usecase(1: low-latency-playback)

01-02 04:02:48.772 423 1116 W AudioFlinger: write blocked for 10554 msecs, 50 delayed writes, thread 0xae883ec0
01-02 04:02:48.772 423 1116 D AudioFlinger: mixer(0xae883ec0) throttle end: throttle time(19)

01-02 04:02:49.579 1767 1767 E ToneGenerator: — Stop timed out

01-02 04:02:52.639 1767 1767 E ToneGenerator: — Delayed start timed out, status -110
01-02 04:02:52.639 1767 1767 W ToneGenerator: Tone start failed!!!, time 8178550

您可以检查代码:DialpadFragment.java--ToneGenerator

private void playTone(int tone, int durationMs) 
private void stopTone()

ToneGenerator停止超时导致ANR。但是ToneGenerator导致停止超时的原因是什么?如何分析和解决此问题?

1 个答案:

答案 0 :(得分:0)

您可以为我简单地使用它及其工作

 ToneGenerator toneG = new ToneGenerator(AudioManager.STREAM_ALARM, 100);
 toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 200);