fix read()=0 error message at stop

javaax25
Georg Lukas 2012-04-05 20:30:19 +02:00
rodzic 7c71ae1e5c
commit 25f6a3952c
1 zmienionych plików z 3 dodań i 1 usunięć

Wyświetl plik

@ -27,7 +27,7 @@ class AfskDemodulator(au : AfskUploader, samplerate : Int) extends Thread("AFSK
Log.d(TAG, "running...")
try {
recorder.startRecording();
while (recorder.getRecordingState() != AudioRecord.RECORDSTATE_STOPPED) {
while (!isInterrupted() && (recorder.getRecordingState() != AudioRecord.RECORDSTATE_STOPPED)) {
val count = recorder.read(buffer_s, 0, BUF_SIZE)
Log.d(TAG, "read " + count + " samples")
if (count <= 0)
@ -49,7 +49,9 @@ class AfskDemodulator(au : AfskUploader, samplerate : Int) extends Thread("AFSK
def close() {
try {
this.interrupt()
recorder.stop()
this.join(50)
} catch {
case e : IllegalStateException => Log.w(TAG, "close(): " + e)
}