diff options
author | Ricardo Garcia <rago@google.com> | 2015-04-02 18:00:28 -0700 |
---|---|---|
committer | Ricardo Garcia <rago@google.com> | 2015-04-02 18:00:28 -0700 |
commit | cad2162a2778830db832247864697a2f11cc71ae (patch) | |
tree | 93196ecced30e68a0d5f24943e5c3cbadcef61a0 | |
parent | 97f7ad49711fdca8da3eeb302e3a7b8779359141 (diff) | |
download | drrickorang-cad2162a2778830db832247864697a2f11cc71ae.tar.gz |
Bugfix for jni min buffer size computation
-rw-r--r-- | LoopbackApp/app/src/main/java/org/drrickorang/loopback/LoopbackApplication.java | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/LoopbackApp/app/src/main/java/org/drrickorang/loopback/LoopbackApplication.java b/LoopbackApp/app/src/main/java/org/drrickorang/loopback/LoopbackApplication.java index 70c5cda..736e64a 100644 --- a/LoopbackApp/app/src/main/java/org/drrickorang/loopback/LoopbackApplication.java +++ b/LoopbackApp/app/src/main/java/org/drrickorang/loopback/LoopbackApplication.java @@ -38,29 +38,6 @@ public class LoopbackApplication extends Application { public static final int BYTES_PER_FRAME = 2; public void setDefaults () { -// mSamplingRate = 48000; -// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { -// AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); -// String value = am.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE); -// mSamplingRate = Integer.parseInt(value); -// } -// if (isSafeToUseSles()) { -// -// mAudioThreadType = AUDIO_THREAD_TYPE_NATIVE; -// mPlayBufferSizeInBytes = 480; -// mPlayBufferSizeInBytes = 480; -// } -// else { -// -// mAudioThreadType = AUDIO_THREAD_TYPE_JAVA; -// mPlayBufferSizeInBytes = AudioTrack.getMinBufferSize(mSamplingRate, -// AudioFormat.CHANNEL_OUT_MONO, -// AudioFormat.ENCODING_PCM_16BIT); -// -// mRecordBuffSizeInBytes = AudioRecord.getMinBufferSize(mSamplingRate, -// AudioFormat.CHANNEL_IN_MONO, -// AudioFormat.ENCODING_PCM_16BIT); -// } if (isSafeToUseSles()) { mAudioThreadType = AUDIO_THREAD_TYPE_NATIVE; @@ -114,10 +91,11 @@ public class LoopbackApplication extends Application { AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); String value = am.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER); - int minBufferSize = Integer.parseInt(value); + int minBufferSizeInFrames = Integer.parseInt(value); + int minBufferSizeInBytes = BYTES_PER_FRAME * minBufferSizeInFrames; - setPlayBufferSizeInBytes(minBufferSize); - setRecordBufferSizeInBytes(minBufferSize); + setPlayBufferSizeInBytes(minBufferSizeInBytes); + setRecordBufferSizeInBytes(minBufferSizeInBytes); } else { int minPlayBufferSizeInBytes = AudioTrack.getMinBufferSize(samplingRate, |