MCPcopy Create free account
hub / github.com/FastLED/FastLED / initWasmAudio

Function initWasmAudio

src/platforms/wasm/ui_audio_wasm.cpp.hpp:16–40  ·  view source on GitHub ↗

Private helper to initialize WasmAudioInput

Source from the content-addressed store, hash-verified

14
15// Private helper to initialize WasmAudioInput
16static void initWasmAudio(const char* name, WasmAudioInput*& wasmInput,
17 fl::shared_ptr<audio::IInput>& wasmInputOwner, bool& ownsInput) {
18 // Get or create the global WASM audio input
19 wasmInput = wasm_get_audio_input();
20
21 if (!wasmInput) {
22 // Create the WASM audio input if it doesn't exist
23 fl::string error;
24 // Use dummy I2S config (config is ignored for WASM anyway)
25 audio::ConfigI2S dummyConfig(0, 0, 0, 0, audio::AudioChannel::Left, 44100, 16);
26 wasmInputOwner = wasm_create_audio_input(fl::audio::Config(dummyConfig), &error);
27 if (wasmInputOwner) {
28 wasmInputOwner->start();
29 wasmInput = wasm_get_audio_input(); // Get the created instance
30 ownsInput = true;
31 FL_WARN("WasmAudioImpl: Created and started WasmAudioInput for '" << name << "'");
32 } else {
33 FL_WARN("WasmAudioImpl: Failed to create WasmAudioInput: " << error.c_str());
34 }
35 } else {
36 // Ensure the existing input is started
37 wasmInput->start();
38 FL_WARN("WasmAudioImpl: Using existing WasmAudioInput for '" << name << "'");
39 }
40}
41
42WasmAudioImpl::WasmAudioImpl(const fl::string& name)
43 : mName(name)

Callers 1

WasmAudioImplMethod · 0.85

Calls 5

wasm_get_audio_inputFunction · 0.85
wasm_create_audio_inputFunction · 0.85
ConfigClass · 0.50
startMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected