feat: audio tag hls support#1079
Conversation
| // AudioNode::~AudioNode() -> cleanup() does not call the virtual disable(), | ||
| // so the daemon thread is not guaranteed to have been joined yet. A still | ||
| // joinable std::thread would call std::terminate() on destruction. |
There was a problem hiding this comment.
i don't think this comment gives some important insight, tbh it can be removed
| [[deprecated( | ||
| "StreamerNode is legacy and will be removed. Use AudioFileSourceNode via the <Audio> component instead.")]]; |
There was a problem hiding this comment.
we do not want to expose that probably, I mean our end users won't see it anyway because they touch only js side not underlying cpp
| } else if (!options.memoryData.empty()) { | ||
| openResult = decoder_->openMemory( | ||
| contextSampleRate, options.memoryData.data(), options.memoryData.size()); |
There was a problem hiding this comment.
| } else if (!options.memoryData.empty()) { | |
| openResult = decoder_->openMemory( | |
| contextSampleRate, options.memoryData.data(), options.memoryData.size()); | |
| } else { | |
| openResult = decoder_->openMemory( | |
| contextSampleRate, options.memoryData.data(), options.memoryData.size()); |
existence of one of this option is checked in AudioFileSourceNode, we can probably simplified this branch and maybe add comment about it
| decoder_ = std::make_unique<miniaudio_decoder::MiniAudioDecoder>(); | ||
| } | ||
|
|
||
| decoding::DecoderResult openResult = Ok(None); |
There was a problem hiding this comment.
| decoding::DecoderResult openResult = Ok(None); | |
| decoding::DecoderResult openResult = Err("Some init value"); |
I think initializing it with err value would be semantically more correct
There was a problem hiding this comment.
it should be replaced of course further in the code
| // True when the audio thread itself wrote onPositionChangedFlush (e.g. EOF), | ||
| // so sendOnPositionChangedEvent knows not to sync currentTime_ from the daemon. | ||
| bool audioThreadSetFlush_{false}; |
There was a problem hiding this comment.
I'm wondering if that is needed, can't we think of a way to simplify this logic and then sync times between threads in simpler manner?
Closes #
Introduced changes
HLSsupport in<Audio>SeekDecoderDaemonclass which holdSPSCs for communication between JS thread (seek commands) and Audio thread (decoded frames). The class is used as a daemon thread (viaoperator()()) that is spawned onplayand joined ondisable. Usesdecoding::IncrementalAudioDecoderdepending on the file format.AudioFileSourceNodehandles 3 threads:decoder->seekToTime, drains frameSPSCof stale frames in case of seek, pushes the decoded frames into the frameSPSCSPSC, in case of seek request outputs silenceNodeOptionsParserto handleHLSformat and throw in case of ffmpeg-less build when processing ffmpeg-required formatsStreamerNode@deprecatedannot on the JS sideChecklist