Trying a fixed audio input buffer size

This commit is contained in:
Bill Somerville 2020-08-10 11:01:38 +01:00
parent 1892f39df3
commit ecde374cee
No known key found for this signature in database
GPG Key ID: D864B06D1E81618F
2 changed files with 9 additions and 5 deletions

View File

@ -81,11 +81,13 @@ void SoundInput::start(QAudioDeviceInfo const& device, int framesPerBuffer, Audi
qDebug () << "SoundIn default buffer size (bytes):" << m_stream->bufferSize ();
m_stream->setBufferSize (m_stream->format ().bytesForFrames (framesPerBuffer));
m_stream->setBufferSize (m_stream->format ().bytesForFrames (3456 * 4 * 5));
qDebug () << "SoundIn selected buffer size (bytes):" << m_stream->bufferSize ();
if (sink->initialize (QIODevice::WriteOnly, channel))
{
m_stream->start (sink);
audioError ();
cummulative_lost_usec_ = -1;
}
else
{
@ -159,7 +161,9 @@ void SoundInput::reset (bool report_dropped_frames)
{
if (m_stream)
{
if (report_dropped_frames)
if (cummulative_lost_usec_ >= 0 // don't report first time as we
// don't yet known latency
&& report_dropped_frames)
{
auto lost_usec = m_stream->elapsedUSecs () - m_stream->processedUSecs () - cummulative_lost_usec_;
Q_EMIT dropped_frames (m_stream->format ().framesForDuration (lost_usec), lost_usec);

View File

@ -56,6 +56,7 @@ void Detector::clear ()
qint64 Detector::writeData (char const * data, qint64 maxSize)
{
qDebug () << "Detector::writeData: size:" << maxSize;
static unsigned mstr0=999999;
qint64 ms0 = QDateTime::currentMSecsSinceEpoch() % 86400000;
unsigned mstr = ms0 % int(1000.0*m_period); // ms into the nominal Tx start time
@ -119,8 +120,7 @@ qint64 Detector::writeData (char const * data, qint64 maxSize)
remaining -= numFramesProcessed;
}
return maxSize; // we drop any data past the end of the buffer on
// the floor until the next period starts
// we drop any data past the end of the buffer on the floor until
// the next period starts
return maxSize;
}