renderer/decoder: clean up decoders after some time
This commit is contained in:
@@ -46,12 +46,15 @@ const rational Decoder::kAnyTimecode = RATIONAL_MIN;
|
||||
|
||||
Decoder::Decoder()
|
||||
{
|
||||
UpdateLastAccessed();
|
||||
}
|
||||
|
||||
bool Decoder::Open(const CodecStream &stream)
|
||||
{
|
||||
QMutexLocker locker(&mutex_);
|
||||
|
||||
UpdateLastAccessed();
|
||||
|
||||
if (stream_.IsValid()) {
|
||||
// Decoder is already open. Return TRUE if the stream is the stream we have, or FALSE if not.
|
||||
if (stream_ == stream) {
|
||||
@@ -94,6 +97,8 @@ FramePtr Decoder::RetrieveVideo(const rational &timecode, const int ÷r)
|
||||
{
|
||||
QMutexLocker locker(&mutex_);
|
||||
|
||||
UpdateLastAccessed();
|
||||
|
||||
if (!stream_.IsValid()) {
|
||||
qCritical() << "Can't retrieve video on a closed decoder";
|
||||
return nullptr;
|
||||
@@ -111,6 +116,8 @@ SampleBufferPtr Decoder::RetrieveAudio(const TimeRange &range, const AudioParams
|
||||
{
|
||||
QMutexLocker locker(&mutex_);
|
||||
|
||||
UpdateLastAccessed();
|
||||
|
||||
if (!stream_.IsValid()) {
|
||||
qCritical() << "Can't retrieve audio on a closed decoder";
|
||||
return nullptr;
|
||||
@@ -167,10 +174,18 @@ SampleBufferPtr Decoder::RetrieveAudio(const TimeRange &range, const AudioParams
|
||||
return buffer;
|
||||
}
|
||||
|
||||
qint64 Decoder::GetLastAccessedTime()
|
||||
{
|
||||
QMutexLocker locker(&mutex_);
|
||||
return last_accessed_;
|
||||
}
|
||||
|
||||
void Decoder::Close()
|
||||
{
|
||||
QMutexLocker locker(&mutex_);
|
||||
|
||||
UpdateLastAccessed();
|
||||
|
||||
if (stream_.IsValid()) {
|
||||
CloseInternal();
|
||||
stream_.Reset();
|
||||
@@ -355,6 +370,11 @@ SampleBufferPtr Decoder::RetrieveAudioFromConform(const QString &conform_filenam
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Decoder::UpdateLastAccessed()
|
||||
{
|
||||
last_accessed_ = QDateTime::currentMSecsSinceEpoch();
|
||||
}
|
||||
|
||||
uint qHash(Decoder::CodecStream stream, uint seed)
|
||||
{
|
||||
return qHash(stream.filename(), seed) ^ qHash(stream.stream(), seed);
|
||||
|
||||
Reference in New Issue
Block a user