moved more objects to shared ptrs
This commit is contained in:
@@ -42,12 +42,12 @@ Decoder::~Decoder()
|
||||
{
|
||||
}
|
||||
|
||||
const Stream *Decoder::stream()
|
||||
StreamPtr Decoder::stream()
|
||||
{
|
||||
return stream_;
|
||||
}
|
||||
|
||||
void Decoder::set_stream(const Stream *fs)
|
||||
void Decoder::set_stream(StreamPtr fs)
|
||||
{
|
||||
Close();
|
||||
|
||||
|
||||
@@ -80,8 +80,8 @@ public:
|
||||
|
||||
virtual QString id() = 0;
|
||||
|
||||
const Stream* stream();
|
||||
void set_stream(const Stream *fs);
|
||||
StreamPtr stream();
|
||||
void set_stream(StreamPtr fs);
|
||||
|
||||
/**
|
||||
* @brief Probe a footage file and dump metadata about it
|
||||
@@ -194,7 +194,7 @@ protected:
|
||||
bool open_;
|
||||
|
||||
private:
|
||||
const Stream* stream_;
|
||||
StreamPtr stream_;
|
||||
};
|
||||
|
||||
#endif // DECODER_H
|
||||
|
||||
@@ -346,12 +346,12 @@ bool FFmpegDecoder::Probe(Footage *f)
|
||||
|
||||
avstream_ = fmt_ctx_->streams[i];
|
||||
|
||||
Stream* str;
|
||||
StreamPtr str;
|
||||
|
||||
if (avstream_->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||
|
||||
// Create a video stream object
|
||||
VideoStream* video_stream = new VideoStream();
|
||||
VideoStreamPtr video_stream = std::make_shared<VideoStream>();
|
||||
|
||||
video_stream->set_width(avstream_->codecpar->width);
|
||||
video_stream->set_height(avstream_->codecpar->height);
|
||||
@@ -361,7 +361,7 @@ bool FFmpegDecoder::Probe(Footage *f)
|
||||
} else if (avstream_->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||
|
||||
// Create an audio stream object
|
||||
AudioStream* audio_stream = new AudioStream();
|
||||
AudioStreamPtr audio_stream = std::make_shared<AudioStream>();
|
||||
|
||||
audio_stream->set_layout(avstream_->codecpar->channel_layout);
|
||||
audio_stream->set_channels(avstream_->codecpar->channels);
|
||||
@@ -372,7 +372,7 @@ bool FFmpegDecoder::Probe(Footage *f)
|
||||
} else {
|
||||
|
||||
// This is data we can't utilize at the moment, but we make a Stream object anyway to keep parity with the file
|
||||
str = new Stream();
|
||||
str = std::make_shared<Stream>();
|
||||
|
||||
// Set the correct codec type based on FFmpeg's result
|
||||
switch (avstream_->codecpar->codec_type) {
|
||||
|
||||
@@ -50,7 +50,7 @@ void RendererProcessor::Start()
|
||||
threads_.resize(QThread::idealThreadCount());
|
||||
|
||||
for (int i=0;i<threads_.size();i++) {
|
||||
threads_[i] = new RendererThread();
|
||||
threads_[i] = std::make_shared<RendererThread>();
|
||||
threads_[i]->run();
|
||||
}
|
||||
|
||||
@@ -67,13 +67,12 @@ void RendererProcessor::Stop()
|
||||
|
||||
for (int i=0;i<threads_.size();i++) {
|
||||
threads_[i]->Cancel();
|
||||
delete threads_[i];
|
||||
}
|
||||
|
||||
threads_.clear();
|
||||
}
|
||||
|
||||
RendererThread *RendererProcessor::CurrentThread()
|
||||
RendererThread* RendererProcessor::CurrentThread()
|
||||
{
|
||||
return dynamic_cast<RendererThread*>(QThread::currentThread());
|
||||
}
|
||||
|
||||
@@ -79,10 +79,10 @@ public:
|
||||
* This function attempts a dynamic_cast on QThread::currentThread() to RendererThread, which will return nullptr if
|
||||
* the cast fails (e.g. if this function is called from the main thread rather than a RendererThread).
|
||||
*/
|
||||
static RendererThread* CurrentThread();
|
||||
static RendererThread *CurrentThread();
|
||||
|
||||
private:
|
||||
QVector<RendererThread*> threads_;
|
||||
QVector<RendererThreadPtr> threads_;
|
||||
|
||||
bool started_;
|
||||
};
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#ifndef RENDERTHREAD_H
|
||||
#define RENDERTHREAD_H
|
||||
|
||||
#include <memory>
|
||||
#include <QMutex>
|
||||
#include <QOffscreenSurface>
|
||||
#include <QOpenGLContext>
|
||||
@@ -65,4 +66,6 @@ private:
|
||||
bool cancelled_;
|
||||
};
|
||||
|
||||
using RendererThreadPtr = std::shared_ptr<RendererThread>;
|
||||
|
||||
#endif // RENDERTHREAD_H
|
||||
|
||||
@@ -47,4 +47,6 @@ private:
|
||||
int sample_rate_;
|
||||
};
|
||||
|
||||
using AudioStreamPtr = std::shared_ptr<AudioStream>;
|
||||
|
||||
#endif // AUDIOSTREAM_H
|
||||
|
||||
@@ -77,7 +77,7 @@ void Footage::set_timestamp(const QDateTime &t)
|
||||
timestamp_ = t;
|
||||
}
|
||||
|
||||
void Footage::add_stream(Stream *s)
|
||||
void Footage::add_stream(StreamPtr s)
|
||||
{
|
||||
// Add a copy of this stream to the list
|
||||
streams_.append(s);
|
||||
@@ -86,7 +86,7 @@ void Footage::add_stream(Stream *s)
|
||||
streams_.last()->set_footage(this);
|
||||
}
|
||||
|
||||
const Stream *Footage::stream(int index)
|
||||
StreamPtr Footage::stream(int index)
|
||||
{
|
||||
return streams_.at(index);
|
||||
}
|
||||
@@ -118,11 +118,6 @@ void Footage::ClearStreams()
|
||||
}
|
||||
|
||||
// Delete all streams
|
||||
for (int i=0;i<streams_.size();i++) {
|
||||
delete streams_.at(i);
|
||||
}
|
||||
|
||||
// Empty array
|
||||
streams_.clear();
|
||||
}
|
||||
|
||||
@@ -191,10 +186,10 @@ void Footage::UpdateTooltip()
|
||||
|
||||
for (int i=0;i<streams_.size();i++) {
|
||||
|
||||
Stream* s = streams_.at(i);
|
||||
StreamPtr s = streams_.at(i);
|
||||
|
||||
if (s->type() == Stream::kVideo) {
|
||||
VideoStream* vs = static_cast<VideoStream*>(s);
|
||||
VideoStreamPtr vs = std::static_pointer_cast<VideoStream>(s);
|
||||
|
||||
tip.append(
|
||||
QCoreApplication::translate("Footage",
|
||||
@@ -203,7 +198,7 @@ void Footage::UpdateTooltip()
|
||||
QString::number(vs->height()))
|
||||
);
|
||||
} else if (streams_.at(i)->type() == Stream::kAudio) {
|
||||
AudioStream* as = static_cast<AudioStream*>(s);
|
||||
AudioStreamPtr as = std::static_pointer_cast<AudioStream>(s);
|
||||
|
||||
tip.append(
|
||||
QCoreApplication::translate("Footage",
|
||||
|
||||
@@ -157,7 +157,7 @@ public:
|
||||
*
|
||||
* A pointer to a stream object. The Footage takes ownership of this object and will free it when it's deleted.
|
||||
*/
|
||||
void add_stream(Stream* s);
|
||||
void add_stream(StreamPtr s);
|
||||
|
||||
/**
|
||||
* @brief Retrieve a stream at the given index.
|
||||
@@ -171,7 +171,7 @@ public:
|
||||
*
|
||||
* The stream at the index provided
|
||||
*/
|
||||
const Stream* stream(int index);
|
||||
StreamPtr stream(int index);
|
||||
|
||||
/**
|
||||
* @brief Retrieve total number of streams in this Footage file
|
||||
@@ -243,7 +243,7 @@ private:
|
||||
/**
|
||||
* @brief Internal streams array
|
||||
*/
|
||||
QList<Stream*> streams_;
|
||||
QList<StreamPtr> streams_;
|
||||
|
||||
/**
|
||||
* @brief Internal ready setting
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#ifndef STREAM_H
|
||||
#define STREAM_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "common/rational.h"
|
||||
|
||||
class Footage;
|
||||
@@ -84,4 +86,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
using StreamPtr = std::shared_ptr<Stream>;
|
||||
|
||||
#endif // STREAM_H
|
||||
|
||||
@@ -43,4 +43,6 @@ private:
|
||||
int height_;
|
||||
};
|
||||
|
||||
using VideoStreamPtr = std::shared_ptr<VideoStream>;
|
||||
|
||||
#endif // VIDEOSTREAM_H
|
||||
|
||||
@@ -41,7 +41,7 @@ ImportTask::ImportTask(ProjectViewModel *model, Folder *parent, const QStringLis
|
||||
urls_(urls),
|
||||
parent_(parent)
|
||||
{
|
||||
set_text(tr("Importing %1 files").arg(urls.size()));
|
||||
set_text(tr("Importing %1 files").arg (urls.size()));
|
||||
}
|
||||
|
||||
bool ImportTask::Action()
|
||||
|
||||
Reference in New Issue
Block a user