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 int sRate = audioContext[
"sampleRate"].as<
int>();
44 audioContext.call<
void>(
"close");
45 format.preferredFormat.setSampleRate(sRate);
48 auto f = QAudioFormat::Float;
50 if (!format.supportedSampleFormats.contains(f))
51 f = QAudioFormat::Int16;
52 format.preferredFormat.setSampleFormat(f);
59QWasmAudioDevice::QWasmAudioDevice(
const char *device,
const char *desc,
bool isDef,
60 QAudioDevice::Mode mode)
61 : QAudioDevicePrivate(device, mode, QString::fromUtf8(desc), isDef,
62 createDefaultWasmAudioDeviceFormat())