Skip to content

Commit

Permalink
Close stream only if it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
langma committed Jun 13, 2022
1 parent 3ea5a25 commit 15b00f0
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,10 @@ class Client (

override fun stopContext() {
this.audioRecorder.stopRecording()
val stream = this.getReadStream()
stream.close()
this.streams.remove(stream)
this.getReadStream()?.let {
it.close()
this.streams.remove(it)
}
}

override fun close() {
Expand All @@ -290,9 +291,9 @@ class Client (
this.identityService.close()
}

private fun getReadStream(): SluStream {
private fun getReadStream(): SluStream? {
if (this.streams.isEmpty()) {
throw NoActiveStreamException()
return null
}

// Always use the last stream for reading.
Expand Down

0 comments on commit 15b00f0

Please sign in to comment.