diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2020-12-12 19:10:41 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2020-12-12 19:10:41 +0000 |
| commit | dd1617ae2862cea5f2c27a1c6d3e3859655a040f (patch) | |
| tree | 739e9e6270aefe2ae35239ebb7fe72b6b8ad5fe2 /src | |
| parent | 8ca516bc875e88009821a243843d8c7ef986235e (diff) | |
| download | qmmp-dd1617ae2862cea5f2c27a1c6d3e3859655a040f.tar.gz qmmp-dd1617ae2862cea5f2c27a1c6d3e3859655a040f.tar.bz2 qmmp-dd1617ae2862cea5f2c27a1c6d3e3859655a040f.zip | |
improved code style
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@9585 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src')
31 files changed, 69 insertions, 124 deletions
diff --git a/src/qmmp/audioconverter.cpp b/src/qmmp/audioconverter.cpp index c0dd1a232..bdc8c285b 100644 --- a/src/qmmp/audioconverter.cpp +++ b/src/qmmp/audioconverter.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010-2016 by Ilya Kotov * + * Copyright (C) 2010-2020 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -43,9 +43,7 @@ } AudioConverter::AudioConverter() -{ - m_format = Qmmp::PCM_UNKNOWN; -} +{} void AudioConverter::configure(Qmmp::AudioFormat f) { diff --git a/src/qmmp/audioconverter.h b/src/qmmp/audioconverter.h index 6c99bbdd8..e1f0ac296 100644 --- a/src/qmmp/audioconverter.h +++ b/src/qmmp/audioconverter.h @@ -57,7 +57,7 @@ public: private: - Qmmp::AudioFormat m_format; + Qmmp::AudioFormat m_format = Qmmp::PCM_UNKNOWN; }; #endif // AUDIOCONVERTER_H diff --git a/src/qmmp/decoder.cpp b/src/qmmp/decoder.cpp index 300c98f1e..0d4c16b8f 100644 --- a/src/qmmp/decoder.cpp +++ b/src/qmmp/decoder.cpp @@ -20,9 +20,7 @@ extern "C" #include "decoder.h" Decoder::Decoder(QIODevice *input) : m_input(input) -{ - m_hasMetaData = false; -} +{} Decoder::~Decoder() {} diff --git a/src/qmmp/decoder.h b/src/qmmp/decoder.h index 71bdcb403..3d71e16e4 100644 --- a/src/qmmp/decoder.h +++ b/src/qmmp/decoder.h @@ -202,7 +202,7 @@ private: AudioParameters m_parameters; QMap<Qmmp::TrackProperty, QString> m_properties; QIODevice *m_input; - bool m_hasMetaData; + bool m_hasMetaData = false; QMap<Qmmp::MetaData, QString> m_metaData; QMap <Qmmp::ReplayGainKey, double> m_rg; //replay gain information }; diff --git a/src/qmmp/dithering.cpp b/src/qmmp/dithering.cpp index fc9f30636..eb2757044 100644 --- a/src/qmmp/dithering.cpp +++ b/src/qmmp/dithering.cpp @@ -25,10 +25,7 @@ Dithering::Dithering() : Effect() { - m_lsb = 0.0f; - m_required = false; m_enabled = QmmpSettings::instance()->useDithering(); - m_chan = 2; clearHistory(); } diff --git a/src/qmmp/dithering_p.h b/src/qmmp/dithering_p.h index 13db7af9c..e79e56733 100644 --- a/src/qmmp/dithering_p.h +++ b/src/qmmp/dithering_p.h @@ -2,7 +2,7 @@ * Based on madplay project * * * * Copyright (C) 2000-2004 Robert Leslie <rob@mars.org> * - * Copyright (C) 2016 Ilya Kotov forkotov02@ya.ru * + * Copyright (C) 2016-2020 Ilya Kotov forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -41,7 +41,7 @@ public: private: void clearHistory(); - int m_chan; + int m_chan = 2; typedef struct { @@ -51,8 +51,8 @@ private: } AudioDither; AudioDither m_dither[9]; - float m_lsb; - bool m_required, m_enabled; + float m_lsb = 0.0f; + bool m_required = false, m_enabled; quint32 prng(quint32 state); diff --git a/src/qmmp/effect.cpp b/src/qmmp/effect.cpp index 2fb3e851a..799ac5bbd 100644 --- a/src/qmmp/effect.cpp +++ b/src/qmmp/effect.cpp @@ -28,11 +28,7 @@ #include "effect.h" Effect::Effect() -{ - m_freq = 0; - m_channels = 0; - m_factory = nullptr; -} +{} Effect::~Effect() {} diff --git a/src/qmmp/effect.h b/src/qmmp/effect.h index 7977eca3e..c1cee6ac4 100644 --- a/src/qmmp/effect.h +++ b/src/qmmp/effect.h @@ -111,9 +111,9 @@ public: static EffectFactory *findFactory(const QString &shortName); private: - EffectFactory *m_factory; - quint32 m_freq; - int m_channels; + EffectFactory *m_factory = nullptr; + quint32 m_freq = 0; + int m_channels = 0; ChannelMap m_chan_map; static void loadPlugins(); static QList<QmmpPluginCache*> *m_cache; diff --git a/src/qmmp/output.cpp b/src/qmmp/output.cpp index 21c4f5813..d6255ba3e 100644 --- a/src/qmmp/output.cpp +++ b/src/qmmp/output.cpp @@ -15,11 +15,7 @@ #include "output.h" Output::Output() -{ - m_frequency = 0; - m_sample_size = 0; - m_format = Qmmp::PCM_UNKNOWN; -} +{} void Output::configure(quint32 freq, ChannelMap map, Qmmp::AudioFormat format) { diff --git a/src/qmmp/output.h b/src/qmmp/output.h index 9a1a10d65..fc1fbac04 100644 --- a/src/qmmp/output.h +++ b/src/qmmp/output.h @@ -139,10 +139,10 @@ protected: void configure(quint32 freq, ChannelMap map, Qmmp::AudioFormat format); private: - quint32 m_frequency; + quint32 m_frequency = 0; ChannelMap m_chan_map; - Qmmp::AudioFormat m_format; - int m_sample_size; + Qmmp::AudioFormat m_format = Qmmp::PCM_UNKNOWN; + int m_sample_size = 0; static void loadPlugins(); static QList<QmmpPluginCache*> *m_cache; }; diff --git a/src/qmmp/qmmpaudioengine.cpp b/src/qmmp/qmmpaudioengine.cpp index cbd20b4aa..f8052c808 100644 --- a/src/qmmp/qmmpaudioengine.cpp +++ b/src/qmmp/qmmpaudioengine.cpp @@ -38,19 +38,9 @@ #define TRANSPORT_TIMEOUT 5000 //ms -QmmpAudioEngine::QmmpAudioEngine(QObject *parent) - : AbstractEngine(parent), m_factory(nullptr), m_output(nullptr) +QmmpAudioEngine::QmmpAudioEngine(QObject *parent) : AbstractEngine(parent) { - m_output_buf = nullptr; - m_output_size = 0; - m_bks = 0; - m_sample_size = 0; - m_decoder = nullptr; - m_output = nullptr; - m_replayGain = nullptr; - m_dithering = nullptr; m_converter = new AudioConverter; - m_settings = QmmpSettings::instance(); connect(m_settings,SIGNAL(replayGainSettingsChanged()), SLOT(updateReplayGainSettings())); connect(m_settings,SIGNAL(audioSettingsChanged()), SLOT(updateAudioSettings())); diff --git a/src/qmmp/qmmpaudioengine_p.h b/src/qmmp/qmmpaudioengine_p.h index afcaf14a0..c7531ace0 100644 --- a/src/qmmp/qmmpaudioengine_p.h +++ b/src/qmmp/qmmpaudioengine_p.h @@ -79,28 +79,28 @@ private: OutputWriter *createOutput(); void prepareEffects(Decoder *d); - DecoderFactory *m_factory; + DecoderFactory *m_factory = nullptr; QList<Effect*> m_effects; QList<Effect*> m_blockedEffects; - OutputWriter *m_output; + OutputWriter *m_output = nullptr; std::atomic_bool m_done, m_finish, m_user_stop; - uint m_bks, m_sample_size; + uint m_bks = 0, m_sample_size = 0; qint64 m_seekTime; - quint64 m_output_at, m_output_size; + quint64 m_output_at, m_output_size = 0; int m_bitrate; - unsigned char *m_output_buf; - Decoder *m_decoder; + unsigned char *m_output_buf = nullptr; + Decoder *m_decoder = nullptr; QQueue <Decoder*> m_decoders; QHash <Decoder*, InputSource*> m_inputs; AudioParameters m_ap; bool m_next; QSharedPointer<TrackInfo> m_trackInfo; static QmmpAudioEngine *m_instance; - ReplayGain *m_replayGain; + ReplayGain *m_replayGain = nullptr; QmmpSettings *m_settings; AudioConverter *m_converter; - Dithering *m_dithering; + Dithering *m_dithering = nullptr; }; #endif // QMMPAUDIOENGINE_P_H diff --git a/src/qmmp/recycler.cpp b/src/qmmp/recycler.cpp index 8dcab2227..a020d6a3a 100644 --- a/src/qmmp/recycler.cpp +++ b/src/qmmp/recycler.cpp @@ -10,15 +10,7 @@ #include "buffer.h" Recycler::Recycler () -{ - m_add_index = 0; - m_done_index = 0; - m_current_count = 0; - m_buffer_count = 0; - m_blocked = nullptr; - m_block_samples = 0; - m_buffers = nullptr; -} +{} Recycler::~Recycler() { diff --git a/src/qmmp/recycler_p.h b/src/qmmp/recycler_p.h index 5ed56a327..5f73d1497 100644 --- a/src/qmmp/recycler_p.h +++ b/src/qmmp/recycler_p.h @@ -98,12 +98,12 @@ public: bool blocked(); private: - unsigned int m_buffer_count, m_add_index, m_done_index, m_current_count; - size_t m_block_samples; - Buffer **m_buffers; + unsigned int m_buffer_count = 0, m_add_index = 0, m_done_index = 0, m_current_count = 0; + size_t m_block_samples = 0; + Buffer **m_buffers = nullptr; QMutex m_mtx; QWaitCondition m_cnd; - Buffer *m_blocked; + Buffer *m_blocked = nullptr; }; #endif // __recycler_h diff --git a/src/qmmp/replaygain.cpp b/src/qmmp/replaygain.cpp index c673d4ac7..551849045 100644 --- a/src/qmmp/replaygain.cpp +++ b/src/qmmp/replaygain.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009-2015 by Ilya Kotov * + * Copyright (C) 2009-2020 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -24,13 +24,7 @@ ReplayGain::ReplayGain() { - m_scale = 1.0; m_mode = QmmpSettings::REPLAYGAIN_DISABLED; - m_preamp = 0.0; - m_default_gain = 0.0; - m_prevent_clipping = false; - m_disabled = true; - m_update = false; } ReplayGain::~ReplayGain() diff --git a/src/qmmp/replaygain_p.h b/src/qmmp/replaygain_p.h index 8c86aaa42..636c86561 100644 --- a/src/qmmp/replaygain_p.h +++ b/src/qmmp/replaygain_p.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009-2015 by Ilya Kotov * + * Copyright (C) 2009-2020 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -45,12 +45,12 @@ private: void updateScale(); QMap<Qmmp::ReplayGainKey, double> m_info; QmmpSettings::ReplayGainMode m_mode; - double m_scale; - double m_preamp; - double m_default_gain; - bool m_prevent_clipping; - bool m_disabled; - bool m_update; + double m_scale = 1.0; + double m_preamp = 0.0; + double m_default_gain = 0.0; + bool m_prevent_clipping = false; + bool m_disabled = true; + bool m_update = false; }; #endif // REPLAYGAIN_H diff --git a/src/qmmp/soundcore.cpp b/src/qmmp/soundcore.cpp index 1f55117ca..7470076da 100644 --- a/src/qmmp/soundcore.cpp +++ b/src/qmmp/soundcore.cpp @@ -44,8 +44,6 @@ SoundCore::SoundCore(QObject *parent) qFatal("SoundCore: only one instance is allowed"); qRegisterMetaType<Qmmp::State>("Qmmp::State"); m_instance = this; - m_engine = nullptr; - m_nextState = NO_ENGINE; m_handler = new StateHandler(this); m_volumeControl = new VolumeHandler(this); connect(m_handler, SIGNAL(elapsedChanged(qint64)), SIGNAL(elapsedChanged(qint64))); diff --git a/src/qmmp/soundcore.h b/src/qmmp/soundcore.h index c0f4ebe56..6a15e5d60 100644 --- a/src/qmmp/soundcore.h +++ b/src/qmmp/soundcore.h @@ -271,9 +271,9 @@ private: static SoundCore* m_instance; StateHandler *m_handler; VolumeHandler *m_volumeControl; - AbstractEngine *m_engine; + AbstractEngine *m_engine = nullptr; QQueue<InputSource *> m_sources; - int m_nextState; + NextEngineState m_nextState = NO_ENGINE; }; #endif diff --git a/src/qmmp/tagmodel.cpp b/src/qmmp/tagmodel.cpp index 5ec4ccdc0..346c35630 100644 --- a/src/qmmp/tagmodel.cpp +++ b/src/qmmp/tagmodel.cpp @@ -35,17 +35,18 @@ void TagModel::setValue(Qmmp::MetaData key, int value) QList<Qmmp::MetaData> TagModel::keys() const { - QList<Qmmp::MetaData> list; - list << Qmmp::TITLE; - list << Qmmp::ARTIST; - list << Qmmp::ALBUMARTIST; - list << Qmmp::ALBUM; - list << Qmmp::COMMENT; - list << Qmmp::GENRE; - list << Qmmp::COMPOSER; - list << Qmmp::YEAR; - list << Qmmp::TRACK; - list << Qmmp::DISCNUMBER; + static const QList<Qmmp::MetaData> list = { + Qmmp::TITLE, + Qmmp::ARTIST, + Qmmp::ALBUMARTIST, + Qmmp::ALBUM, + Qmmp::COMMENT, + Qmmp::GENRE, + Qmmp::COMPOSER, + Qmmp::YEAR, + Qmmp::TRACK, + Qmmp::DISCNUMBER + }; return list; } diff --git a/src/qmmp/trackinfo.cpp b/src/qmmp/trackinfo.cpp index d7673560a..a078c4db3 100644 --- a/src/qmmp/trackinfo.cpp +++ b/src/qmmp/trackinfo.cpp @@ -22,16 +22,11 @@ #include "trackinfo.h" TrackInfo::TrackInfo() -{ - m_duration = 0; - m_parts = Parts(); -} +{} TrackInfo::TrackInfo(const QString &path) { m_path = path; - m_duration = 0; - m_parts = Parts(); } TrackInfo::TrackInfo(const TrackInfo &other) diff --git a/src/qmmp/trackinfo.h b/src/qmmp/trackinfo.h index 3b8006cb4..c7db50ef8 100644 --- a/src/qmmp/trackinfo.h +++ b/src/qmmp/trackinfo.h @@ -172,9 +172,9 @@ private: QMap<Qmmp::MetaData, QString> m_metaData; QMap<Qmmp::TrackProperty, QString> m_properties; QMap<Qmmp::ReplayGainKey, double> m_replayGainInfo; - Parts m_parts; + Parts m_parts = Parts(); QString m_path; - qint64 m_duration; + qint64 m_duration = 0; }; Q_DECLARE_OPERATORS_FOR_FLAGS(TrackInfo::Parts) diff --git a/src/qmmpui/fileloader.cpp b/src/qmmpui/fileloader.cpp index b2ec35881..ec1004836 100644 --- a/src/qmmpui/fileloader.cpp +++ b/src/qmmpui/fileloader.cpp @@ -33,9 +33,6 @@ FileLoader::FileLoader(QObject *parent) : QThread(parent) { qRegisterMetaType<QList<PlayListTrack*> >("QList<PlayListTrack*>"); m_settings = QmmpUiSettings::instance(); - m_finished = false; - m_readMetaDataForPlayLists = true; - m_parts = TrackInfo::Parts(); connect(qApp, SIGNAL(aboutToQuit()), SLOT(finish())); } diff --git a/src/qmmpui/fileloader_p.h b/src/qmmpui/fileloader_p.h index 070560047..aa0afd08a 100644 --- a/src/qmmpui/fileloader_p.h +++ b/src/qmmpui/fileloader_p.h @@ -100,9 +100,9 @@ private: QQueue <LoaderTask> m_tasks; QStringList m_filters; QmmpUiSettings *m_settings; - bool m_finished; - bool m_readMetaDataForPlayLists; - TrackInfo::Parts m_parts; + bool m_finished = false; + bool m_readMetaDataForPlayLists = false; + TrackInfo::Parts m_parts = TrackInfo::Parts(); QMutex m_mutex; }; diff --git a/src/qmmpui/mediaplayer.cpp b/src/qmmpui/mediaplayer.cpp index d6f2d9975..a5f223102 100644 --- a/src/qmmpui/mediaplayer.cpp +++ b/src/qmmpui/mediaplayer.cpp @@ -35,9 +35,9 @@ MediaPlayer::MediaPlayer(QObject *parent) if(m_instance) qFatal("StateHandler: only one instance is allowed"); m_instance = this; - m_pl_manager = nullptr; - m_core = nullptr; - m_skips = 0; + m_core = new SoundCore(this); + m_settings = new QmmpUiSettings(this); + m_pl_manager = new PlayListManager(this); m_finishTimer = new QTimer(this); m_finishTimer->setSingleShot(true); m_finishTimer->setInterval(500); @@ -46,9 +46,7 @@ MediaPlayer::MediaPlayer(QObject *parent) QString locale = Qmmp::systemLanguageID(); translator->load(QString(":/libqmmpui_") + locale); qApp->installTranslator(translator); - m_core = new SoundCore(this); - m_settings = new QmmpUiSettings(this); - m_pl_manager = new PlayListManager(this); + connect(m_core, SIGNAL(nextTrackRequest()), SLOT(updateNextUrl())); connect(m_core, SIGNAL(finished()), SLOT(playNext())); connect(m_core, SIGNAL(stateChanged(Qmmp::State)), SLOT(processState(Qmmp::State))); diff --git a/src/qmmpui/mediaplayer.h b/src/qmmpui/mediaplayer.h index 29174874d..92403fedd 100644 --- a/src/qmmpui/mediaplayer.h +++ b/src/qmmpui/mediaplayer.h @@ -90,7 +90,7 @@ private: PlayListManager *m_pl_manager; SoundCore *m_core; static MediaPlayer* m_instance; - int m_skips; + int m_skips = 0; QString m_nextUrl; QTimer *m_finishTimer; }; diff --git a/src/qmmpui/playlistheadermodel.cpp b/src/qmmpui/playlistheadermodel.cpp index 5e16be5d0..9077dd88b 100644 --- a/src/qmmpui/playlistheadermodel.cpp +++ b/src/qmmpui/playlistheadermodel.cpp @@ -30,7 +30,6 @@ PlayListHeaderModel::PlayListHeaderModel(QObject *parent) : QObject(parent) { m_helper = MetaDataHelper::instance(); - m_settings_loaded = false; ColumnHeader col; col.name = tr("Artist - Title"); diff --git a/src/qmmpui/playlistheadermodel.h b/src/qmmpui/playlistheadermodel.h index aae68baa0..13098749c 100644 --- a/src/qmmpui/playlistheadermodel.h +++ b/src/qmmpui/playlistheadermodel.h @@ -161,7 +161,7 @@ private: QHash<int, QVariant> data; }; QList<ColumnHeader> m_columns; - bool m_settings_loaded; + bool m_settings_loaded = false; MetaDataHelper *m_helper; }; diff --git a/src/qmmpui/playlistitem.cpp b/src/qmmpui/playlistitem.cpp index f9c29ce29..5fb5d0965 100644 --- a/src/qmmpui/playlistitem.cpp +++ b/src/qmmpui/playlistitem.cpp @@ -23,9 +23,7 @@ #include "playlistitem.h" PlayListItem::PlayListItem() -{ - m_selected = false; -} +{} PlayListItem::~PlayListItem() {} diff --git a/src/qmmpui/playlistitem.h b/src/qmmpui/playlistitem.h index 080129618..9097f2f04 100644 --- a/src/qmmpui/playlistitem.h +++ b/src/qmmpui/playlistitem.h @@ -78,7 +78,7 @@ public: virtual int trackIndex() const; private: - bool m_selected; + bool m_selected = false; }; #endif diff --git a/src/qmmpui/playlistmanager.cpp b/src/qmmpui/playlistmanager.cpp index 3b128745a..02ca9731b 100644 --- a/src/qmmpui/playlistmanager.cpp +++ b/src/qmmpui/playlistmanager.cpp @@ -40,8 +40,6 @@ PlayListManager::PlayListManager(QObject *parent) : QObject(parent) m_instance = this; m_ui_settings = QmmpUiSettings::instance(); m_header = new PlayListHeaderModel(this); - m_current = nullptr; - m_selected = nullptr; m_timer = new QTimer(this); m_timer->setInterval(5000); m_timer->setSingleShot(true); diff --git a/src/qmmpui/playlistmanager.h b/src/qmmpui/playlistmanager.h index 5352eef43..c1a5c08ae 100644 --- a/src/qmmpui/playlistmanager.h +++ b/src/qmmpui/playlistmanager.h @@ -268,8 +268,8 @@ private: void readPlayLists(); static PlayListManager* m_instance; QList <PlayListModel *> m_models; - PlayListModel *m_current; - PlayListModel *m_selected; + PlayListModel *m_current = nullptr; + PlayListModel *m_selected = nullptr; QTimer *m_timer; PlayListHeaderModel *m_header; QmmpUiSettings *m_ui_settings; |
