Skip to content

Commit

Permalink
fix(client): update last buffer time in al source if samples write wa…
Browse files Browse the repository at this point in the history
…s skipped
  • Loading branch information
Apehum committed Nov 16, 2024
1 parent 9359a30 commit 19200b6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ public interface AlSource extends DeviceSource {
*/
void setCloseTimeoutMs(long timeoutMs);

/**
* Updates last buffer time to current time provided by the time supplier.
*/
void updateLastBufferTime();

/**
* Gets the OpenAL format of the source.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ class StreamAlSource private constructor(
this.closeTimeoutMs = timeoutMs
}

override fun updateLastBufferTime() {
lastBufferTime = timeSupplier.currentTimeMillis
}

override fun write(samples: ShortArray, applyFilters: Boolean) {
val processedSamples = if (applyFilters) {
device.processFilters(samples)
Expand Down Expand Up @@ -202,7 +206,7 @@ class StreamAlSource private constructor(
queueWithEmptyBuffers()
fillQueue()

lastBufferTime = timeSupplier.currentTimeMillis
updateLastBufferTime()
availableBuffer[0] = -1

while (isStreaming.get()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,8 @@ abstract class BaseClientAudioSource<T>(
} catch (e: CodecException) {
BaseVoice.DEBUG_LOGGER.warn("Failed to decode source audio", e)
}
} else {
source.updateLastBufferTime()
}

lastSequenceNumber = packet.sequenceNumber
Expand Down

0 comments on commit 19200b6

Please sign in to comment.