Skip to content

Commit

Permalink
fix read()=0 error message at stop
Browse files Browse the repository at this point in the history
  • Loading branch information
ge0rg committed Apr 5, 2012
1 parent 0155e1b commit 4a431a3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/backend/AfskDemodulator.scala
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AfskDemodulator(au : AfskUploader, samplerate : Int) extends Thread("AFSK
Log.d(TAG, "running...") Log.d(TAG, "running...")
try { try {
recorder.startRecording(); recorder.startRecording();
while (recorder.getRecordingState() != AudioRecord.RECORDSTATE_STOPPED) { while (!isInterrupted() && (recorder.getRecordingState() != AudioRecord.RECORDSTATE_STOPPED)) {
val count = recorder.read(buffer_s, 0, BUF_SIZE) val count = recorder.read(buffer_s, 0, BUF_SIZE)
Log.d(TAG, "read " + count + " samples") Log.d(TAG, "read " + count + " samples")
if (count <= 0) if (count <= 0)
Expand All @@ -49,7 +49,9 @@ class AfskDemodulator(au : AfskUploader, samplerate : Int) extends Thread("AFSK


def close() { def close() {
try { try {
this.interrupt()
recorder.stop() recorder.stop()
this.join(50)
} catch { } catch {
case e : IllegalStateException => Log.w(TAG, "close(): " + e) case e : IllegalStateException => Log.w(TAG, "close(): " + e)
} }
Expand Down

0 comments on commit 4a431a3

Please sign in to comment.