mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-15 16:42:12 -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 <QAudioDeviceInfo>
|
||||||
#include <QAudioFormat>
|
#include <QAudioFormat>
|
||||||
#include <QAudioInput>
|
#include <QAudioInput>
|
||||||
|
#include <QSysInfo>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "moc_soundin.cpp"
|
#include "moc_soundin.cpp"
|
||||||
@ -49,11 +50,13 @@ void SoundInput::start(QAudioDeviceInfo const& device, int framesPerBuffer, Audi
|
|||||||
m_sink = sink;
|
m_sink = sink;
|
||||||
|
|
||||||
QAudioFormat format (device.preferredFormat());
|
QAudioFormat format (device.preferredFormat());
|
||||||
|
qDebug () << "Preferred audio input format:" << format;
|
||||||
format.setChannelCount (AudioDevice::Mono == channel ? 1 : 2);
|
format.setChannelCount (AudioDevice::Mono == channel ? 1 : 2);
|
||||||
format.setCodec ("audio/pcm");
|
format.setCodec ("audio/pcm");
|
||||||
format.setSampleRate (12000 * downSampleFactor);
|
format.setSampleRate (12000 * downSampleFactor);
|
||||||
format.setSampleType (QAudioFormat::SignedInt);
|
format.setSampleType (QAudioFormat::SignedInt);
|
||||||
format.setSampleSize (16);
|
format.setSampleSize (16);
|
||||||
|
format.setByteOrder (QAudioFormat::Endian (QSysInfo::ByteOrder));
|
||||||
|
|
||||||
if (!format.isValid ())
|
if (!format.isValid ())
|
||||||
{
|
{
|
||||||
@ -61,12 +64,12 @@ void SoundInput::start(QAudioDeviceInfo const& device, int framesPerBuffer, Audi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this function lies!
|
if (!device.isFormatSupported (format))
|
||||||
// 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."));
|
Q_EMIT error (tr ("Requested input audio format is not supported on device."));
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
m_stream.reset (new QAudioInput {device, format});
|
m_stream.reset (new QAudioInput {device, format});
|
||||||
if (audioError ())
|
if (audioError ())
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QAudioDeviceInfo>
|
#include <QAudioDeviceInfo>
|
||||||
#include <QAudioOutput>
|
#include <QAudioOutput>
|
||||||
|
#include <QSysInfo>
|
||||||
#include <qmath.h>
|
#include <qmath.h>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
@ -59,6 +60,7 @@ void SoundOutput::setFormat (QAudioDeviceInfo const& device, unsigned channels,
|
|||||||
format.setSampleRate (48000);
|
format.setSampleRate (48000);
|
||||||
format.setSampleType (QAudioFormat::SignedInt);
|
format.setSampleType (QAudioFormat::SignedInt);
|
||||||
format.setSampleSize (16);
|
format.setSampleSize (16);
|
||||||
|
format.setByteOrder (QAudioFormat::Endian (QSysInfo::ByteOrder));
|
||||||
if (!format.isValid ())
|
if (!format.isValid ())
|
||||||
{
|
{
|
||||||
Q_EMIT error (tr ("Requested output audio format is not valid."));
|
Q_EMIT error (tr ("Requested output audio format is not valid."));
|
||||||
|
Loading…
Reference in New Issue
Block a user