Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qwasmaudiodevice.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5#include <emscripten.h>
6#include <emscripten/val.h>
7#include <emscripten/bind.h>
8
9#include <AL/al.h>
10#include <AL/alc.h>
11
13
16{
18
19 isDefault = isDef;
22 minimumSampleRate = 8000;
23 maximumSampleRate = 96000; // js AudioContext max according to docs
24
25 // native openAL formats
28
29 // Browsers use 32bit floats as native, but emscripten reccomends checking for the exension.
30 if (alIsExtensionPresent("AL_EXT_float32"))
32
34
35 // FIXME: firefox
36 // An AudioContext was prevented from starting automatically.
37 // It must be created or resumed after a user gesture on the page.
38 emscripten::val audioContext = emscripten::val::global("window")["AudioContext"].new_();
39 if (audioContext == emscripten::val::undefined())
40 audioContext = emscripten::val::global("window")["webkitAudioContext"].new_();
41
42 if (audioContext != emscripten::val::undefined()) {
43 audioContext.call<void>("resume");
44 int sRate = audioContext["sampleRate"].as<int>();
45 audioContext.call<void>("close");
47 }
48
50
54}
55
IOBluetoothDevice * device
QAudioFormat preferredFormat
QList< QAudioFormat::SampleFormat > supportedSampleFormats
Mode
Describes the mode of this device.
constexpr void setSampleRate(int sampleRate) noexcept
Sets the sample rate to samplerate in Hertz.
constexpr void setSampleFormat(SampleFormat f) noexcept
Sets the sample format to format.
constexpr void setChannelCount(int channelCount) noexcept
Sets the channel count to channels.
void append(parameter_type t)
Definition qlist.h:441
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5857
QWasmAudioDevice(const char *device, const char *description, bool isDefault, QAudioDevice::Mode mode)
Combined button and popup list for selecting options.
GLenum mode
GLfloat GLfloat f
@ desc
bool contains(const AT &t) const noexcept
Definition qlist.h:44