Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqnxaudiodevice.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 Research In Motion
2// Copyright (C) 2021 The Qt Company
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#include "qqnxaudiodevice_p.h"
6
7#include "qqnxaudioutils_p.h"
8
9#include <array>
10
11#include <sys/asoundlib.h>
12
13using namespace QnxAudioUtils;
14
16
18 : QAudioDevicePrivate(deviceName, mode)
19{
20 isDefault = id.contains("Preferred");
21
23
25
28
29 const std::optional<snd_pcm_channel_info_t> info = pcmChannelInfo(id, mode);
30
31 if (!info)
32 return;
33
34 minimumSampleRate = info->min_rate;
35 maximumSampleRate = info->max_rate;
36
37 constexpr std::array sampleRates { 48000, 44100, 22050, 16000, 11025, 8000 };
38
39 for (int rate : sampleRates) {
40 if (rate <= maximumSampleRate && rate >= minimumSampleRate) {
42 break;
43 }
44 }
45
46 if (info->formats & SND_PCM_FMT_U8) {
49 }
50
51 if (info->formats & SND_PCM_FMT_S16) {
54 }
55
56 if (info->formats & SND_PCM_FMT_S32)
58
59 if (info->formats & SND_PCM_FMT_FLOAT)
61}
62
66
68{
70
71 if (!handle)
72 return false;
73
74 const std::optional<snd_pcm_channel_info_t> info = pcmChannelInfo(handle.get(), mode);
75
76 if (!info)
77 return false;
78
79 snd_pcm_channel_params_t params = formatToChannelParams(format, mode, info->max_fragment_size);
80 const int errorCode = snd_pcm_plugin_params(handle.get(), &params);
81
82 return errorCode == 0;
83}
84
QAudioFormat preferredFormat
QList< QAudioFormat::SampleFormat > supportedSampleFormats
Mode
Describes the mode of this device.
The QAudioFormat class stores audio stream parameter information.
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.
\inmodule QtCore
Definition qbytearray.h:57
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:6018
bool isFormatSupported(const QAudioFormat &format) const
QnxAudioDeviceInfo(const QByteArray &deviceName, QAudioDevice::Mode mode)
Combined button and popup list for selecting options.
std::optional< snd_pcm_channel_info_t > pcmChannelInfo(snd_pcm_t *handle, QAudioDevice::Mode mode)
std::unique_ptr< snd_pcm_t, HandleDeleter > HandleUniquePtr
HandleUniquePtr openPcmDevice(const QByteArray &id, QAudioDevice::Mode mode)
snd_pcm_channel_params_t formatToChannelParams(const QAudioFormat &format, QAudioDevice::Mode mode, int fragmentSize)
GLuint64 GLenum void * handle
GLenum mode
GLint GLsizei GLsizei GLenum format
void ** params
GLuint GLenum * rate
QHostInfo info
[0]