Audio format issue with Qt 6.8.2, all worked well with 6.6.3
Unsolved
Qt 6
-
Hi, why does the following code now gives me with Qt 6.8.2 the error message "Requested output audio format is not supported on device."? All was working well up to and including Qt 6.6.3. Was has been changed and why?
void SoundOutput::setFormat (QAudioDevice const& device, unsigned channels, int frames_buffered) { Q_ASSERT (0 < channels && channels < 3); m_device = device; m_channels = channels; m_framesBuffered = frames_buffered; } void SoundOutput::restart (QIODevice * source) { if (!m_device.isNull ()) { QAudioFormat format (m_device.preferredFormat ()); format.setChannelCount (m_channels); format.setSampleRate (48000); format.setSampleFormat (QAudioFormat::Int16); if (!format.isValid ()) { Q_EMIT error (tr ("Requested output audio format is not valid.")); } else if (!m_device.isFormatSupported (format)) { Q_EMIT error (tr ("Requested output audio format is not supported on device.")); } else { m_stream.reset (new QAudioSink (m_device, format)); qDebug () << "SoundOutput::restart Selected audio output format:" << m_stream -> format(); checkStream (); m_stream->setVolume (m_volume); // m_stream->setNotifyInterval(1000); error_ = false; connect (m_stream.data(), &QAudioSink::stateChanged, this, &SoundOutput::handleStateChanged); // connect (m_stream.data(), &QAudioSink::notify, [this] () {checkStream ();}); // qDebug() << "A" << m_volume << m_stream->notifyInterval(); } }