feat: AudioStream | expose frame-activity oracle (LastFrameReceivedAt)#69
Merged
Merged
Conversation
Add a cheap monotonic timestamp on every AudioStream that ticks
inside the FFI callback whenever a media frame is decoded. This is
the foundation for the NearbyVoiceChat single-active-sid resolver:
a stream that's alive is decoding frames; a ghost never decodes.
- AudioStreamInternal: private `lastFrameReceivedAt` (init -1),
Volatile.Read/Write around Environment.TickCount, set right before
the buffer write under the existing channel/sampleRate guards.
- AudioStream: pass-through `LastFrameReceivedAt`.
- IAudioStreams.GetLastFrameReceivedAt(StreamKey): returns -1 when
the stream is missing or has never emitted (sentinel chosen over
0 because TickCount is signed and can legitimately be 0/negative).
No Explorer-side consumer yet — existing API surface unchanged.
🔗 Merge Alignment ReminderIf this PR targets Both repos should be merged in coordination to avoid breaking changes. Do not merge one without the other being ready. |
NickKhalow
requested changes
May 20, 2026
NickKhalow
left a comment
There was a problem hiding this comment.
Great, addition. Please address the comments and then we can proceed to merge
| ); | ||
|
|
||
| private bool disposed; | ||
| private int lastFrameReceivedAt = -1; |
There was a problem hiding this comment.
lastFrameReceivedAt should be named with Volatile prefix to prevent its misuse
| return stream.AudioStreamInfo; | ||
| } | ||
|
|
||
| public int GetLastFrameReceivedAt(StreamKey streamKey) |
There was a problem hiding this comment.
use Option<> and avoid sentinel values
| public interface IAudioStreams : IStreams<AudioStream, AudioStreamInfo> | ||
| { | ||
|
|
||
| int GetLastFrameReceivedAt(StreamKey streamKey); |
There was a problem hiding this comment.
Looks like it could be an extension method or a method with default impl
NickKhalow
approved these changes
May 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a cheap monotonic timestamp on every AudioStream that ticks inside the FFI callback whenever a media frame is decoded. This is the foundation for the NearbyVoiceChat single-active-sid resolver (stream deduplication): a stream that's alive is decoding frames; a ghost never decodes.
lastFrameReceivedAt(init -1), Volatile.Read/Write around Environment.TickCount, set right before the buffer write under the existing channel/sampleRate guards.LastFrameReceivedAt.explorer consumer - decentraland/unity-explorer#8817