use ffmpeg for sample packing

FFmpeg has a much more optimized algorithm than we do so may as well use it.
This commit is contained in:
itsmattkc
2021-09-25 13:22:13 -07:00
parent 4c9863a696
commit 845b4a7559
9 changed files with 191 additions and 29 deletions
+8 -3
View File
@@ -434,9 +434,13 @@ void ViewerWidget::ReceivedAudioBufferForPlayback()
if (watcher->HasResult()) {
SampleBufferPtr samples = watcher->Get().value<SampleBufferPtr>();
if (samples && audio_playback_device_) {
qint64 t = QDateTime::currentMSecsSinceEpoch();
QByteArray pack = samples->toPackedData();
qDebug() << "Packing took:" << (QDateTime::currentMSecsSinceEpoch() - t);
if (!packed_processor_.IsOpen()) {
packed_processor_.Open(samples->audio_params());
}
// Convert to packed data for audio output
QByteArray pack = packed_processor_.Convert(samples);
audio_playback_device_->Push(pack);
if (prequeuing_audio_) {
@@ -627,6 +631,7 @@ void ViewerWidget::PauseInternal()
audio_playback_device_.reset(nullptr);
qDeleteAll(audio_playback_queue_);
audio_playback_queue_.clear();
packed_processor_.Close();
UpdateTextureFromNode();
}