Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwindowsaudioutils_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 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
4#ifndef QWINDOWSAUDIOUTILS_H
5#define QWINDOWSAUDIOUTILS_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qstring.h>
19#include <QtCore/private/qcomptr_p.h>
20#include <QtCore/private/quniquehandle_types_p.h>
21#include <QtMultimedia/qaudioformat.h>
22#include <QtMultimedia/private/qaudiosystem_p.h>
23
24#include <mmreg.h>
25
26#include <chrono>
27#include <optional>
28
29struct IAudioClient;
30struct IAudioClient3;
31struct IMFMediaType;
32struct IMMDevice;
34
35QT_BEGIN_NAMESPACE
36
37class QWindowsMediaFoundation;
38
39namespace QWindowsAudioUtils
40{
42
43// REFERENCE_TIME helper
44using reference_time = std::chrono::duration<long long, std::ratio<1, 10000000>>;
45static_assert(reference_time(1) == std::chrono::nanoseconds(100));
46
47// format utilities
48bool formatToWaveFormatExtensible(const QAudioFormat &format, WAVEFORMATEXTENSIBLE &wfx);
49std::optional<WAVEFORMATEXTENSIBLE> toWaveFormatExtensible(const QAudioFormat &format);
50
51QAudioFormat waveFormatExToFormat(const WAVEFORMATEX &in);
52Q_MULTIMEDIA_EXPORT QAudioFormat mediaTypeToFormat(IMFMediaType *mediaType);
53ComPtr<IMFMediaType> formatToMediaType(QWindowsMediaFoundation &, const QAudioFormat &format);
54QAudioFormat::ChannelConfig maskToChannelConfig(UINT32 mask, int count);
55
56// IAudioClient helpers
64createAudioClient(const ComPtr<IMMDevice> &, const QAudioFormat &,
65 std::optional<qsizetype> hardwareBufferFrames,
66 const QUniqueWin32NullHandle &wasapiEventHandle,
67 std::optional<AudioEndpointRole> = {});
68
69bool audioClientStart(const ComPtr<IAudioClient3> &);
70bool audioClientStop(const ComPtr<IAudioClient3> &);
71bool audioClientReset(const ComPtr<IAudioClient3> &);
72bool audioClientSetRate(const ComPtr<IAudioClient3> &, int rate);
73bool audioClientSetRole(const ComPtr<IAudioClient3> &client, AudioEndpointRole role);
74
75std::optional<quint32> getBufferSizeInFrames(const ComPtr<IAudioClient3> &client);
81std::optional<AudioClientDevicePeriod> getDevicePeriod(const ComPtr<IAudioClient3> &client);
82
83// wasapi thread helper
85
86// error stringification
88
89} // namespace QWindowsAudioUtils
90
91QT_END_NAMESPACE
92
93#endif // QWINDOWSAUDIOUTILS_H
static constexpr QAudioFormat::AudioChannelPosition channelFormatMap[]
QAudioFormat mediaTypeToFormat(IMFMediaType *mediaType)
std::optional< AudioClientCreationResult > createAudioClient(const ComPtr< IMMDevice > &device, const QAudioFormat &format, std::optional< qsizetype > hardwareBufferFrames, const QUniqueWin32NullHandle &wasapiEventHandle, std::optional< AudioEndpointRole > role)
bool audioClientSetRate(const ComPtr< IAudioClient3 > &client, int rate)
bool audioClientSetRole(const ComPtr< IAudioClient3 > &client, AudioEndpointRole role)
ComPtr< IMFMediaType > formatToMediaType(QWindowsMediaFoundation &wmf, const QAudioFormat &format)
bool audioClientStop(const ComPtr< IAudioClient3 > &client)
bool audioClientStart(const ComPtr< IAudioClient3 > &client)
std::optional< WAVEFORMATEXTENSIBLE > toWaveFormatExtensible(const QAudioFormat &format)
std::optional< quint32 > getBufferSizeInFrames(const ComPtr< IAudioClient3 > &client)
static UINT32 channelConfigToMask(QAudioFormat::ChannelConfig config)
bool audioClientReset(const ComPtr< IAudioClient3 > &client)
std::optional< AudioClientDevicePeriod > getDevicePeriod(const ComPtr< IAudioClient3 > &client)
std::chrono::duration< long long, std::ratio< 1, 10000000 > > reference_time
QAudioFormat waveFormatExToFormat(const WAVEFORMATEX &in)
bool formatToWaveFormatExtensible(const QAudioFormat &format, WAVEFORMATEXTENSIBLE &wfx)
QAudioFormat::ChannelConfig maskToChannelConfig(UINT32 mask, int count)
void setMCSSForPeriodSize(reference_time periodSize)
QString audioClientErrorString(HRESULT hr)
#define AUDCLNT_E_EFFECT_NOT_AVAILABLE
#define AUDCLNT_E_EFFECT_STATE_READ_ONLY
LONGLONG REFERENCE_TIME