Private helper to initialize WasmAudioInput
| 14 | |
| 15 | // Private helper to initialize WasmAudioInput |
| 16 | static 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 | |
| 42 | WasmAudioImpl::WasmAudioImpl(const fl::string& name) |
| 43 | : mName(name) |
no test coverage detected