kopia lustrzana https://github.com/f4exb/sdrangel
Multiple audio support: removed useless start/stop immediate methods from AudioOutput
rodzic
90843df58d
commit
937bc19375
|
@ -37,7 +37,7 @@ AudioOutput::~AudioOutput()
|
|||
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
|
||||
for (AudioFifos::iterator it = m_audioFifos.begin(); it != m_audioFifos.end(); ++it)
|
||||
for (std::list<AudioFifo*>::iterator it = m_audioFifos.begin(); it != m_audioFifos.end(); ++it)
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
|
@ -116,77 +116,6 @@ bool AudioOutput::start(int device, int rate)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool AudioOutput::startImmediate(int device, int rate)
|
||||
{
|
||||
if (QIODevice::isOpen())
|
||||
{
|
||||
qInfo("AudioOutput::startImmediate: already open");
|
||||
return true;
|
||||
}
|
||||
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
QAudioDeviceInfo devInfo;
|
||||
|
||||
if (device < 0)
|
||||
{
|
||||
devInfo = QAudioDeviceInfo::defaultOutputDevice();
|
||||
qWarning("AudioOutput::startImmediate: using default device %s", qPrintable(devInfo.defaultOutputDevice().deviceName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
QList<QAudioDeviceInfo> devicesInfo = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
||||
|
||||
if (device < devicesInfo.size())
|
||||
{
|
||||
devInfo = devicesInfo[device];
|
||||
qWarning("AudioOutput::startImmediate: using audio device #%d: %s", device, qPrintable(devInfo.defaultOutputDevice().deviceName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
devInfo = QAudioDeviceInfo::defaultOutputDevice();
|
||||
qWarning("AudioOutput::startImmediate: audio device #%d does not exist. Using default device %s", device, qPrintable(devInfo.defaultOutputDevice().deviceName()));
|
||||
}
|
||||
}
|
||||
|
||||
//QAudioDeviceInfo devInfo(QAudioDeviceInfo::defaultOutputDevice());
|
||||
|
||||
m_audioFormat.setSampleRate(rate);
|
||||
m_audioFormat.setChannelCount(2);
|
||||
m_audioFormat.setSampleSize(16);
|
||||
m_audioFormat.setCodec("audio/pcm");
|
||||
m_audioFormat.setByteOrder(QAudioFormat::LittleEndian);
|
||||
m_audioFormat.setSampleType(QAudioFormat::SignedInt);
|
||||
|
||||
if (!devInfo.isFormatSupported(m_audioFormat))
|
||||
{
|
||||
m_audioFormat = devInfo.nearestFormat(m_audioFormat);
|
||||
qWarning("AudioOutput::startImmediate: %d Hz S16_LE audio format not supported. New rate: %d", rate, m_audioFormat.sampleRate());
|
||||
}
|
||||
else
|
||||
{
|
||||
qInfo("AudioOutput::startImmediate: audio format OK");
|
||||
}
|
||||
|
||||
if (m_audioFormat.sampleSize() != 16)
|
||||
{
|
||||
qWarning("AudioOutput::startImmediate: Audio device ( %s ) failed", qPrintable(devInfo.defaultOutputDevice().deviceName()));
|
||||
return false;
|
||||
}
|
||||
|
||||
m_audioOutput = new QAudioOutput(devInfo, m_audioFormat);
|
||||
|
||||
QIODevice::open(QIODevice::ReadOnly);
|
||||
|
||||
m_audioOutput->start(this);
|
||||
|
||||
if (m_audioOutput->state() != QAudio::ActiveState)
|
||||
{
|
||||
qWarning("AudioOutput::startImmediate: cannot start");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AudioOutput::stop()
|
||||
{
|
||||
qDebug("AudioOutput::stop");
|
||||
|
@ -207,21 +136,6 @@ void AudioOutput::stop()
|
|||
}
|
||||
}
|
||||
|
||||
void AudioOutput::stopImmediate()
|
||||
{
|
||||
if (!QIODevice::isOpen())
|
||||
{
|
||||
qInfo("AudioOutput::stopImmediate");
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("AudioOutput::stopImmediate");
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
QIODevice::close();
|
||||
delete m_audioOutput;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioOutput::addFifo(AudioFifo* audioFifo)
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
|
@ -274,7 +188,7 @@ qint64 AudioOutput::readData(char* data, qint64 maxLen)
|
|||
|
||||
// sum up a block from all fifos
|
||||
|
||||
for (AudioFifos::iterator it = m_audioFifos.begin(); it != m_audioFifos.end(); ++it)
|
||||
for (std::list<AudioFifo*>::iterator it = m_audioFifos.begin(); it != m_audioFifos.end(); ++it)
|
||||
{
|
||||
// use outputBuffer as temp - yes, one memcpy could be saved
|
||||
uint samples = (*it)->read((quint8*) data, framesPerBuffer, 1);
|
||||
|
|
|
@ -37,9 +37,6 @@ public:
|
|||
bool start(int device, int rate);
|
||||
void stop();
|
||||
|
||||
bool startImmediate(int device, int rate);
|
||||
void stopImmediate();
|
||||
|
||||
void addFifo(AudioFifo* audioFifo);
|
||||
void removeFifo(AudioFifo* audioFifo);
|
||||
|
||||
|
@ -52,8 +49,7 @@ private:
|
|||
uint m_audioUsageCount;
|
||||
bool m_onExit;
|
||||
|
||||
typedef std::list<AudioFifo*> AudioFifos;
|
||||
AudioFifos m_audioFifos;
|
||||
std::list<AudioFifo*> m_audioFifos;
|
||||
std::vector<qint32> m_mixBuffer;
|
||||
|
||||
QAudioFormat m_audioFormat;
|
||||
|
|
Ładowanie…
Reference in New Issue