55 std::optional<qsizetype> ringbufferSize, QWindowsAudioSink *parent,
56 float volume, std::optional<int32_t> hardwareBufferSize,
68 bool start(QIODevice *);
79 bool openAudioClient(ComPtr<IMMDevice>, AudioEndpointRole);
82 template <
typename Functor>
83 bool visitAudioClientBuffer(Functor &&f);
86 void runProcessRingbufferLoop();
87 void runProcessCallbackLoop();
91 void handleAudioClientError();
92 void joinWorkerThread();
94 ComPtr<IAudioClient3> m_audioClient;
95 ComPtr<IAudioRenderClient> m_renderClient;
97 QWindowsAudioUtils::reference_time m_periodSize;
98 qsizetype m_audioClientFrames;
100 std::atomic_bool m_suspended{};
102 QAutoResetEvent m_ringbufferDrained;
104 const AudioEndpointRole m_role;
106 const QUniqueWin32NullHandle m_wasapiHandle;
107 std::unique_ptr<QThread> m_workerThread;
109 AudioCallback m_audioCallback;
111 QWindowsAudioSink *m_parent;
113 QAudioFormat m_hostFormat;
114 std::unique_ptr<
char[]> m_preallocatedBuffer;
115 std::unique_ptr<std::pmr::memory_resource> m_memoryResource;
116 std::unique_ptr<QWindowsResampler> m_resampler;
QWASAPIAudioSinkStream(QAudioDevice, const QAudioFormat &, std::optional< qsizetype > ringbufferSize, QWindowsAudioSink *parent, float volume, std::optional< int32_t > hardwareBufferSize, AudioEndpointRole)