mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-19 03:45:30 +08:00
AFV initial commit
This commit is contained in:
committed by
Mat Sutcliffe
parent
7030302e73
commit
b5a2f2ad13
36
src/blacksound/sampleprovider/mixingsampleprovider.cpp
Normal file
36
src/blacksound/sampleprovider/mixingsampleprovider.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "mixingsampleprovider.h"
|
||||
|
||||
int MixingSampleProvider::readSamples(QVector<qint16> &samples, qint64 count)
|
||||
{
|
||||
samples.clear();
|
||||
samples.fill(0, count);
|
||||
int outputLen = 0;
|
||||
|
||||
QVector<ISampleProvider*> finishedProviders;
|
||||
for (int i = 0; i < m_sources.size(); i++)
|
||||
{
|
||||
ISampleProvider *sampleProvider = m_sources.at(i);
|
||||
QVector<qint16> sourceBuffer;
|
||||
int len = sampleProvider->readSamples(sourceBuffer, count);
|
||||
|
||||
for (int n = 0; n < len; n++)
|
||||
{
|
||||
samples[n] += sourceBuffer[n];
|
||||
}
|
||||
|
||||
outputLen = qMax(len, outputLen);
|
||||
|
||||
if (sampleProvider->isFinished())
|
||||
{
|
||||
finishedProviders.push_back(sampleProvider);
|
||||
}
|
||||
}
|
||||
|
||||
for (ISampleProvider *sampleProvider : finishedProviders)
|
||||
{
|
||||
sampleProvider->deleteLater();
|
||||
m_sources.removeAll(sampleProvider);
|
||||
}
|
||||
|
||||
return outputLen;
|
||||
}
|
||||
Reference in New Issue
Block a user