Commit 6f9e4470 authored by Sébastien Toque's avatar Sébastien Toque
Browse files

use at leat MinBufferSize of AudioTrack

(avoid ERROR/AudioTrack: Invalid buffer size)
parent b7e72ba2
......@@ -21,11 +21,14 @@ public class Aout {
public void init(int sampleRateInHz, int channels, int samples) {
Log.d(TAG, sampleRateInHz + ", " + channels + ", " + samples + "=>" + channels * samples);
int minBufferSize = AudioTrack.getMinBufferSize(sampleRateInHz,
AudioFormat.CHANNEL_CONFIGURATION_STEREO,
AudioFormat.ENCODING_PCM_16BIT);
mAudioTrack = new AudioTrack(AudioManager.STREAM_MUSIC,
sampleRateInHz,
AudioFormat.CHANNEL_CONFIGURATION_STEREO,
AudioFormat.ENCODING_PCM_16BIT,
channels * samples * 2,
Math.max(minBufferSize, channels * samples * 2),
AudioTrack.MODE_STREAM);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment