42 std::optional<int32_t> hardwareBufferFrames,
59 Q_UNREACHABLE_RETURN();
62 stream_events.state_changed = [](
void *userData, pw_stream_state old, pw_stream_state state,
67 std::vector<spa_dict_item> properties{
68 { PW_KEY_MEDIA_TYPE,
"Audio" },
70 properties.insert(properties.end(), extraProperties.begin(), extraProperties.end());
72 if (hardwareBufferFrames)
73 properties.push_back({
75 std::to_string(*hardwareBufferFrames).data(),
79 m_stream = PwStreamHandle{
80 pw_stream_new_simple(QAudioContextManager::getEventLoop(), streamName,
81 makeProperties(properties).release(), &stream_events,
this),
92 QAudioContextManager::deviceMonitor().findObjectId(target);
97 if (!deviceAlreadyRemoved)
100 std::array<uint8_t, 1024> buffer;
103 QT_WARNING_DISABLE_CLANG(
"-Wmissing-field-initializers")
104 struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer.data(), uint32_t(buffer.size()));
106 spa_audio_info_raw audioInfo = asSpaAudioInfoRaw(m_format);
108 std::array<
const struct spa_pod *, 1> params{
109 spa_format_audio_raw_build(&b, SPA_PARAM_EnumFormat, &audioInfo),
112 return pw_stream_connect(
113 m_stream.get(), direction, targetNodeId->value,
114 pw_stream_flags(PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_MAP_BUFFERS
115 | PW_STREAM_FLAG_RT_PROCESS | PW_STREAM_FLAG_DONT_RECONNECT),
116 params.data(), params.size());
static QAudioDeviceMonitor & deviceMonitor()