File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
record_android/android/src/main/kotlin/com/llfbandit/record/record/recorder Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import com.llfbandit.record.record.format.Format
14
14
import com.llfbandit.record.record.format.OpusFormat
15
15
import com.llfbandit.record.record.format.PcmFormat
16
16
import com.llfbandit.record.record.format.WaveFormat
17
+ import java.util.concurrent.CountDownLatch
17
18
import java.util.concurrent.Executors
18
19
import java.util.concurrent.Semaphore
19
20
import java.util.concurrent.atomic.AtomicBoolean
@@ -84,6 +85,8 @@ class RecordThread(
84
85
fun getAmplitude (): Double = mPcmReader?.getAmplitude() ? : - 160.0
85
86
86
87
fun startRecording () {
88
+ val startLatch = CountDownLatch (1 )
89
+
87
90
mExecutorService.execute {
88
91
try {
89
92
val format = selectFormat()
@@ -97,6 +100,8 @@ class RecordThread(
97
100
98
101
recordState()
99
102
103
+ startLatch.countDown()
104
+
100
105
while (isRecording()) {
101
106
if (isPaused()) {
102
107
mIsPausedSem.acquire()
@@ -112,9 +117,12 @@ class RecordThread(
112
117
} catch (ex: Exception ) {
113
118
recorderListener.onFailure(ex)
114
119
} finally {
120
+ startLatch.countDown()
115
121
stopAndRelease()
116
122
}
117
123
}
124
+
125
+ startLatch.await()
118
126
}
119
127
120
128
private fun stopAndRelease () {
You can’t perform that action at this time.
0 commit comments