2011-08-18 2 views
3

Bonjour, J'ai écrit un programme (sur Android NDK), qui fournit un tampon audio via JNI en Java. Le problème de l'instabilité. Parfois, AudioTrack reproduit parfaitement le tampon, et parfois il y a ces messages:Problème avec AudioTrack

08-18 15:13:00.745: INFO/AudioTrack(12457): AudioTrack::set streamType[3] channels[12] format[1] sampleRate[44100] 08-18 15:13:00.749: INFO/AudioPolicyManager(2381): setOutputDevice() output 1 device 2 delayMs 0 force:0 08-18 15:13:04.183: INFO/AudioHardwareALSA(2381): Output standby called!!. Turn off PCM device.

code en Java comme ceci:

final int bufSize = AudioTrack.getMinBufferSize(44100, AudioFormat.CHANNEL_OUT_STEREO, AudioFormat.ENCODING_PCM_16BIT); 
track = new AudioTrack(AudioManager.STREAM_MUSIC, 44100,AudioFormat.CHANNEL_CONFIGURATION_STEREO,AudioFormat.ENCODING_PCM_16BIT, bufSize, AudioTrack.MODE_STREAM); 
track.play(); 
int byt = track.write(buf, 0, length); 

Dans ce qui pourrait être un problème avec cette erreur?

Répondre

3

Vous devez appeler track.write et remplir d'abord la taille minimale bufSize avant d'appeler track.play.

Questions connexes