Skip to content

fix(aaudio): Wait for AAudioStream status change#1125

Merged
roderickvd merged 2 commits intoRustAudio:masterfrom
osoftware:master
Mar 18, 2026
Merged

fix(aaudio): Wait for AAudioStream status change#1125
roderickvd merged 2 commits intoRustAudio:masterfrom
osoftware:master

Conversation

@osoftware
Copy link
Contributor

This PR fixes two bugs at once.

After starting the stream and before the status changes to Started, dropping it causes the main thread to lock permanently. The underlying AAudioStream never closes while the drop method waits for it to close. By using wait_for_state_change method we ensure the play method won't return befor it's safe to drop the stream.

If wait_for_state_change is never called then AAudioStream_getTimestamp always returns InvalidState error leading to info.timestamp().capture and info.timestamp().playback in stream callbacks always returning zero.

Copy link
Member

@roderickvd roderickvd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution. A big PR was just merged so if you would be so kind to rebase and look at the review comments below? And add a changelog entry?

@osoftware osoftware force-pushed the master branch 2 times, most recently from 5f05ee3 to b420553 Compare March 18, 2026 20:25
@roderickvd
Copy link
Member

Thanks! Merging.

@roderickvd roderickvd merged commit 9d43748 into RustAudio:master Mar 18, 2026
31 checks passed
@roderickvd
Copy link
Member

@osoftware By the way and off-topic to this PR but since you're an AAudio user, can you confirm the dynamic tuning has been working well for you? (#1080 with AAudio defaulting to BufferSize::Default)

@osoftware
Copy link
Contributor Author

I've just tried it on https://github.com/osoftware/rush_audio and it works fine 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants