Media Element Audio Source Node#1072
Conversation
| 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; | ||
| } | ||
|
|
There was a problem hiding this comment.
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.
Closes #
Introduced changes
Checklist