Merge branch 'audiorecorder-1.1.2'

This commit is contained in:
Alexey Kuznetsov 2016-03-25 18:42:18 +03:00
commit d77e44ae57
3 changed files with 23 additions and 5 deletions

View file

@ -8,8 +8,8 @@ android {
applicationId "com.github.axet.audiorecorder"
minSdkVersion 16
targetSdkVersion 23
versionCode 22
versionName "1.1.1"
versionCode 23
versionName "1.1.2"
}
signingConfigs {
release {

View file

@ -525,6 +525,9 @@ public class RecordingActivity extends AppCompatActivity {
}
void record() {
pitch.setOnClickListener(null);
pitch.setClickable(false);
state.setText("recording");
silent();
@ -546,8 +549,8 @@ public class RecordingActivity extends AppCompatActivity {
}
long startTime = System.currentTimeMillis();
// start recording after 0.5 sec
long goTime = startTime + 500;
// start recording after 1 sec or stableRefresh
long goTime = startTime + 1000;
RawSamples rs = null;
AudioRecord recorder = null;
@ -593,7 +596,7 @@ public class RecordingActivity extends AppCompatActivity {
break;
}
if (cur > goTime) {
if (cur > goTime || pitch.stableRefresh()) {
rs.write(buffer);
int pa = getPa(buffer, 0, readSize);

View file

@ -55,6 +55,8 @@ public class PitchView extends ViewGroup {
// pitch length in pn + pitch delimiter length in px
int pitchSize;
boolean stableRefresh;
PitchGraphView graph;
PitchCurrentView current;
@ -544,10 +546,13 @@ public class PitchView extends ViewGroup {
}
}
if (thread == null) {
stableRefresh = false;
draw = new Runnable() {
@Override
public void run() {
time = System.currentTimeMillis();
int count = 0;
while (!Thread.currentThread().isInterrupted()) {
long time = System.currentTimeMillis();
draw();
@ -556,6 +561,10 @@ public class PitchView extends ViewGroup {
long delay = UPDATE_SPEED - (cur - time);
if (delay > 0) {
count++;
if (count > 5) {
stableRefresh = true;
}
try {
Thread.sleep(delay);
} catch (InterruptedException e) {
@ -627,4 +636,10 @@ public class PitchView extends ViewGroup {
thread.start();
}
}
public boolean stableRefresh() {
synchronized (this) {
return stableRefresh;
}
}
}