QtCraft API C++ classes QML types Handbook

QcAudioPlatform Class

What QcAudioOutput needs from the system's audio: the output devices, the formats they take and a sink that pulls the mixer. More...

Header: #include <audio/QcAudioPlatform.h>
Inherits: QObject
Inherited By:

QcSystemAudio

Public Types

struct Device
struct Format
struct Opened

Public Functions

virtual void close() = 0
virtual QByteArray defaultOutput() const = 0
virtual std::optional<QcAudioPlatform::Format> format(const QByteArray &device, int keepRate) const = 0
virtual QcAudioPlatform::Opened open(const QByteArray &device, const QcAudioPlatform::Format &format, const QcMixerDevice::Render &render) = 0
virtual QList<QcAudioPlatform::Device> outputs() const = 0
virtual void watchOutputs(bool watch) = 0

Signals

void failed(quint64 generation, int error)
void outputsChanged()

Detailed Description

QcSystemAudio is the one of Qt Multimedia; tests use a fake one to play through device changes and sink errors without a real device.

Member Function Documentation

[pure virtual] void QcAudioPlatform::close()

Stops the sink; render is not called any more once this returns.

[pure virtual] QByteArray QcAudioPlatform::defaultOutput() const

Returns the id of the system's default output; empty when it has none.

[signal] void QcAudioPlatform::failed(quint64 generation, int error)

The sink of generation stopped with error while playing and is closed.

[pure virtual] std::optional<QcAudioPlatform::Format> QcAudioPlatform::format(const QByteArray &device, int keepRate) const

Returns the format of device: float or 16-bit stereo at keepRate if device takes it (0: no rate to keep), else at the device's own rate; nullopt when the device takes neither or is not there.

[pure virtual] QcAudioPlatform::Opened QcAudioPlatform::open(const QByteArray &device, const QcAudioPlatform::Format &format, const QcMixerDevice::Render &render)

Starts a sink on device in format that pulls render, closing the one before; on an error nothing stays open. Returns when the sink plays (or failed to start).

[pure virtual] QList<QcAudioPlatform::Device> QcAudioPlatform::outputs() const

Returns the system's output devices.

[signal] void QcAudioPlatform::outputsChanged()

The system's devices or its default output changed (while watchOutputs() is on).

[pure virtual] void QcAudioPlatform::watchOutputs(bool watch)

While watch is true, outputsChanged() reports changes of the system's devices.