diff --git a/sample_code/SampleImageReader.cpp b/sample_code/SampleImageReader.cpp index 9068e138..917205dd 100644 --- a/sample_code/SampleImageReader.cpp +++ b/sample_code/SampleImageReader.cpp @@ -56,7 +56,7 @@ class ImagePlayer : public RecordFormatStreamPlayer { /// Sample basic code to demonstrate how to read a VRS file. struct SampleImageReader { /// This function is the entry point for your reader - void imageReader(const string& vrsFilePath) { + static void imageReader(const string& vrsFilePath) { RecordFileReader reader; if (reader.openFile(vrsFilePath) == 0) { vector> streamPlayers; diff --git a/sample_code/SampleRecordAndPlay.cpp b/sample_code/SampleRecordAndPlay.cpp index 20ddcd7e..185eb05f 100644 --- a/sample_code/SampleRecordAndPlay.cpp +++ b/sample_code/SampleRecordAndPlay.cpp @@ -145,7 +145,7 @@ class RecordableDemo : public Recordable { } // pseudocode helper function - bool iNeedToRecordMoreData() { + static bool iNeedToRecordMoreData() { static int count = 5000; return --count > 0; // arbitrary condition for our demo } @@ -250,7 +250,7 @@ class PlaybackSample { /* * VRS File playback sample */ - static void readVRSFile(string filePath) { + static void readVRSFile(const string& filePath) { RecordFileReader reader; if (reader.openFile(filePath) == 0) { vector> streamPlayers; diff --git a/tools/vrs/VrsCommand.cpp b/tools/vrs/VrsCommand.cpp index ea7f1572..cbc6544a 100644 --- a/tools/vrs/VrsCommand.cpp +++ b/tools/vrs/VrsCommand.cpp @@ -90,7 +90,7 @@ struct CommandConverter : public EnumStringConverter< static_assert(COUNT_OF(sCommands) == enumCount(), "Missing GaiaOp name definitions"); }; -static const RecordFileInfo::Details kCopyOpsDetails = Details::MainCounters; +const RecordFileInfo::Details kCopyOpsDetails = Details::MainCounters; struct CommandSpec { Command cmd; diff --git a/tools/vrs/VrsCommand.h b/tools/vrs/VrsCommand.h index 01de5e25..a367477f 100644 --- a/tools/vrs/VrsCommand.h +++ b/tools/vrs/VrsCommand.h @@ -113,7 +113,7 @@ struct VrsCommand { /// Perform Copy, Merge operation int doCopyMerge(); - bool isRemoteFileSystem(const std::string& path); + static bool isRemoteFileSystem(const std::string& path); /// Main operation Command cmd = Command::None; diff --git a/tools/vrsplayer/AudioPlayer.h b/tools/vrsplayer/AudioPlayer.h index 0f6134f2..112ed343 100644 --- a/tools/vrsplayer/AudioPlayer.h +++ b/tools/vrsplayer/AudioPlayer.h @@ -44,18 +44,18 @@ class AudioPlayer : public QObject, public RecordFormatStreamPlayer { AudioJob() = default; AudioJob(std::vector&& samples, uint32_t frameCount, uint32_t frameSize) : samples{std::move(samples)}, frameCount{frameCount}, frameSize{frameSize} {} - AudioJob(AudioJob&& job) + AudioJob(AudioJob&& job) noexcept : samples{std::move(job.samples)}, frameCount{job.frameCount}, frameSize{job.frameSize} {} - AudioJob& operator=(AudioJob&& job) { + AudioJob& operator=(AudioJob&& job) noexcept { samples = std::move(job.samples); frameCount = job.frameCount; frameSize = job.frameSize; return *this; } std::vector samples; - uint32_t frameCount; - uint32_t frameSize; + uint32_t frameCount{}; + uint32_t frameSize{}; }; public: diff --git a/tools/vrsplayer/FileReader.cpp b/tools/vrsplayer/FileReader.cpp index 4fb551ed..d13c8061 100644 --- a/tools/vrsplayer/FileReader.cpp +++ b/tools/vrsplayer/FileReader.cpp @@ -78,7 +78,7 @@ QString kLayoutPresets("layout_presets"); class FlagKeeper { public: - FlagKeeper(bool& flag) : flag_{flag}, finalValue_{flag_} { + explicit FlagKeeper(bool& flag) : flag_{flag}, finalValue_{flag_} { flag_ = false; } FlagKeeper(bool& flag, bool finalValue) : flag_{flag}, finalValue_{finalValue} { @@ -565,7 +565,7 @@ void FileReader::setBlankMode(bool blank) { } void FileReader::clearLayout(QLayout* layout, bool deleteWidgets) { - QLayoutItem* child; + QLayoutItem* child{}; while ((child = layout->takeAt(0)) != nullptr) { if (child->layout() != nullptr) { clearLayout(child->layout(), deleteWidgets); @@ -719,7 +719,7 @@ double FileReader::getNextRecordDelay() { } void FileReader::playThreadActivity() { - EventChannel::Event event; + EventChannel::Event event{}; while (runThread_) { double delay = getNextRecordDelay(); if (delay > 0) { diff --git a/tools/vrsplayer/FileReader.h b/tools/vrsplayer/FileReader.h index 7219f94f..bf9f83b5 100644 --- a/tools/vrsplayer/FileReader.h +++ b/tools/vrsplayer/FileReader.h @@ -85,7 +85,7 @@ class FileReader : public QObject { static constexpr double kMaxPlaybackAge = 0.2; explicit FileReader(QObject* parent = nullptr); - ~FileReader(); + ~FileReader() override; void setPlayerUi(PlayerUI* ui) { playerUi_ = ui; @@ -128,7 +128,7 @@ class FileReader : public QObject { void setPosition(int position); void sliderPressed(); void sliderReleased(); - bool eventFilter(QObject* obj, QEvent* event); + bool eventFilter(QObject* obj, QEvent* event) override; void stop(); void play(); void pause(); @@ -181,7 +181,7 @@ class FileReader : public QObject { void closeFile(); private: - PlayerUI* playerUi_; + PlayerUI* playerUi_{}; std::vector visibleStreams_; QVBoxLayout* videoFrames_{}; int lastMaxPerRow_{0}; @@ -190,16 +190,16 @@ class FileReader : public QObject { std::map lastReadRecords_; Record::Type recordType_{Record::Type::UNDEFINED}; QTimer slowTimer_; - FileReaderState state_; + FileReaderState state_{}; std::unique_ptr fileReader_; - bool isLocalFile_; - bool isSliderActive_; + bool isLocalFile_{}; + bool isSliderActive_{}; bool layoutUpdatesEnabled_{true}; - double startTime_; - double endTime_; - uint32_t firstDataRecordIndex_; - double lastShownTime_; - size_t nextRecord_; + double startTime_{}; + double endTime_{}; + uint32_t firstDataRecordIndex_{}; + double lastShownTime_{}; + size_t nextRecord_{}; QString lastSaveLocation_; VideoTime time_; bool runThread_{true}; diff --git a/tools/vrsplayer/FramePlayer.h b/tools/vrsplayer/FramePlayer.h index 556cbd99..1827c95e 100644 --- a/tools/vrsplayer/FramePlayer.h +++ b/tools/vrsplayer/FramePlayer.h @@ -103,14 +103,14 @@ class FramePlayer : public QObject, public VideoRecordFormatStreamPlayer { bool firstImage_{true}; std::atomic iframesOnly_{true}; string saveNextFramePath_; - int estimatedFps_; + int estimatedFps_{}; Fps dataFps_; FileReaderState state_{}; vrs::JobQueueWithThread> imageJobs_; void convertFrame(shared_ptr& frame); - void makeBlankFrame(shared_ptr& frame); + static void makeBlankFrame(shared_ptr& frame); shared_ptr getFrame(bool inputNotConvertedFrame); void recycle(shared_ptr& frame, bool inputNotConvertedFrame); bool saveFrame(const CurrentRecord& record, const ContentBlock& contentBlock); diff --git a/tools/vrsplayer/FrameWidget.cpp b/tools/vrsplayer/FrameWidget.cpp index 10dab47d..92049d07 100644 --- a/tools/vrsplayer/FrameWidget.cpp +++ b/tools/vrsplayer/FrameWidget.cpp @@ -87,7 +87,7 @@ void FrameWidget::paintEvent(QPaintEvent* evt) { unique_lock lock; PixelFrame* image = image_.get(); if (image != nullptr) { - QImage::Format qformat; + QImage::Format qformat{}; hasImage = convertToQImageFormat(image->getPixelFormat(), qformat); if (hasImage) { QSize size = image->qsize(); @@ -97,7 +97,7 @@ void FrameWidget::paintEvent(QPaintEvent* evt) { size.height(), static_cast(image->getStride()), qformat); - painter.translate(rect.width() / 2, rect.height() / 2); + painter.translate(rect.width() / 2.f, rect.height() / 2.f); QSize rsize = size; rsize.scale(rotate(rect.size()), Qt::KeepAspectRatio); bool sideWays = rotation_ % 180 != 0; @@ -122,8 +122,7 @@ void FrameWidget::paintEvent(QPaintEvent* evt) { painter.setPen(Qt::black); painter.setBackground(QBrush(Qt::white)); painter.setBackgroundMode(Qt::BGMode::OpaqueMode); - QString description = - QString::fromStdString(vrs::toString(image->getPixelFormat()).c_str()) + + QString description = QString::fromStdString(vrs::toString(image->getPixelFormat())) + " pixel format not supported..."; painter.drawText(QPointF(rect.left() + 4, rect.bottom() - 4), description); } diff --git a/tools/vrsplayer/FrameWidget.h b/tools/vrsplayer/FrameWidget.h index c1b04067..7b04f694 100644 --- a/tools/vrsplayer/FrameWidget.h +++ b/tools/vrsplayer/FrameWidget.h @@ -77,7 +77,7 @@ class Fps { class FrameWidget : public QWidget { Q_OBJECT public: - explicit FrameWidget(QWidget* parent = 0); + explicit FrameWidget(QWidget* parent = nullptr); void paintEvent(QPaintEvent* evt) override; QSize sizeHint() const override; diff --git a/tools/vrsplayer/PlayerUI.cpp b/tools/vrsplayer/PlayerUI.cpp index d9ec9a15..09af7263 100644 --- a/tools/vrsplayer/PlayerUI.cpp +++ b/tools/vrsplayer/PlayerUI.cpp @@ -74,11 +74,11 @@ class JumpSlider : public QSlider { JumpSlider() : QSlider(Qt::Horizontal) {} protected: - void mousePressEvent(QMouseEvent* event) { + void mousePressEvent(QMouseEvent* event) override { QStyleOptionSlider opt; initStyleOption(&opt); QRect sr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); - if (event->button() == Qt::LeftButton && sr.contains(event->pos()) == false) { + if (event->button() == Qt::LeftButton && !sr.contains(event->pos())) { #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) int newVal = minimum() + ((maximum() - minimum()) * event->x()) / width(); #else @@ -231,7 +231,7 @@ void PlayerUI::openFileChooser() { void PlayerUI::openPathChooser() { setStatusText({}); fileReader_.stop(); - bool ok; + bool ok{}; QString text = QInputDialog::getText( nullptr, "Open VRS File", @@ -374,7 +374,7 @@ void PlayerUI::toggleVisibleStreams() { } void PlayerUI::savePreset() { - bool ok; + bool ok{}; QString text = QInputDialog::getText( nullptr, "Save Preset", @@ -399,7 +399,7 @@ void PlayerUI::deletePreset(const QString& preset) { fileReader_.deletePreset(preset); } -void PlayerUI::reportError(QString errorTitle, QString errorMessage) { +void PlayerUI::reportError(const QString& errorTitle, const QString& errorMessage) { emit fileReader_.stop(); QMessageBox messageBox(QMessageBox::Critical, "", errorMessage, QMessageBox::Ok); messageBox.QDialog::setWindowTitle(errorTitle); // Backdoor for MacOS diff --git a/tools/vrsplayer/PlayerUI.h b/tools/vrsplayer/PlayerUI.h index 51bd510c..ae28c6b0 100644 --- a/tools/vrsplayer/PlayerUI.h +++ b/tools/vrsplayer/PlayerUI.h @@ -45,7 +45,7 @@ using PathPreparer = std::function; class PlayerUI : public QWidget { Q_OBJECT public: - PlayerUI(QWidget* parent = nullptr); + explicit PlayerUI(QWidget* parent = nullptr); void setPathPreparer(const PathPreparer& pathPreparer) { pathPreparer_ = pathPreparer; @@ -78,7 +78,7 @@ class PlayerUI : public QWidget { void savePreset(); void recallPreset(const QString& preset); void deletePreset(const QString& preset); - void reportError(QString errorTitle, QString errorMessage); + void reportError(const QString& errorTitle, const QString& errorMessage); void setOverlayColor(QColor color); QColor getOverlayColor() const { return overlayColor_; @@ -97,7 +97,7 @@ class PlayerUI : public QWidget { void recordTypeChanged(int index); void speedControlChanged(int index); void setStatusText(const std::string& statusText); - bool eventFilter(QObject* obj, QEvent* event); + bool eventFilter(QObject* obj, QEvent* event) override; private: QSettings settings_; diff --git a/tools/vrsplayer/PlayerWindow.cpp b/tools/vrsplayer/PlayerWindow.cpp index ab794da7..0ead409b 100644 --- a/tools/vrsplayer/PlayerWindow.cpp +++ b/tools/vrsplayer/PlayerWindow.cpp @@ -28,7 +28,7 @@ using namespace vrsp; using namespace std; inline QKeySequence shortcut(int keyA, int keyB, int keyC = 0) { - return QKeySequence(keyA + keyB + keyC); + return {keyA + keyB + keyC}; } PlayerWindow::PlayerWindow(QApplication& app) : QMainWindow(nullptr) { diff --git a/tools/vrsplayer/PlayerWindow.h b/tools/vrsplayer/PlayerWindow.h index c00e0e6a..bd63329c 100644 --- a/tools/vrsplayer/PlayerWindow.h +++ b/tools/vrsplayer/PlayerWindow.h @@ -61,10 +61,10 @@ class PlayerWindow : public QMainWindow { private: PlayerUI player_; - QMenu* fileMenu_; - QMenu* layoutMenu_; - QMenu* orientationMenu_; - QMenu* textOverlayMenu_; + QMenu* fileMenu_{}; + QMenu* layoutMenu_{}; + QMenu* orientationMenu_{}; + QMenu* textOverlayMenu_{}; std::vector> layoutActions_; };