Repository navigation
Add loop callback to sfSoundStream - #422
Merged
Merged
Conversation
- Add an optional onLoop callback to sfSoundStream_create - Use the same types for sfSoundStreamChunk as sf::SoundStream::Chunk Co-authored-by: Miron Alexandru <mironalex@hotmail.com>
eXpl0it3r
force-pushed
the
feature/sound-stream-loop
branch
from
November 7, 2026 15:49
d4537a2 to
5cea0cc
Compare
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.
sf::SoundStream::onLoopcouldn't be overridden from CSFML so far. LikeonGetDataandonSeek, it's now an optional callback passed tosfSoundStream_create, which keeps it consistent withsfSoundRecorder_createand avoids changing callbacks while the audio thread is running. If it'sNULL, SFML's default behavior is used, i.e. seek to the beginning and continue from sample 0.Additionally,
sfSoundStreamChunknow uses the same types assf::SoundStream::Chunk, a test checks the layout.This replaces #397 with the approach discussed there. As
sf::Musicisn't really meant to be extended,sfMusicdoesn't get overrides, custom streaming can be built on top ofsfSoundStreaminstead. Thanks to @Marioalexsan for the initial work, the chunk changes are taken from #397.Note that this breaks the API:
sfSoundStream_createtakes a newonLoopparameter afteronSeeksfSoundStreamChunk::samplesisconst int16_t*andsfSoundStreamChunk::sampleCountissize_tReturning
falsefrom the loop callback doesn't stop the stream, same as returningstd::nulloptin SFML, see SFML/SFML#3777.Closes #394
How to test this PR?
CI should succeed.
Create a looping
sfSoundStreamwith a loop callback and check that it gets called whenever the stream reaches its end.