Permalink
Browse files

fix read()=0 error message at stop

  • Loading branch information...
1 parent 0155e1b commit 4a431a38fffc9784b8fc796abee44f832d4080a2 @ge0rg committed Apr 5, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 src/backend/AfskDemodulator.scala
View
4 src/backend/AfskDemodulator.scala
@@ -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)
}

0 comments on commit 4a431a3

Please sign in to comment.