20 #include <QAudioFormat> 21 #include <QAudioDeviceInfo> 22 #include <QAudioOutput> 28 m_mutex(QMutex::Recursive),
31 m_copyAudioToUdp(false),
32 m_udpChannelMode(UDPChannelLeft),
33 m_udpChannelCodec(UDPCodecL16),
59 QMutexLocker mutexLocker(&
m_mutex);
60 QAudioDeviceInfo devInfo;
64 devInfo = QAudioDeviceInfo::defaultOutputDevice();
65 qWarning(
"AudioOutput::start: using system default device %s", qPrintable(devInfo.defaultOutputDevice().deviceName()));
69 QList<QAudioDeviceInfo> devicesInfo = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
71 if (device < devicesInfo.size())
73 devInfo = devicesInfo[device];
74 qWarning(
"AudioOutput::start: using audio device #%d: %s", device, qPrintable(devInfo.deviceName()));
78 devInfo = QAudioDeviceInfo::defaultOutputDevice();
79 qWarning(
"AudioOutput::start: audio device #%d does not exist. Using system default device %s", device, qPrintable(devInfo.defaultOutputDevice().deviceName()));
95 std::ostringstream os;
100 <<
" byteOrder: " << (
m_audioFormat.byteOrder() == QAudioFormat::BigEndian ?
"BE" :
"LE")
102 qWarning(
"AudioOutput::start: format %d Hz 2xS16LE audio/pcm not supported. Using: %s", rate, os.str().c_str());
106 qInfo(
"AudioOutput::start: audio format OK");
111 qWarning(
"AudioOutput::start: Audio device '%s' failed", qPrintable(devInfo.defaultOutputDevice().deviceName()));
118 QIODevice::open(QIODevice::ReadOnly);
124 qWarning(
"AudioOutput::start: cannot start");
135 qDebug(
"AudioOutput::stop");
137 QMutexLocker mutexLocker(&
m_mutex);
162 QMutexLocker mutexLocker(&
m_mutex);
169 QMutexLocker mutexLocker(&
m_mutex);
231 unsigned int samplesPerBuffer = maxLen / 4;
233 if (samplesPerBuffer == 0)
255 unsigned int samples = (*it)->read((quint8*) data, samplesPerBuffer);
256 const qint16* src = (
const qint16*) data;
257 std::vector<qint32>::iterator dst =
m_mixBuffer.begin();
264 for (
unsigned int i = 0;
i < samples;
i++)
277 qint16* dst = (qint16*) data;
280 for (
unsigned int i = 0;
i < samplesPerBuffer;
i++)
335 return samplesPerBuffer * 4;
void setUdpChannelMode(UDPChannelMode udpChannelMode)
bool selectType(SinkType type)
QAudioFormat m_audioFormat
void setDecimation(uint32_t decimation)
int decimation(float Fin, float Fout)
QAudioOutput * m_audioOutput
std::list< AudioFifo * > m_audioFifos
AudioNetSink * m_audioNetSink
void setUdpCopyToUDP(bool copyToUDP)
bool start(int device, int rate)
virtual qint64 readData(char *data, qint64 maxLen)
std::vector< qint32 > m_mixBuffer
void setUdpDecimation(uint32_t decimation)
void addFifo(AudioFifo *audioFifo)
void setUdpChannelFormat(UDPChannelCodec udpChannelCodec, bool stereo, int sampleRate)
void setDestination(const QString &address, uint16_t port)
void removeFifo(AudioFifo *audioFifo)
virtual qint64 writeData(const char *data, qint64 len)
UDPChannelCodec m_udpChannelCodec
void setUdpDestination(const QString &address, uint16_t port)
void write(qint16 sample)
void setUdpUseRTP(bool useRTP)
UDPChannelMode m_udpChannelMode
void setParameters(Codec codec, bool stereo, int sampleRate)