Skip to content

Conversation

@maciejmakowski2003
Copy link
Collaborator

@maciejmakowski2003 maciejmakowski2003 commented Dec 29, 2025

Closes RNAA-250

⚠️ Breaking changes ⚠️

Introduced changes

  • Enhanced communication between JS thread and Audio thread. All node's modifications from JS thread are scheduled on CrossThreadEventScheduler wrapper to be executed on Audio thread. HostObject plays a ShadowAudioNode role - it stores a copy of node's state.

Read: Simply read HostObject state
Write: Schedule modification and modify Shadow State

Lock free approach!!!

TODO:

  • AudioNode creation guide
  • test AudioPlayer on Android
  • lambda dtor
  • buffer copy constraints

Nodes:

  • OscillatorNode
  • AnalyserNode
  • BiquadFilterNode
  • ConvolverNode
  • IIRFilterNode
  • PeriodicWave
  • WaveShaper
  • AudioNode
  • AudioContext
  • BaseAudioContext
  • OfflineAudioContext

Checklist

  • Linked relevant issue
  • Updated relevant documentation
  • Added/Conducted relevant tests
  • Performed self-review of the code
  • Updated Web Audio API coverage
  • Added support for web

Copy link
Contributor

Choose a reason for hiding this comment

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

I would mark this as something that we need to take a look at. It would be very good to be 100% sure that it is thread safe.

Comment on lines +65 to +97
/// @brief Move constructor
/// @param other
FatFunction(FatFunction &&other) noexcept {
if (other.invoker_) {
if (other.mover_) {
other.mover_(storage_.data(), other.storage_.data());
} else {
std::memcpy(storage_.data(), other.storage_.data(), N);
}
invoker_ = other.invoker_;
deleter_ = other.deleter_;
mover_ = other.mover_;
other.reset();
}
}

/// @brief Move assignment operator
/// @param other
FatFunction &operator=(FatFunction &&other) noexcept {
if (this != &other) {
reset();
if (other.invoker_) {
if (other.mover_) {
other.mover_(storage_.data(), other.storage_.data());
} else {
std::memcpy(storage_.data(), other.storage_.data(), N);
}
invoker_ = other.invoker_;
deleter_ = other.deleter_;
mover_ = other.mover_;
other.reset();
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// @brief Move constructor
/// @param other
FatFunction(FatFunction &&other) noexcept {
if (other.invoker_) {
if (other.mover_) {
other.mover_(storage_.data(), other.storage_.data());
} else {
std::memcpy(storage_.data(), other.storage_.data(), N);
}
invoker_ = other.invoker_;
deleter_ = other.deleter_;
mover_ = other.mover_;
other.reset();
}
}
/// @brief Move assignment operator
/// @param other
FatFunction &operator=(FatFunction &&other) noexcept {
if (this != &other) {
reset();
if (other.invoker_) {
if (other.mover_) {
other.mover_(storage_.data(), other.storage_.data());
} else {
std::memcpy(storage_.data(), other.storage_.data(), N);
}
invoker_ = other.invoker_;
deleter_ = other.deleter_;
mover_ = other.mover_;
other.reset();
}
}
/// @brief Move constructor
/// @param other
FatFunction(FatFunction &&other) noexcept {
if (other.invoker_) {
if (other.mover_) {
other.mover_(storage_.data(), other.storage_.data());
} else {
std::memcpy(storage_.data(), other.storage_.data(), N);
}
invoker_ = other.invoker_;
deleter_ = other.deleter_;
mover_ = other.mover_;
other.reset();
}
}
/// @brief Move assignment operator
/// @param other
FatFunction &operator=(FatFunction &&other) noexcept {
if (this != &other) {
reset();
new (this) FatFunction(std::move(other));
}
}

code duplication

Copy link
Contributor

Choose a reason for hiding this comment

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

Uuuuu 🆒

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.

4 participants