Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible race condition in SFBAudioPlayerNode when accessing active decoders #558

Open
sbooth opened this issue Jan 22, 2025 · 1 comment

Comments

@sbooth
Copy link
Owner

sbooth commented Jan 22, 2025

I believe a similar bug exists in AudioPlayerNode in all methods accessing the current decoder. For example:

SFBPlaybackTime SFB::AudioPlayerNode::PlaybackTime() const noexcept
{
const auto decoderState = GetActiveDecoderStateWithSmallestSequenceNumber();
if(!decoderState)
return SFBInvalidPlaybackTime;
SFBPlaybackTime playbackTime = SFBInvalidPlaybackTime;
const auto framePosition = decoderState->FramePosition();
const auto frameLength = decoderState->FrameLength();
if(const auto sampleRate = decoderState->mSampleRate; sampleRate > 0) {
if(framePosition != SFBUnknownFramePosition)
playbackTime.currentTime = framePosition / sampleRate;
if(frameLength != SFBUnknownFrameLength)
playbackTime.totalTime = frameLength / sampleRate;
}
return playbackTime;
}

After the decoderState pointer is loaded, it could become invalid (deleted) at any time. Access and deletion of a DecoderState should probably be protected by a lock.

Originally posted by @jlama in #548

@sbooth
Copy link
Owner Author

sbooth commented Jan 22, 2025

I'm investigating a possible fix in #557

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant