18 QAudioDevicePrivate::AudioDeviceFormat format;
20 format.minimumChannelCount = 1;
21 format.maximumChannelCount = 2;
22 format.minimumSampleRate = 8000;
23 format.maximumSampleRate = 96000;
26 format.supportedSampleFormats.append(QAudioFormat::UInt8);
27 format.supportedSampleFormats.append(QAudioFormat::Int16);
30 if (alIsExtensionPresent(
"AL_EXT_float32"))
31 format.supportedSampleFormats.append(QAudioFormat::Float);
33 format.preferredFormat.setChannelCount(2);
38 emscripten::val audioContext = emscripten::val::global(
"window")[
"AudioContext"].new_();
39 if (audioContext == emscripten::val::undefined())
40 audioContext = emscripten::val::global(
"window")[
"webkitAudioContext"].new_();
42 if (audioContext != emscripten::val::undefined()) {
43 audioContext.call<
void>(
"resume");
44 int sRate = audioContext[
"sampleRate"].as<
int>();
45 audioContext.call<
void>(
"close");
46 format.preferredFormat.setSampleRate(sRate);
49 auto f = QAudioFormat::Float;
51 if (!format.supportedSampleFormats.contains(f))
52 f = QAudioFormat::Int16;
53 format.preferredFormat.setSampleFormat(f);
60QWasmAudioDevice::QWasmAudioDevice(
const char *device,
const char *desc,
bool isDef,
61 QAudioDevice::Mode mode)
62 : QAudioDevicePrivate(device, mode, QString::fromUtf8(desc), isDef,
63 createDefaultWasmAudioDeviceFormat())