Skip to content

Commit

Permalink
fix: set startTime when first frame received in AudioSender
Browse files Browse the repository at this point in the history
  • Loading branch information
Apehum committed Oct 28, 2024
1 parent cda366d commit 42abe28
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class AudioSender(

val job = CoroutineScope(Dispatchers.Default).launch {
var sequenceNumber = 0L
val startTime = System.nanoTime()
var startTime = 0L

var endOfStream = false

Expand All @@ -49,6 +49,7 @@ class AudioSender(
if (!endOfStream) {
endOfStream = true
onEnd.invoke(sequenceNumber++)
startTime = 0L
}

delay(10L)
Expand All @@ -61,6 +62,7 @@ class AudioSender(

endOfStream = true
onEnd.invoke(sequenceNumber++)
startTime = 0L
continue
}

Expand All @@ -76,6 +78,10 @@ class AudioSender(
continue
}

if (startTime == 0L) {
startTime = System.nanoTime()
}

val frameTime = 20_000_000 * sequenceNumber
val waitTime = startTime + frameTime - System.nanoTime()

Expand Down
11 changes: 2 additions & 9 deletions client/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,5 @@ If you encounter any issues, please report them on Discord: https://discord.gg/u
Versions 2.0.x and 2.1.x are protocol-compatible,
so there’s no need to worry if the server hasn't been updated to 2.1.x.

### Changes in 2.1.1
- Build for 1.19.3 was reintroduced.
- Soften Minecraft version bounds:
- 1.20.4 now allows 1.20.2, 1.20.3 and 1.20.4
- 1.19.2 now allows 1.19, 1.19.1 and 1.19.2
- Updated to 1.21.2.
- Updated [slib](https://github.com/plasmoapp/mc-slib) to fix crash with EssentialAddons on world join.
- Fixed audio sources causing a high CPU load. [#421](https://github.com/plasmoapp/plasmo-voice/issues/421)
- Attempt to fix "Cannot measure distance between worlds" exception, see [#422](https://github.com/plasmoapp/plasmo-voice/issues/422).
### Changes in 2.1.2
- Fixed buffer overflow when using AudioSender with delayed first frame.
3 changes: 2 additions & 1 deletion proxy/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ If you encounter any issues, please report them on Discord: https://discord.gg/u
Versions 2.0.x and 2.1.x are protocol-compatible,
so there’s no need to worry if the server hasn't been updated to 2.1.x.

### Changes in 2.1.1
### Changes in 2.1.2
- Fixed buffer overflow when using AudioSender with delayed first frame.
4 changes: 2 additions & 2 deletions server/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ If you encounter any issues, please report them on Discord: https://discord.gg/u
Versions 2.0.x and 2.1.x are protocol-compatible,
so there’s no need to worry if the server hasn't been updated to 2.1.x.

### Changes in 2.1.1
- Attempt to fix "Cannot measure distance between worlds" exception, see [#422](https://github.com/plasmoapp/plasmo-voice/issues/422).
### Changes in 2.1.2
- Fixed buffer overflow when using AudioSender with delayed first frame.

0 comments on commit 42abe28

Please sign in to comment.