exporter: wait for conforms/indexes when exporting audio
The audio rendering system uses an event-based mechanism where if audio needs to be converted (i.e. to a different sample rate), it will create a conform task and re-render that section again when the audio is ready. Unfortunately, the export code didn't respect this and would start encoding audio once the initial queue was done. This usually resulted in silent audio, but could also result in "uninitialized" audio that would crash any float-based encoders (e.g. AAC). Now we use a different signal that only emits once the queue is done AND all conforms are done.
This commit is contained in:
@@ -12,6 +12,7 @@ AudioRenderBackend::AudioRenderBackend(QObject *parent) :
|
||||
ic_from_conform_(false)
|
||||
{
|
||||
connect(IndexManager::instance(), &IndexManager::StreamConformAppended, this, &AudioRenderBackend::ConformUpdated);
|
||||
connect(this, &AudioRenderBackend::QueueComplete, this, &AudioRenderBackend::FilterQueueCompleteSignal);
|
||||
}
|
||||
|
||||
void AudioRenderBackend::SetParameters(const AudioRenderingParams ¶ms)
|
||||
@@ -205,6 +206,13 @@ void AudioRenderBackend::TruncateCache(const rational &r)
|
||||
}
|
||||
}
|
||||
|
||||
void AudioRenderBackend::FilterQueueCompleteSignal()
|
||||
{
|
||||
if (conform_wait_info_.isEmpty()) {
|
||||
emit AudioComplete();
|
||||
}
|
||||
}
|
||||
|
||||
bool AudioRenderBackend::ConformWaitInfo::operator==(const AudioRenderBackend::ConformWaitInfo &rhs) const
|
||||
{
|
||||
return rhs.params == params
|
||||
|
||||
@@ -27,6 +27,8 @@ public:
|
||||
signals:
|
||||
void ParamsChanged();
|
||||
|
||||
void AudioComplete();
|
||||
|
||||
protected:
|
||||
virtual void ConnectViewer(ViewerOutput* node) override;
|
||||
|
||||
@@ -76,6 +78,8 @@ private slots:
|
||||
|
||||
void TruncateCache(const rational& r);
|
||||
|
||||
void FilterQueueCompleteSignal();
|
||||
|
||||
};
|
||||
|
||||
#endif // AUDIORENDERBACKEND_H
|
||||
|
||||
@@ -245,7 +245,7 @@ void Exporter::EncoderOpenedSuccessfully()
|
||||
|
||||
if (!audio_done_) {
|
||||
// We set the audio backend to render the full sequence to the disk
|
||||
connect(audio_backend_, &AudioRenderBackend::QueueComplete, this, &Exporter::AudioRendered);
|
||||
connect(audio_backend_, &AudioRenderBackend::AudioComplete, this, &Exporter::AudioRendered);
|
||||
|
||||
audio_backend_->InvalidateCache(TimeRange(0, viewer_node_->Length()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user