mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-25 13:48:42 -05:00
Fix endian issue with some Mac OS X sound devices
Audio loop back devices on Mac OS X Intel strangely have a big endian sample format, perhaps a hang over from PowerPC days. This change ensures that samples are converted to the machine endianness before processing. Also re-enabled is the input audio format validation which now seems to work. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7614 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
39cf3e1b9a
commit
72c8eccf96
15
soundin.cpp
15
soundin.cpp
@ -3,6 +3,7 @@
|
||||
#include <QAudioDeviceInfo>
|
||||
#include <QAudioFormat>
|
||||
#include <QAudioInput>
|
||||
#include <QSysInfo>
|
||||
#include <QDebug>
|
||||
|
||||
#include "moc_soundin.cpp"
|
||||
@ -49,11 +50,13 @@ 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 ())
|
||||
{
|
||||
@ -61,12 +64,12 @@ void SoundInput::start(QAudioDeviceInfo const& device, int framesPerBuffer, Audi
|
||||
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;
|
||||
}
|
||||
|
||||
m_stream.reset (new QAudioInput {device, format});
|
||||
if (audioError ())
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <QDateTime>
|
||||
#include <QAudioDeviceInfo>
|
||||
#include <QAudioOutput>
|
||||
#include <QSysInfo>
|
||||
#include <qmath.h>
|
||||
#include <QDebug>
|
||||
|
||||
@ -59,6 +60,7 @@ void SoundOutput::setFormat (QAudioDeviceInfo const& device, unsigned channels,
|
||||
format.setSampleRate (48000);
|
||||
format.setSampleType (QAudioFormat::SignedInt);
|
||||
format.setSampleSize (16);
|
||||
format.setByteOrder (QAudioFormat::Endian (QSysInfo::ByteOrder));
|
||||
if (!format.isValid ())
|
||||
{
|
||||
Q_EMIT error (tr ("Requested output audio format is not valid."));
|
||||
|
Loading…
Reference in New Issue
Block a user