Skip to content

Commit

Permalink
pre 2.3 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
arpruss committed Sep 10, 2019
1 parent e8db1b9 commit eaef717
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "omegacentauri.mobi.simplestopwatch"
minSdkVersion 4
targetSdkVersion 28
versionCode 11
versionName "1.10"
versionCode 12
versionName "1.11"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
13 changes: 10 additions & 3 deletions app/src/main/java/omegacentauri/mobi/simplestopwatch/MyChrono.java
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,17 @@ public void setAudio(String soundMode) {
longTone = new AudioTrack(STREAM, 44100, AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT, tone.length * 2, AudioTrack.MODE_STATIC);
longTone.write(tone, 0, tone.length);
int sessionId = longTone.getAudioSessionId();
int sessionId = 0;
int shortLength = Math.min(tone.length, (int) (44.100 * SHORT_TONE_LENGTH));
shortTone = new AudioTrack(STREAM, 44100, AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT, shortLength * 2, AudioTrack.MODE_STATIC, sessionId);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD) {
sessionId = longTone.getAudioSessionId();
shortTone = new AudioTrack(STREAM, 44100, AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT, shortLength * 2, AudioTrack.MODE_STATIC, sessionId);
}
else {
shortTone = new AudioTrack(STREAM, 44100, AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT, shortLength * 2, AudioTrack.MODE_STATIC);
}
shortTone.write(tone, 0, shortLength);
AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
am.setStreamVolume(STREAM, am.getStreamMaxVolume(STREAM), 0);
Expand Down

0 comments on commit eaef717

Please sign in to comment.