diff options
Diffstat (limited to 'soundin.cpp')
| -rw-r--r-- | soundin.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/soundin.cpp b/soundin.cpp index a93fb49d..3da3bdd0 100644 --- a/soundin.cpp +++ b/soundin.cpp @@ -3,6 +3,7 @@ #include <QAudioDeviceInfo> #include <QAudioFormat> #include <QAudioInput> +#include <QSysInfo> #include <QDebug> #include "moc_soundin.cpp" @@ -49,24 +50,26 @@ void SoundInput::start(QAudioDeviceInfo const& device, int framesPerBuffer, Audi m_sink = sink; QAudioFormat format (device.preferredFormat()); +// qDebug () << "Preferred audio input format:" << format; format.setChannelCount (AudioDevice::Mono == channel ? 1 : 2); format.setCodec ("audio/pcm"); format.setSampleRate (12000 * downSampleFactor); format.setSampleType (QAudioFormat::SignedInt); format.setSampleSize (16); - + format.setByteOrder (QAudioFormat::Endian (QSysInfo::ByteOrder)); if (!format.isValid ()) { Q_EMIT error (tr ("Requested input audio format is not valid.")); return; } - // this function lies! - // if (!device.isFormatSupported (format)) - // { - // Q_EMIT error (tr ("Requested input audio format is not supported on device.")); - // return; - // } + if (!device.isFormatSupported (format)) + { +// qDebug () << "Nearest supported audio format:" << device.nearestFormat (format); + Q_EMIT error (tr ("Requested input audio format is not supported on device.")); + return; + } +// qDebug () << "Selected audio input format:" << format; m_stream.reset (new QAudioInput {device, format}); if (audioError ()) @@ -99,6 +102,7 @@ void SoundInput::suspend () void SoundInput::resume () { +// qDebug() << "Resume" << fmod(0.001*QDateTime::currentMSecsSinceEpoch(),6.0); if (m_sink) { m_sink->reset (); |
