renderer/decoder: use same background mechanism to conform audio as well
This commit is contained in:
@@ -31,7 +31,7 @@ void IndexManager::StartIndexingStream(StreamPtr stream)
|
||||
}
|
||||
|
||||
IndexTask* index_task = new IndexTask(stream);
|
||||
threads_.append({stream, index_task});
|
||||
indexing_.append({stream, index_task});
|
||||
|
||||
connect(stream.get(), &Stream::IndexChanged, this, &IndexManager::StreamIndexUpdatedEvent, Qt::QueuedConnection);
|
||||
connect(index_task, &IndexTask::Succeeded, this, &IndexManager::IndexTaskFinished, Qt::QueuedConnection);
|
||||
@@ -39,9 +39,24 @@ void IndexManager::StartIndexingStream(StreamPtr stream)
|
||||
TaskManager::instance()->AddTask(index_task);
|
||||
}
|
||||
|
||||
bool IndexManager::IsIndexing(StreamPtr stream)
|
||||
void IndexManager::StartConformingStream(AudioStreamPtr stream, const AudioRenderingParams ¶ms)
|
||||
{
|
||||
foreach (const StreamThreadPair& stp, threads_) {
|
||||
if (IsConforming(stream, params)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ConformTask* conform_task = new ConformTask(stream, params);
|
||||
conforming_.append({stream, params, conform_task});
|
||||
|
||||
connect(stream.get(), &AudioStream::ConformAppended, this, &IndexManager::StreamConformAppendedEvent, Qt::QueuedConnection);
|
||||
connect(conform_task, &ConformTask::Succeeded, this, &IndexManager::IndexTaskFinished, Qt::QueuedConnection);
|
||||
|
||||
TaskManager::instance()->AddTask(conform_task);
|
||||
}
|
||||
|
||||
bool IndexManager::IsIndexing(StreamPtr stream) const
|
||||
{
|
||||
foreach (const IndexPair& stp, indexing_) {
|
||||
if (stp.stream == stream) {
|
||||
return true;
|
||||
}
|
||||
@@ -50,14 +65,25 @@ bool IndexManager::IsIndexing(StreamPtr stream)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IndexManager::IsConforming(AudioStreamPtr stream, const AudioRenderingParams ¶ms) const
|
||||
{
|
||||
foreach (const ConformPair& cfp, conforming_) {
|
||||
if (cfp.stream == stream && cfp.params == params) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void IndexManager::IndexTaskFinished()
|
||||
{
|
||||
for (int i=0;i<threads_.size();i++) {
|
||||
const StreamThreadPair& stp = threads_.at(i);
|
||||
for (int i=0;i<indexing_.size();i++) {
|
||||
const IndexPair& stp = indexing_.at(i);
|
||||
|
||||
if (stp.task == sender()) {
|
||||
//emit StreamIndexUpdated(stp.stream.get());
|
||||
threads_.removeAt(i);
|
||||
indexing_.removeAt(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -67,3 +93,9 @@ void IndexManager::StreamIndexUpdatedEvent()
|
||||
{
|
||||
emit StreamIndexUpdated(static_cast<Stream*>(sender()));
|
||||
}
|
||||
|
||||
void IndexManager::StreamConformAppendedEvent(const AudioRenderingParams ¶ms)
|
||||
{
|
||||
qDebug() << "Got stream conform appended event";
|
||||
emit StreamConformAppended(static_cast<Stream*>(sender()), params);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user