비슷한 문제가 있습니다. 내 응용 프로그램에서 시작 (사인파 진폭이 0), 그리고 2 초 후 진폭 = 10000의 사인파를 재생해야합니다.
때때로 AudioTrack (정적 모드 , stream is MUSIC), 아무 소리도 들리지 않습니다. 수동으로 볼륨을 변경 한 후에야 내 소리가 들리기 시작합니다. 사운드를 재생하기 전에 (조용한 경우에도) 스트림의 볼륨을 프로그래밍 방식으로 max로 설정하고 신호 진폭에 따라 출력 볼륨을 제어합니다.
이유를 알아 냈습니까?
업데이트 : 장치가이 이상한 상태에있는 동안, AudioManager.setStreamVolume에 내 전화가 작동하지 않는 이상한 일을 발견 더 깊이 문제에
다이빙. 나는이 확인 :
int max = mAudioManager.getStreamMaxVolume(SoundConfig.outputStreamType); // max = 15
int v = mAudioManager.getStreamVolume(SoundConfig.outputStreamType); // v = 0
mAudioManager.setStreamVolume(SoundConfig.outputStreamType, max, 0);
v = mAudioManager.getStreamVolume(SoundConfig.outputStreamType); // v = 0
내가 로그 캣 출력을 분석하기 시작 이후를, 무엇을 내가 찾은 것은 : - 이상한 상태에서 볼륨을 설정하고 재생을 시작 보이는 같은 :
12-19 12:45:37.120: D/AudioService(192): getStreamVolume(12)
12-19 12:45:40.970: D/AudioSystem(192): getParameters() ERROR : can't get parameters
12-19 12:45:40.970: D/AudioService(192): getStreamVolume(12)
12-19 12:45:45.680: D/AudioService(192): getStreamVolume(12)
12-19 12:45:50.120: I/AudioPolicyManager(110): startOutput() output 1, stream 3, session 6
12-19 12:45:50.120: I/AudioPolicyManager(110): getDeviceForStrategy() strategy 0, device 4
12-19 12:45:50.120: I/AudioPolicyManager(110): getDeviceForStrategy() strategy 0, device 4
12-19 12:45:50.120: I/AudioFlinger(110): start output streamType (0, 3) for 1
12-19 12:45:50.120: D/AudioHardware(110): AudioStreamOutALSA::setParameters() start_output_streamtype=3
12-19 15:25:02.521: D/AudioHardware(110): AudioHardware pcm playback is exiting standby.
그러나 정상에
(I 위아래로 볼륨 버튼을 누른 후) 상태는 다음과 같습니다 내가 최대로하는 방법 하드웨어 설정 볼륨을 볼 수있는 두 번째 경우
12-19 15:25:02.481: D/AudioSystem(193): getParameters() ERROR : can't get parameters
12-19 15:25:02.481: D/AudioService(193): getStreamVolume(12)
12-19 15:25:02.481: I/AudioService(193): AudioFocus abandonAudioFocus() from android.media.AudioManager#413cbf68com.kinsa.manager.CAndroidManager#414087a0
12-19 15:25:02.491: I/AudioService(193): AudioFocus requestAudioFocus() from android.media.AudioManager#413cbf68com.kinsa.manager.CAndroidManager#414087a0
12-19 15:25:02.491: D/AudioSystem(193): getParameters() ERROR : can't get parameters
12-19 15:25:02.491: D/AudioHardware(110): AudioStreamOutALSA::setParameters() music_volume_index=1
12-19 15:25:02.491: D/AudioService(193): getStreamVolume(12)
12-19 15:25:02.491: D/AudioService(193): getStreamVolume(12)
12-19 15:25:02.491: D/AudioService(193): getStreamVolume(12)
12-19 15:25:02.491: D/AudioSystem(193): getParameters() ERROR : can't get parameters
12-19 15:25:02.501: D/AudioService(193): getStreamVolume(12)
12-19 15:25:02.501: D/AudioService(193): getStreamVolume(12)
12-19 15:25:02.501: D/AudioService(193): getStreamVolume(12)
12-19 15:25:02.501: D/AudioHardware(110): AudioStreamOutALSA::setParameters() music_volume_index=15
12-19 15:25:02.521: I/AudioPolicyManager(110): startOutput() output 1, stream 3, session 3
12-19 15:25:02.521: I/AudioPolicyManager(110): getDeviceForStrategy() strategy 0, device 4
12-19 15:25:02.521: I/AudioPolicyManager(110): getDeviceForStrategy() strategy 0, device 4
12-19 15:25:02.521: I/AudioFlinger(110): start output streamType (0, 3) for 1
12-19 15:25:02.521: D/AudioHardware(110): AudioStreamOutALSA::setParameters() start_output_streamtype=3
12-19 15:25:02.521: D/AudioHardware(110): AudioHardware pcm playback is exiting standby.
하고 대기 상태를 종료하지만, 첫 번째 경우에는 발생하지 않습니다. 하지만 왜? 동일한 코드, 유일한 차이점은 두 번째 경우의 볼륨 버튼을 누른 후 실행한다는 것입니다.
아직 없습니다. 어쨌든 누군가가 상황을 알게되어 기쁩니다. – eNeLOu