decoder: signal indexing progress

Better UI interactions, actually shows the progress of the index function in
the task manager now.
This commit is contained in:
itsmattkc
2020-02-19 12:19:42 +11:00
parent 03bdf01357
commit 53551246da
4 changed files with 21 additions and 0 deletions
+7
View File
@@ -180,3 +180,10 @@ void Decoder::Conform(const AudioRenderingParams &params, const QAtomicInt* canc
void Decoder::Index(const QAtomicInt *cancelled) void Decoder::Index(const QAtomicInt *cancelled)
{ {
} }
void Decoder::SignalIndexProgress(const int64_t &ts)
{
if (stream()->duration() != AV_NOPTS_VALUE && stream()->duration() != 0) {
emit IndexProgress(qRound(100.0 * static_cast<double>(ts) / static_cast<double>(stream()->duration())));
}
}
+8
View File
@@ -234,7 +234,15 @@ public:
*/ */
virtual void Index(const QAtomicInt* cancelled); virtual void Index(const QAtomicInt* cancelled);
signals:
/**
* @brief While indexing, this signal will provide progress as a percentage (0-100 inclusive) if available
*/
void IndexProgress(int);
protected: protected:
void SignalIndexProgress(const int64_t& ts);
bool open_; bool open_;
private: private:
+4
View File
@@ -868,6 +868,8 @@ void FFmpegDecoder::UnconditionalAudioIndex(AVPacket *pkt, AVFrame *frame, const
if (data_frame != frame) { if (data_frame != frame) {
av_frame_free(&data_frame); av_frame_free(&data_frame);
} }
SignalIndexProgress(frame->pts);
} }
} }
@@ -917,6 +919,8 @@ void FFmpegDecoder::UnconditionalVideoIndex(AVPacket* pkt, AVFrame* frame, const
//CacheFrameToDisk(frame); //CacheFrameToDisk(frame);
video_stream->append_frame_index(frame->pts); video_stream->append_frame_index(frame->pts);
SignalIndexProgress(frame->pts);
} else { } else {
// Assume we've reached the end of the file // Assume we've reached the end of the file
break; break;
+2
View File
@@ -17,6 +17,8 @@ void IndexTask::Action()
decoder->set_stream(stream_); decoder->set_stream(stream_);
connect(decoder.get(), &Decoder::IndexProgress, this, &IndexTask::ProgressChanged);
decoder->Open(); decoder->Open();
decoder->Index(&IsCancelled()); decoder->Index(&IsCancelled());
decoder->Close(); decoder->Close();