-
Notifications
You must be signed in to change notification settings - Fork 122
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
Fix/alsa wait #1770
Fix/alsa wait #1770
Conversation
previously, `wait()` was returnign immediately, but `stop()` was not stopping properly (drain, instead of drop), so it had the impression of working.
…iod worth of frames remaining Fixes the issue where sounds where not properly waiting to play before finishing. Would cause only a very small portion of the start of the sound to play.
Codecov ReportPatch coverage has no change and project coverage change:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## main #1770 +/- ##
==========================================
- Coverage 51.19% 51.16% -0.04%
==========================================
Files 1740 1740
Lines 102140 102163 +23
Branches 14453 14456 +3
==========================================
- Hits 52294 52270 -24
- Misses 45905 45935 +30
- Partials 3941 3958 +17
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
korau/src/commonMain/kotlin/korlibs/audio/sound/backends/ALSA.kt
Outdated
Show resolved
Hide resolved
korau/src/commonMain/kotlin/korlibs/audio/sound/backends/ALSA.kt
Outdated
Show resolved
Hide resolved
korau/src/commonMain/kotlin/korlibs/audio/sound/backends/ALSA.kt
Outdated
Show resolved
Hide resolved
All modification of |
Thanks! |
The previous commit did fix ALSA not being interruptible, but I notice that it also doesn't cleanly end on it own (i.e. without being interrupted). Specifically,
availableSamples
was not implemented, sowait()
always returned immediately. This was not noticed, sincestop()
calleddrain()
which waits for the written audio to end. This seeks to solve that by:availableSamples
sowait()
works properlystop()
to callsnd_pcm_drop()
instead ofsnd_pcm_drain()
to immediately drop all remaining frames, instead of waiting for them to finishwait()
thenstop()
when a sound is donestop()
when a sound is cancelledsnd_pcm_delay()
to get the number offrames
remaining to be heard aftersnd_pcm_writei
to determine how long to wait before writing the next sound (or returning, if done).