diff --git a/api/client/src/main/java/su/plo/voice/api/client/audio/device/source/AlSource.java b/api/client/src/main/java/su/plo/voice/api/client/audio/device/source/AlSource.java index f190f4c3..9e9906ca 100644 --- a/api/client/src/main/java/su/plo/voice/api/client/audio/device/source/AlSource.java +++ b/api/client/src/main/java/su/plo/voice/api/client/audio/device/source/AlSource.java @@ -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. * diff --git a/client/src/main/kotlin/su/plo/voice/client/audio/device/source/StreamAlSource.kt b/client/src/main/kotlin/su/plo/voice/client/audio/device/source/StreamAlSource.kt index 4a6ab435..21a4aaac 100644 --- a/client/src/main/kotlin/su/plo/voice/client/audio/device/source/StreamAlSource.kt +++ b/client/src/main/kotlin/su/plo/voice/client/audio/device/source/StreamAlSource.kt @@ -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) @@ -202,7 +206,7 @@ class StreamAlSource private constructor( queueWithEmptyBuffers() fillQueue() - lastBufferTime = timeSupplier.currentTimeMillis + updateLastBufferTime() availableBuffer[0] = -1 while (isStreaming.get()) { diff --git a/client/src/main/kotlin/su/plo/voice/client/audio/source/BaseClientAudioSource.kt b/client/src/main/kotlin/su/plo/voice/client/audio/source/BaseClientAudioSource.kt index 69a5e4e3..07da4bcd 100644 --- a/client/src/main/kotlin/su/plo/voice/client/audio/source/BaseClientAudioSource.kt +++ b/client/src/main/kotlin/su/plo/voice/client/audio/source/BaseClientAudioSource.kt @@ -382,6 +382,8 @@ abstract class BaseClientAudioSource( } catch (e: CodecException) { BaseVoice.DEBUG_LOGGER.warn("Failed to decode source audio", e) } + } else { + source.updateLastBufferTime() } lastSequenceNumber = packet.sequenceNumber