From bb63b6968c2050694bf78bb759ae3d67f8d05eed Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Mon, 10 Oct 2022 18:54:10 -0700 Subject: [PATCH] decoder: use atomic int instead of mutex for access time Prevents main thread from getting hung up if the decoder is doing something slow --- app/codec/decoder.cpp | 12 ------------ app/codec/decoder.h | 2 +- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/app/codec/decoder.cpp b/app/codec/decoder.cpp index 3e6998f88..434376c06 100644 --- a/app/codec/decoder.cpp +++ b/app/codec/decoder.cpp @@ -45,7 +45,6 @@ Decoder::Decoder() : void Decoder::IncrementAccessTime(qint64 t) { - QMutexLocker locker(&mutex_); last_accessed_ += t; } @@ -156,7 +155,6 @@ Decoder::RetrieveAudioStatus Decoder::RetrieveAudio(SampleBuffer &dest, const Ti qint64 Decoder::GetLastAccessedTime() { - QMutexLocker locker(&mutex_); return last_accessed_; } @@ -215,16 +213,6 @@ DecoderPtr Decoder::CreateFromID(const QString &id) return nullptr; } -int64_t Decoder::GetTimeInTimebaseUnits(const rational &time, const rational &timebase, int64_t start_time) -{ - return Timecode::time_to_timestamp(time, timebase); -} - -rational Decoder::GetTimestampInTimeUnits(int64_t time, const rational &timebase, int64_t start_time) -{ - return Timecode::timestamp_to_time(time, timebase); -} - void Decoder::SignalProcessingProgress(int64_t ts, int64_t duration) { if (duration != AV_NOPTS_VALUE && duration != 0) { diff --git a/app/codec/decoder.h b/app/codec/decoder.h index c6aac3ecb..757b48080 100644 --- a/app/codec/decoder.h +++ b/app/codec/decoder.h @@ -315,7 +315,7 @@ private: QMutex mutex_; - qint64 last_accessed_; + std::atomic_int64_t last_accessed_; TexturePtr cached_texture_; rational cached_time_;