Skip to content

Commit

Permalink
Chunking: Honor buffer.hasRemaining() and otherwise release the buffe…
Browse files Browse the repository at this point in the history
  • Loading branch information
vanniktech authored Feb 20, 2023
1 parent ccbcd50 commit f51a806
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ internal class ChunkQueue(private val sampleRate: Int, private val channels: Int
fun isEmpty() = queue.isEmpty()

fun enqueue(buffer: ShortBuffer, timeUs: Long, timeStretch: Double, release: () -> Unit) {
require(buffer.hasRemaining())
queue.addLast(Chunk(buffer, timeUs, timeStretch, release))
if (buffer.hasRemaining()) {
queue.addLast(Chunk(buffer, timeUs, timeStretch, release))
} else {
release()
}
}

fun enqueueEos() {
Expand Down

0 comments on commit f51a806

Please sign in to comment.