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

Cubeb: rewrite locking #12805

Merged
merged 2 commits into from Oct 21, 2022
Merged

Cubeb: rewrite locking #12805

merged 2 commits into from Oct 21, 2022

Conversation

Vestrel
Copy link
Contributor

@Vestrel Vestrel commented Oct 13, 2022

Fixes #12528 and maybe #12798

rpcs3/Emu/Audio/Cubeb/CubebBackend.cpp Outdated Show resolved Hide resolved
rpcs3/Emu/Cell/Modules/cellAudio.cpp Outdated Show resolved Hide resolved
@@ -427,14 +432,14 @@ long CubebBackend::data_cb(cubeb_stream* stream, void* user_ptr, void const* /*

std::unique_lock lock(cubeb->m_cb_mutex, std::defer_lock);

if (stream != cubeb->m_stream)
if (!cubeb->m_reset_req.observe() && lock.try_lock_for(std::chrono::microseconds{50}) && cubeb->m_write_callback && cubeb->m_playing)
Copy link
Contributor

@elad335 elad335 Oct 13, 2022

Choose a reason for hiding this comment

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

Chancing a lock for a period of time needs to be well justified otherwise it looks like a workaround.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's typically taken by nonblocking code for a short period of time, so it makes sense to spin a bit.

@Vestrel Vestrel force-pushed the audio_fixes branch 2 times, most recently from d5a630d to 885500b Compare October 15, 2022 23:38
@Vestrel Vestrel marked this pull request as ready for review October 16, 2022 00:08
@Megamouse Megamouse merged commit a1f9ff0 into RPCS3:master Oct 21, 2022
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.

[Regression] RPCS3 crashes if airpods are taken off on macOS.
3 participants