Skip to content

Media Element Audio Source Node#1072

Open
mdydek wants to merge 3 commits into
mainfrom
feat/mediaelementaudiosourcenode
Open

Media Element Audio Source Node#1072
mdydek wants to merge 3 commits into
mainfrom
feat/mediaelementaudiosourcenode

Conversation

@mdydek
Copy link
Copy Markdown
Collaborator

@mdydek mdydek commented May 18, 2026

Closes #

⚠️ Breaking changes ⚠️

Introduced changes

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
  • Updated old arch android spec file

@mdydek mdydek added the feature New feature label May 18, 2026
@mdydek mdydek changed the title feat: first impl of MEASN Media Element Audio Source Node May 18, 2026
Copy link
Copy Markdown
Contributor

@closetcaiman closetcaiman left a comment

Choose a reason for hiding this comment

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

nice!

Comment thread packages/audiodocs/docs/other/web-audio-api-coverage.mdx Outdated
Comment thread packages/audiodocs/docs/sources/media-element-audio-source-node.mdx Outdated
Comment thread packages/audiodocs/docs/sources/media-element-audio-source-node.mdx Outdated
Comment thread packages/audiodocs/docs/sources/media-element-audio-source-node.mdx Outdated
Comment thread packages/react-native-audio-api/common/cpp/audioapi/core/BaseAudioContext.cpp Outdated
Comment thread packages/react-native-audio-api/src/core/MediaElementAudioSourceNode.ts Outdated
Comment thread packages/react-native-audio-api/src/development/react/Audio/types.ts Outdated
@mdydek mdydek requested a review from closetcaiman May 20, 2026 15:06
Comment on lines +104 to +122
std::shared_ptr<MediaElementAudioSourceNode> AudioContext::createMediaElementSource(
const std::shared_ptr<AudioFileSourceNode> &fileSource) {
if (fileSource == nullptr) {
return nullptr;
}

auto mediaElementSource = std::make_shared<MediaElementAudioSourceNode>(
shared_from_this(),
fileSource,
MediaElementAudioSourceOptions(static_cast<int>(fileSource->getChannelCount())));

if (!fileSource->tryBindMediaElementSource(mediaElementSource)) {
return nullptr;
}

graphManager_->addMediaElementSourceNode(mediaElementSource);
return mediaElementSource;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

tiny-tiny nitpick

Is fileSource being nullptr equivalent to the case where user connects the node more than once? Because in MediaElementAudioSourceNodeHostObject it handles nullptr (return of this) as duplicate connection.

The interface of this function returns nullptr if fileSource is nullptr. It's used then in JSI_HOST_FUNCTION_IMPL(AudioContextHostObject, createMediaElementSource) which handles nullptr as "duplicate connection". While with JS-proxy it's impossible to pass a HostObject which would have its node as nullptr, the cpp code technically handles this case by this check (if(fileSource == nullptr). This together with the fallback in AudioContextHostObject causes an error mismatch ("duplicate connection" instead "no audionode"). We can use Result here to close all the gaps.

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

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants