renderer/decoder: use same background mechanism to conform audio as well
This commit is contained in:
@@ -49,6 +49,8 @@ void AudioBackend::DecompileInternal()
|
||||
|
||||
void AudioBackend::ConnectWorkerToThis(RenderWorker *worker)
|
||||
{
|
||||
AudioRenderBackend::ConnectWorkerToThis(worker);
|
||||
|
||||
connect(worker, &RenderWorker::CompletedCache, this, &AudioBackend::ThreadCompletedCache);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,12 @@
|
||||
|
||||
#include "audiorenderworker.h"
|
||||
#include "common/filefunctions.h"
|
||||
#include "render/indexmanager.h"
|
||||
|
||||
AudioRenderBackend::AudioRenderBackend(QObject *parent) :
|
||||
RenderBackend(parent)
|
||||
{
|
||||
connect(IndexManager::instance(), &IndexManager::StreamConformAppended, this, &AudioRenderBackend::ConformUpdated);
|
||||
}
|
||||
|
||||
void AudioRenderBackend::SetParameters(const AudioRenderingParams ¶ms)
|
||||
@@ -74,3 +76,66 @@ bool AudioRenderBackend::CanRender()
|
||||
{
|
||||
return params_.is_valid();
|
||||
}
|
||||
|
||||
void AudioRenderBackend::ConnectWorkerToThis(RenderWorker *worker)
|
||||
{
|
||||
AudioRenderWorker* arw = static_cast<AudioRenderWorker*>(worker);
|
||||
|
||||
connect(arw, &AudioRenderWorker::ConformUnavailable, this, &AudioRenderBackend::ConformUnavailable, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void AudioRenderBackend::ConformUnavailable(StreamPtr stream, const TimeRange &range, const rational &stream_time, const AudioRenderingParams& params)
|
||||
{
|
||||
ConformWaitInfo info = {stream, params, range, stream_time};
|
||||
|
||||
if (conform_wait_info_.contains(info)) {
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "Waiting for conformed" << stream.get() << "time" << stream_time.toDouble() << "for frame" << range.in();
|
||||
|
||||
AudioStreamPtr audio_stream = std::static_pointer_cast<AudioStream>(stream);
|
||||
|
||||
if (IndexManager::instance()->IsConforming(audio_stream, params)) {
|
||||
|
||||
conform_wait_info_.append(info);
|
||||
|
||||
} else if (audio_stream->has_conformed_version(params)) {
|
||||
|
||||
// Index JUST finished, requeue this time
|
||||
InvalidateCache(range);
|
||||
|
||||
} else {
|
||||
|
||||
// Start indexing process
|
||||
conform_wait_info_.append(info);
|
||||
IndexManager::instance()->StartConformingStream(audio_stream, params);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void AudioRenderBackend::ConformUpdated(Stream *stream, const AudioRenderingParams ¶ms)
|
||||
{
|
||||
qDebug() << "Got conform updated in ARB";
|
||||
|
||||
for (int i=0;i<conform_wait_info_.size();i++) {
|
||||
const ConformWaitInfo& info = conform_wait_info_.at(i);
|
||||
|
||||
if (info.stream.get() == stream
|
||||
&& info.params == params) {
|
||||
|
||||
InvalidateCache(info.affected_range);
|
||||
conform_wait_info_.removeAt(i);
|
||||
i--;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool AudioRenderBackend::ConformWaitInfo::operator==(const AudioRenderBackend::ConformWaitInfo &rhs) const
|
||||
{
|
||||
return rhs.params == params
|
||||
&& rhs.stream == stream
|
||||
&& rhs.stream_time == stream_time
|
||||
&& rhs.affected_range == affected_range;
|
||||
}
|
||||
|
||||
@@ -38,9 +38,27 @@ protected:
|
||||
|
||||
virtual bool CanRender() override;
|
||||
|
||||
virtual void ConnectWorkerToThis(RenderWorker* worker) override;
|
||||
|
||||
private:
|
||||
struct ConformWaitInfo {
|
||||
StreamPtr stream;
|
||||
AudioRenderingParams params;
|
||||
TimeRange affected_range;
|
||||
rational stream_time;
|
||||
|
||||
bool operator==(const ConformWaitInfo& rhs) const;
|
||||
};
|
||||
|
||||
QList<ConformWaitInfo> conform_wait_info_;
|
||||
|
||||
AudioRenderingParams params_;
|
||||
|
||||
private slots:
|
||||
void ConformUnavailable(StreamPtr stream, const TimeRange& range, const rational& stream_time, const AudioRenderingParams ¶ms);
|
||||
|
||||
void ConformUpdated(Stream *stream, const AudioRenderingParams& params);
|
||||
|
||||
};
|
||||
|
||||
#endif // AUDIORENDERBACKEND_H
|
||||
|
||||
@@ -25,7 +25,12 @@ void AudioRenderWorker::CloseInternal()
|
||||
|
||||
FramePtr AudioRenderWorker::RetrieveFromDecoder(DecoderPtr decoder, const TimeRange &range)
|
||||
{
|
||||
return decoder->RetrieveAudio(range.in(), range.out() - range.in(), audio_params_);
|
||||
if (decoder->HasConformedVersion(audio_params_)) {
|
||||
return decoder->RetrieveAudio(range.in(), range.out() - range.in(), audio_params_);
|
||||
} else {
|
||||
emit ConformUnavailable(decoder->stream(), CurrentPath().range(), range.out(), audio_params_);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
NodeValueTable AudioRenderWorker::RenderBlock(const TrackOutput *track, const TimeRange &range)
|
||||
|
||||
@@ -11,6 +11,9 @@ public:
|
||||
|
||||
void SetParameters(const AudioRenderingParams& audio_params);
|
||||
|
||||
signals:
|
||||
void ConformUnavailable(StreamPtr stream, const TimeRange& range, const rational& stream_time, const AudioRenderingParams& params);
|
||||
|
||||
protected:
|
||||
virtual bool InitInternal() override;
|
||||
|
||||
|
||||
@@ -443,12 +443,8 @@ void RenderBackend::FootageUnavailable(StreamPtr stream, Decoder::RetrieveState
|
||||
|
||||
FootageWaitInfo info = {stream, range, stream_time};
|
||||
|
||||
foreach (const FootageWaitInfo& compare, footage_wait_info_) {
|
||||
if (info.stream == compare.stream
|
||||
&& info.stream_time == compare.stream_time
|
||||
&& info.affected_range == compare.affected_range) {
|
||||
return;
|
||||
}
|
||||
if (footage_wait_info_.contains(info)) {
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "Waiting for" << stream.get() << "time" << stream_time.toDouble() << "for frame" << range.in();
|
||||
@@ -513,3 +509,10 @@ void RenderBackend::IndexUpdated(Stream* stream)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool RenderBackend::FootageWaitInfo::operator==(const RenderBackend::FootageWaitInfo &rhs) const
|
||||
{
|
||||
return rhs.stream == stream
|
||||
&& rhs.stream_time == stream_time
|
||||
&& rhs.affected_range == affected_range;
|
||||
}
|
||||
|
||||
@@ -149,6 +149,8 @@ private:
|
||||
StreamPtr stream;
|
||||
TimeRange affected_range;
|
||||
rational stream_time;
|
||||
|
||||
bool operator==(const FootageWaitInfo& rhs) const;
|
||||
};
|
||||
|
||||
QList<FootageWaitInfo> footage_wait_info_;
|
||||
|
||||
Reference in New Issue
Block a user