diff options
author | Ricardo Garcia <rago@google.com> | 2015-04-02 17:04:39 -0700 |
---|---|---|
committer | Ricardo Garcia <rago@google.com> | 2015-04-02 17:04:39 -0700 |
commit | 339e2b8eef0d5cd8e6033315a55df68eafd1c263 (patch) | |
tree | 8a2be098a2c0f2d3a65d5c529fc7bd22ca1efc3b /LoopbackApp/app/src | |
parent | e1b0d76f5597f735509e48e732e3efa26ea9fe0b (diff) | |
download | drrickorang-339e2b8eef0d5cd8e6033315a55df68eafd1c263.tar.gz |
Added open SLES query for preferred frame size.
Plus some minor cosmetic fixes
Diffstat (limited to 'LoopbackApp/app/src')
3 files changed, 32 insertions, 21 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 651983e..70c5cda 100644 --- a/LoopbackApp/app/src/main/java/org/drrickorang/loopback/LoopbackApplication.java +++ b/LoopbackApp/app/src/main/java/org/drrickorang/loopback/LoopbackApplication.java @@ -107,21 +107,28 @@ public class LoopbackApplication extends Application { int samplingRate = AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC); setSamplingRate(samplingRate); - int minPlayBufferSizeInBytes = AudioTrack.getMinBufferSize(samplingRate, - AudioFormat.CHANNEL_OUT_MONO, - AudioFormat.ENCODING_PCM_16BIT); - setPlayBufferSizeInBytes(minPlayBufferSizeInBytes); - int minRecBufferSizeInBytes = AudioRecord.getMinBufferSize(samplingRate, - AudioFormat.CHANNEL_IN_MONO, - AudioFormat.ENCODING_PCM_16BIT); - setRecordBufferSizeInBytes(minRecBufferSizeInBytes); if( mAudioThreadType == AUDIO_THREAD_TYPE_NATIVE) { - setPlayBufferSizeInBytes(minPlayBufferSizeInBytes/10); //rule of thumb, - // the ideal would be to ask openSLES for these numbers - setRecordBufferSizeInBytes(minRecBufferSizeInBytes/10); + + AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); + String value = am.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER); + int minBufferSize = Integer.parseInt(value); + + setPlayBufferSizeInBytes(minBufferSize); + setRecordBufferSizeInBytes(minBufferSize); + } else { + + int minPlayBufferSizeInBytes = AudioTrack.getMinBufferSize(samplingRate, + AudioFormat.CHANNEL_OUT_MONO, + AudioFormat.ENCODING_PCM_16BIT); + setPlayBufferSizeInBytes(minPlayBufferSizeInBytes); + + int minRecBufferSizeInBytes = AudioRecord.getMinBufferSize(samplingRate, + AudioFormat.CHANNEL_IN_MONO, + AudioFormat.ENCODING_PCM_16BIT); + setRecordBufferSizeInBytes(minRecBufferSizeInBytes); } //log("computed defaults"); diff --git a/LoopbackApp/app/src/main/res/layout/main_activity.xml b/LoopbackApp/app/src/main/res/layout/main_activity.xml index fe13b5b..f9cee12 100644 --- a/LoopbackApp/app/src/main/res/layout/main_activity.xml +++ b/LoopbackApp/app/src/main/res/layout/main_activity.xml @@ -94,16 +94,20 @@ </LinearLayout> - <SeekBar - android:id="@+id/BarMasterLevel" - android:indeterminate="false" - android:max="100" - android:progress="0" + <LinearLayout + android:orientation="horizontal" android:layout_width="fill_parent" - android:layout_height="wrap_content" - style="?android:attr/progressBarStyleHorizontal" - android:layout_marginRight="5dp" - android:layout_marginBottom="5px"/> + android:layout_height="wrap_content"> + + <SeekBar + android:id="@+id/BarMasterLevel" + android:indeterminate="false" + android:max="100" + android:progress="0" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + style="?android:attr/progressBarStyleHorizontal" /> + </LinearLayout> <LinearLayout android:layout_marginTop="0mm" diff --git a/LoopbackApp/app/src/main/res/values/strings.xml b/LoopbackApp/app/src/main/res/values/strings.xml index c34ac8f..5219316 100644 --- a/LoopbackApp/app/src/main/res/values/strings.xml +++ b/LoopbackApp/app/src/main/res/values/strings.xml @@ -30,7 +30,7 @@ <!-- disabled --> <string name="buttonZoomInFull">In Full</string> - <string name="buttonSettings">Settings bb</string> + <string name="buttonSettings">Settings</string> <string name="labelInfo">Info...</string> <string name="labelSettings">SETTINGS</string> |