diff options
Diffstat (limited to 'src/plugins/Input')
68 files changed, 265 insertions, 395 deletions
diff --git a/src/plugins/Input/aac/aacfile.cpp b/src/plugins/Input/aac/aacfile.cpp index cf60f8e57..66f5e10d3 100644 --- a/src/plugins/Input/aac/aacfile.cpp +++ b/src/plugins/Input/aac/aacfile.cpp @@ -30,14 +30,8 @@ static int adts_sample_rates[] = {96000,88200,64000,48000,44100,32000,24000,22050,16000,12000,11025,8000,7350,0,0,0}; -AACFile::AACFile(QIODevice *input, bool metaData, bool adts) +AACFile::AACFile(QIODevice *input, bool metaData, bool adts) : m_input(input) { - m_isValid = false; - m_duration = 0; - m_bitrate = 0; - m_samplerate = 0; - m_input = input; - m_offset = 0; char buf[AAC_BUFFER_SIZE]; qint64 buf_at = input->peek((char *) buf, AAC_BUFFER_SIZE); @@ -257,9 +251,8 @@ void AACFile::parseID3v2(const QByteArray &data) m_metaData.insert(Qmmp::TRACK, QString::number(taglib_tag.track())); } -ID3v2Tag::ID3v2Tag(const QByteArray &array) : TagLib::ID3v2::Tag() +ID3v2Tag::ID3v2Tag(const QByteArray &array) : TagLib::ID3v2::Tag(), m_buf(array) { - m_buf = array; read(); } diff --git a/src/plugins/Input/aac/aacfile.h b/src/plugins/Input/aac/aacfile.h index 61e34c2ea..762322249 100644 --- a/src/plugins/Input/aac/aacfile.h +++ b/src/plugins/Input/aac/aacfile.h @@ -42,7 +42,7 @@ class QBuffer; class AACFile { public: - AACFile(QIODevice *input, bool metaData = true, bool adts = true); + explicit AACFile(QIODevice *input, bool metaData = true, bool adts = true); ~AACFile(); @@ -56,19 +56,19 @@ public: private: void parseADTS(); void parseID3v2(const QByteArray &data); - qint64 m_duration; - quint32 m_bitrate; - int m_offset; + qint64 m_duration = 0; + quint32 m_bitrate = 0; + int m_offset = 0; QIODevice *m_input; - bool m_isValid; - quint32 m_samplerate; + bool m_isValid = false; + quint32 m_samplerate = 0; QMap<Qmmp::MetaData, QString> m_metaData; }; class ID3v2Tag : public TagLib::ID3v2::Tag { public: - ID3v2Tag(const QByteArray &array); + explicit ID3v2Tag(const QByteArray &array); protected: void read(); diff --git a/src/plugins/Input/aac/decoder_aac.cpp b/src/plugins/Input/aac/decoder_aac.cpp index ec7b45696..f663a468a 100644 --- a/src/plugins/Input/aac/decoder_aac.cpp +++ b/src/plugins/Input/aac/decoder_aac.cpp @@ -30,19 +30,8 @@ // Decoder class -DecoderAAC::DecoderAAC(QIODevice *i) - : Decoder(i) -{ - m_bitrate = 0; - m_totalTime = 0; - m_data = nullptr; - m_input_buf = nullptr; - m_input_at = 0; - m_sample_buf = nullptr; - m_sample_buf_at = 0; - m_sample_buf_size = 0; -} - +DecoderAAC::DecoderAAC(QIODevice *i) : Decoder(i) +{} DecoderAAC::~DecoderAAC() { diff --git a/src/plugins/Input/aac/decoder_aac.h b/src/plugins/Input/aac/decoder_aac.h index 4f2c3590b..e8a2329b1 100644 --- a/src/plugins/Input/aac/decoder_aac.h +++ b/src/plugins/Input/aac/decoder_aac.h @@ -21,12 +21,9 @@ #ifndef DECODER_AAC_H #define DECODER_AAC_H - #include <neaacdec.h> - #include <qmmp/decoder.h> - struct aac_data { NeAACDecHandle handle; @@ -35,7 +32,7 @@ struct aac_data class DecoderAAC : public Decoder { public: - DecoderAAC(QIODevice *); + explicit DecoderAAC(QIODevice *); virtual ~DecoderAAC(); @@ -51,14 +48,14 @@ public: void seek(qint64 time) override; private: - struct aac_data *m_data; - char* m_input_buf; - void* m_sample_buf; - int m_sample_buf_at; - qint64 m_sample_buf_size; - int m_bitrate; - ulong m_input_at; - qint64 m_totalTime; + struct aac_data *m_data = nullptr; + char *m_input_buf = nullptr; + void *m_sample_buf = nullptr; + int m_sample_buf_at = 0; + qint64 m_sample_buf_size = 0; + int m_bitrate = 0; + ulong m_input_at = 0; + qint64 m_totalTime = 0; }; diff --git a/src/plugins/Input/archive/archiveinputdevice.cpp b/src/plugins/Input/archive/archiveinputdevice.cpp index 95b336750..bbe2151c5 100644 --- a/src/plugins/Input/archive/archiveinputdevice.cpp +++ b/src/plugins/Input/archive/archiveinputdevice.cpp @@ -23,14 +23,11 @@ ArchiveInputDevice::ArchiveInputDevice(const QString &url, QObject *parent) : QIODevice(parent) { - m_archive = nullptr; - m_entry = nullptr; QString filePath = url.section("#", -1); QString archivePath = url; archivePath.remove(QRegExp("^.+://")); archivePath.remove(QRegExp("#.+$")); - m_close_libarchive = true; m_archive = archive_read_new(); archive_read_support_filter_all(m_archive); archive_read_support_format_all(m_archive); diff --git a/src/plugins/Input/archive/archiveinputdevice.h b/src/plugins/Input/archive/archiveinputdevice.h index 18d8024d6..fef847a77 100644 --- a/src/plugins/Input/archive/archiveinputdevice.h +++ b/src/plugins/Input/archive/archiveinputdevice.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2016 by Ilya Kotov * + * Copyright (C) 2016-2020 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -30,8 +30,8 @@ class ArchiveInputDevice : public QIODevice { Q_OBJECT public: - ArchiveInputDevice(const QString &url, QObject *parent = nullptr); - ArchiveInputDevice(struct archive *a, struct archive_entry *e, QObject *parent = nullptr); + explicit ArchiveInputDevice(const QString &url, QObject *parent = nullptr); + explicit ArchiveInputDevice(struct archive *a, struct archive_entry *e, QObject *parent = nullptr); virtual ~ArchiveInputDevice(); bool seek(qint64 pos) override; @@ -42,10 +42,10 @@ protected: virtual qint64 writeData(const char *, qint64) override; private: - struct archive *m_archive; - struct archive_entry *m_entry; + struct archive *m_archive = nullptr; + struct archive_entry *m_entry = nullptr; QBuffer m_buffer; - bool m_close_libarchive; + bool m_close_libarchive = true; }; #endif // ARCHIVEINPUTDEVICE_H diff --git a/src/plugins/Input/archive/archivetagreader.cpp b/src/plugins/Input/archive/archivetagreader.cpp index f1837c18a..2ec7fe524 100644 --- a/src/plugins/Input/archive/archivetagreader.cpp +++ b/src/plugins/Input/archive/archivetagreader.cpp @@ -24,15 +24,13 @@ class IODeviceStream : public TagLib::IOStream { public: - IODeviceStream(QIODevice *input, const QString &url) - { - m_input = input; + IODeviceStream(QIODevice *input, const QString &url) : m_input(input), #ifdef Q_OS_WIN - m_fileName = url.section("/", -1); + m_fileName(url.section("/", -1)) #else - m_fileName = url.section("/", -1).toLocal8Bit(); + m_fileName(url.section("/", -1).toLocal8Bit()) #endif - } + {} virtual ~IODeviceStream() {} diff --git a/src/plugins/Input/archive/decoder_archive.cpp b/src/plugins/Input/archive/decoder_archive.cpp index 0f1fc860f..34a37aa01 100644 --- a/src/plugins/Input/archive/decoder_archive.cpp +++ b/src/plugins/Input/archive/decoder_archive.cpp @@ -24,12 +24,8 @@ #include "archivetagreader.h" #include "decoder_archive.h" -DecoderArchive::DecoderArchive(const QString &url) -{ - m_url = url; - m_decoder = nullptr; - m_input = nullptr; -} +DecoderArchive::DecoderArchive(const QString &url) : m_url(url) +{} DecoderArchive::~DecoderArchive() { diff --git a/src/plugins/Input/archive/decoder_archive.h b/src/plugins/Input/archive/decoder_archive.h index 3b9b06f94..d14a11180 100644 --- a/src/plugins/Input/archive/decoder_archive.h +++ b/src/plugins/Input/archive/decoder_archive.h @@ -30,7 +30,7 @@ class DecoderArchive : public Decoder { public: - DecoderArchive(const QString &url); + explicit DecoderArchive(const QString &url); virtual ~DecoderArchive(); @@ -42,8 +42,8 @@ public: private: QString m_url; - Decoder *m_decoder; - QIODevice *m_input; + Decoder *m_decoder = nullptr; + QIODevice *m_input = nullptr; }; diff --git a/src/plugins/Input/cdaudio/decoder_cdaudio.cpp b/src/plugins/Input/cdaudio/decoder_cdaudio.cpp index 37d7656bc..d2cf8dda9 100644 --- a/src/plugins/Input/cdaudio/decoder_cdaudio.cpp +++ b/src/plugins/Input/cdaudio/decoder_cdaudio.cpp @@ -79,11 +79,10 @@ static void cddb_log_handler(cddb_log_level_t level, const char *message) // Decoder class -DecoderCDAudio::DecoderCDAudio(const QString &url) : Decoder() -{ - m_url = url; - m_buffer = new char[CDDA_BUFFER_SIZE]; -} +DecoderCDAudio::DecoderCDAudio(const QString &url) : Decoder(), + m_url(url), + m_buffer(new char[CDDA_BUFFER_SIZE]) +{} DecoderCDAudio::~DecoderCDAudio() { @@ -233,8 +232,7 @@ QList<CDATrack> DecoderCDAudio::generateTrackList(const QString &device, TrackIn qDebug("DecoderCDAudio: reading CDDB..."); cddb_log_set_handler(cddb_log_handler); cddb_conn_t *cddb_conn = cddb_new (); - cddb_disc_t *cddb_disc = NULL; - cddb_track_t *cddb_track = NULL; + cddb_disc_t *cddb_disc = nullptr; lba_t lba; if (!cddb_conn) qWarning ("DecoderCDAudio: unable to create cddb connection"); @@ -270,7 +268,7 @@ QList<CDATrack> DecoderCDAudio::generateTrackList(const QString &device, TrackIn for (int i = first_track_number; i <= last_track_number; ++i) { - cddb_track = cddb_track_new (); + cddb_track_t *cddb_track = cddb_track_new (); cddb_track_set_frame_offset (cddb_track, cdio_get_track_lba (cdio, i)); cddb_disc_add_track (cddb_disc, cddb_track); } diff --git a/src/plugins/Input/cdaudio/decoder_cdaudio.h b/src/plugins/Input/cdaudio/decoder_cdaudio.h index 130f85bd4..f3f3e6688 100644 --- a/src/plugins/Input/cdaudio/decoder_cdaudio.h +++ b/src/plugins/Input/cdaudio/decoder_cdaudio.h @@ -31,20 +31,17 @@ class CDATrack { public: CDATrack() - { - first_sector = 0; - last_sector = 0; - } + {} TrackInfo info; - lsn_t first_sector; - lsn_t last_sector; + lsn_t first_sector = 0; + lsn_t last_sector = 0; }; class DecoderCDAudio : public Decoder { public: - DecoderCDAudio(const QString &url); + explicit DecoderCDAudio(const QString &url); virtual ~DecoderCDAudio(); static QList <CDATrack> generateTrackList(const QString &device, TrackInfo::Parts parts = TrackInfo::AllParts); diff --git a/src/plugins/Input/cue/cuefile.cpp b/src/plugins/Input/cue/cuefile.cpp index 8941c2059..d1980fe39 100644 --- a/src/plugins/Input/cue/cuefile.cpp +++ b/src/plugins/Input/cue/cuefile.cpp @@ -95,11 +95,11 @@ CueFile::CueFile(const QString &path) : CueParser() } } - for(const QString &path : m_dataFiles.values()) + for(const QString &p : m_dataFiles.values()) { - if(!QFile::exists(path)) + if(!QFile::exists(p)) { - qDebug("CueFile: unable to find file: %s", qPrintable(path)); + qDebug("CueFile: unable to find file: %s", qPrintable(p)); clear(); return; } diff --git a/src/plugins/Input/cue/cuefile.h b/src/plugins/Input/cue/cuefile.h index ca9da23bd..91b82c9f3 100644 --- a/src/plugins/Input/cue/cuefile.h +++ b/src/plugins/Input/cue/cuefile.h @@ -35,7 +35,7 @@ class CueFile : public CueParser { public: - CueFile(const QString &path); + explicit CueFile(const QString &path); ~CueFile(); QString dataFilePath(int track) const; diff --git a/src/plugins/Input/cue/cuemetadatamodel.h b/src/plugins/Input/cue/cuemetadatamodel.h index 7c827ce54..b5eba82ca 100644 --- a/src/plugins/Input/cue/cuemetadatamodel.h +++ b/src/plugins/Input/cue/cuemetadatamodel.h @@ -28,7 +28,7 @@ class CueFile; class CUEMetaDataModel : public MetaDataModel { public: - CUEMetaDataModel(const QString &url); + explicit CUEMetaDataModel(const QString &url); ~CUEMetaDataModel(); QList<MetaDataItem> extraProperties() const override; QString coverPath() const override; diff --git a/src/plugins/Input/cue/decoder_cue.cpp b/src/plugins/Input/cue/decoder_cue.cpp index 9f5680113..fcd597bfc 100644 --- a/src/plugins/Input/cue/decoder_cue.cpp +++ b/src/plugins/Input/cue/decoder_cue.cpp @@ -29,16 +29,9 @@ #include "decoder_cue.h" -DecoderCUE::DecoderCUE(const QString &url) - : Decoder() -{ - m_path = url; - m_decoder = nullptr; - m_cueFile = nullptr; - m_track = 0; - m_buf = nullptr; - m_input = nullptr; -} +DecoderCUE::DecoderCUE(const QString &url) : Decoder(), + m_path(url) +{} DecoderCUE::~DecoderCUE() { diff --git a/src/plugins/Input/cue/decoder_cue.h b/src/plugins/Input/cue/decoder_cue.h index f0aa7b906..216f29cad 100644 --- a/src/plugins/Input/cue/decoder_cue.h +++ b/src/plugins/Input/cue/decoder_cue.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2016 by Ilya Kotov * + * Copyright (C) 2008-2020 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -31,7 +31,7 @@ class CueFile; class DecoderCUE : public Decoder { public: - DecoderCUE(const QString &url); + explicit DecoderCUE(const QString &url); virtual ~DecoderCUE(); // Standard Decoder API @@ -44,18 +44,18 @@ public: void next() override; private: - Decoder *m_decoder; - qint64 m_length; - qint64 m_offset; - qint64 length_in_bytes; - qint64 m_totalBytes; + Decoder *m_decoder = nullptr; + qint64 m_length = 0; + qint64 m_offset = 0; + qint64 length_in_bytes = 0; + qint64 m_totalBytes = 0; QString m_path; - CueFile *m_cueFile; - int m_track; - char *m_buf; //buffer for remainig data - qint64 m_buf_size; - qint64 m_sz; //sample size - QIODevice *m_input; + CueFile *m_cueFile = nullptr; + int m_track = 0; + char *m_buf = nullptr; //buffer for remainig data + qint64 m_buf_size = 0; + qint64 m_sz = 0; //sample size + QIODevice *m_input = nullptr; }; #endif // DECODER_CUE_H diff --git a/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp b/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp index 986528d19..b9d890770 100644 --- a/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp +++ b/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp @@ -35,12 +35,12 @@ static int ffmpeg_read(void *data, uint8_t *buf, int size) if(d->input()->atEnd()) return AVERROR_EOF; #endif - return (int)d->input()->read((char*)buf, size); + return static_cast<int>(d->input()->read((char*)buf, size)); } static int64_t ffmpeg_seek(void *data, int64_t offset, int whence) { - DecoderFFmpeg *d = (DecoderFFmpeg*)data; + DecoderFFmpeg *d = static_cast<DecoderFFmpeg*>(data); int64_t absolute_pos = 0; /*if(d->input()->isSequential()) return -1;*/ @@ -66,10 +66,10 @@ static int64_t ffmpeg_seek(void *data, int64_t offset, int whence) } // Decoder class -DecoderFFmpeg::DecoderFFmpeg(const QString &path, QIODevice *i) - : Decoder(i) +DecoderFFmpeg::DecoderFFmpeg(const QString &path, QIODevice *i) : Decoder(i), + m_path(path) + { - m_path = path; m_pkt = av_packet_alloc(); } @@ -410,9 +410,9 @@ void DecoderFFmpeg::fillBuffer() if((m_eof || send_error < 0) && recv_error < 0) { - char errbuf[AV_ERROR_MAX_STRING_SIZE] = { 0 }; if(!m_eof) { + char errbuf[AV_ERROR_MAX_STRING_SIZE] = { 0 }; av_strerror(send_error, errbuf, sizeof(errbuf)); qWarning("DecoderFFmpeg: avcodec_send_packet error: %s", errbuf); av_strerror(recv_error, errbuf, sizeof(errbuf)); diff --git a/src/plugins/Input/ffmpeg/decoder_ffmpeg.h b/src/plugins/Input/ffmpeg/decoder_ffmpeg.h index 5bea3901d..303234f2c 100644 --- a/src/plugins/Input/ffmpeg/decoder_ffmpeg.h +++ b/src/plugins/Input/ffmpeg/decoder_ffmpeg.h @@ -36,7 +36,7 @@ extern "C"{ class DecoderFFmpeg : public Decoder { public: - DecoderFFmpeg(const QString &, QIODevice *i); + explicit DecoderFFmpeg(const QString &, QIODevice *i); virtual ~DecoderFFmpeg(); // Standard Decoder API diff --git a/src/plugins/Input/ffmpeg/decoder_ffmpegcue.cpp b/src/plugins/Input/ffmpeg/decoder_ffmpegcue.cpp index b85ff55db..a27a687fe 100644 --- a/src/plugins/Input/ffmpeg/decoder_ffmpegcue.cpp +++ b/src/plugins/Input/ffmpeg/decoder_ffmpegcue.cpp @@ -25,12 +25,9 @@ #include "decoder_ffmpeg.h" #include "decoder_ffmpegcue.h" - -DecoderFFmpegCue::DecoderFFmpegCue(const QString &url) - : Decoder() -{ - m_url = url; -} +DecoderFFmpegCue::DecoderFFmpegCue(const QString &url) : Decoder(), + m_url(url) +{} DecoderFFmpegCue::~DecoderFFmpegCue() { diff --git a/src/plugins/Input/ffmpeg/decoder_ffmpegcue.h b/src/plugins/Input/ffmpeg/decoder_ffmpegcue.h index 7edb372b2..b8203e70c 100644 --- a/src/plugins/Input/ffmpeg/decoder_ffmpegcue.h +++ b/src/plugins/Input/ffmpeg/decoder_ffmpegcue.h @@ -33,7 +33,7 @@ class CueParser; class DecoderFFmpegCue : public Decoder { public: - DecoderFFmpegCue(const QString &url); + explicit DecoderFFmpegCue(const QString &url); virtual ~DecoderFFmpegCue(); // Standard Decoder API diff --git a/src/plugins/Input/ffmpeg/decoderffmpegfactory.cpp b/src/plugins/Input/ffmpeg/decoderffmpegfactory.cpp index fccd90bd3..4fb284b98 100644 --- a/src/plugins/Input/ffmpeg/decoderffmpegfactory.cpp +++ b/src/plugins/Input/ffmpeg/decoderffmpegfactory.cpp @@ -174,14 +174,14 @@ Decoder *DecoderFFmpegFactory::create(const QString &path, QIODevice *input) QList<TrackInfo *> DecoderFFmpegFactory::createPlayList(const QString &path, TrackInfo::Parts parts, QStringList *) { - int track = -1; //cue track + int cueTrack = -1; //cue track QString filePath = path; if(path.contains("://")) //is it cue track? { filePath.remove("ffmpeg://"); filePath.remove(QRegExp("#\\d+$")); - track = path.section("#", -1).toInt(); + cueTrack = path.section("#", -1).toInt(); parts = TrackInfo::AllParts; //extract all metadata for single cue track } @@ -240,7 +240,7 @@ QList<TrackInfo *> DecoderFFmpegFactory::createPlayList(const QString &path, Tra avformat_close_input(&in); delete info; - return (track > 0) ? parser.createPlayList(track) : parser.createPlayList(); + return (cueTrack > 0) ? parser.createPlayList(cueTrack) : parser.createPlayList(); } AVDictionaryEntry *album = av_dict_get(in->metadata,"album",nullptr,0); diff --git a/src/plugins/Input/ffmpeg/ffmpegmetadatamodel.h b/src/plugins/Input/ffmpeg/ffmpegmetadatamodel.h index 13d040231..9e18add0a 100644 --- a/src/plugins/Input/ffmpeg/ffmpegmetadatamodel.h +++ b/src/plugins/Input/ffmpeg/ffmpegmetadatamodel.h @@ -26,7 +26,7 @@ class FFmpegMetaDataModel : public MetaDataModel { public: - FFmpegMetaDataModel(const QString &path); + explicit FFmpegMetaDataModel(const QString &path); ~FFmpegMetaDataModel(); QPixmap cover() const override; diff --git a/src/plugins/Input/ffmpeg/replaygainreader.h b/src/plugins/Input/ffmpeg/replaygainreader.h index 2002b15b6..6b11ab868 100644 --- a/src/plugins/Input/ffmpeg/replaygainreader.h +++ b/src/plugins/Input/ffmpeg/replaygainreader.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2016 by Ilya Kotov * + * Copyright (C) 2016-2020 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -35,7 +35,7 @@ extern "C"{ class ReplayGainReader { public: - ReplayGainReader(AVFormatContext *ic); + explicit ReplayGainReader(AVFormatContext *ic); QMap <Qmmp::ReplayGainKey, double> replayGainInfo() const; private: diff --git a/src/plugins/Input/flac/decoder_flac.cpp b/src/plugins/Input/flac/decoder_flac.cpp index cfc34a35e..d95b1a9f3 100644 --- a/src/plugins/Input/flac/decoder_flac.cpp +++ b/src/plugins/Input/flac/decoder_flac.cpp @@ -84,9 +84,9 @@ static size_t pack_pcm_signed (FLAC__byte *output, return samples * channels * bps / 8; } -static int flac_decode (void *void_data, unsigned char *buf, int buf_len) +static int flac_decode (void *client_data, unsigned char *buf, int buf_len) { - flac_data *data = (flac_data *) void_data; + flac_data *data = static_cast<flac_data *>(client_data); unsigned to_copy; if (!data->sample_buffer_fill) @@ -120,7 +120,7 @@ static FLAC__StreamDecoderReadStatus flac_callback_read (const FLAC__StreamDecod size_t *bytes, void *client_data) { - flac_data *data = (flac_data *) client_data; + flac_data *data = static_cast<flac_data *>(client_data); qint64 res = data->input->read((char *)buffer, *bytes); if (res > 0) @@ -143,7 +143,7 @@ static FLAC__StreamDecoderWriteStatus flac_callback_write (const FLAC__StreamDec const FLAC__int32* const buffer[], void *client_data) { - flac_data *data = (flac_data *) client_data; + flac_data *data = static_cast<flac_data *>(client_data); const unsigned wide_samples = frame->header.blocksize; if (data->abort) @@ -185,7 +185,7 @@ static FLAC__StreamDecoderTellStatus flac_callback_tell (const FLAC__StreamDecod FLAC__uint64 *offset, void *client_data) { - flac_data *data = (flac_data *) client_data; + flac_data *data = static_cast<flac_data *>(client_data); if(data->input->isSequential()) return FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED; @@ -197,7 +197,7 @@ static FLAC__StreamDecoderSeekStatus flac_callback_seek (const FLAC__StreamDecod FLAC__uint64 offset, void *client_data) { - flac_data *data = (flac_data *) client_data; + flac_data *data = static_cast<flac_data *>(client_data); if(data->input->isSequential()) return FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED; @@ -210,7 +210,7 @@ static FLAC__StreamDecoderLengthStatus flac_callback_length (const FLAC__StreamD FLAC__uint64 *stream_length, void *client_data) { - flac_data *data = (flac_data *) client_data; + flac_data *data = static_cast<flac_data *>(client_data); if(data->input->isSequential()) return FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED; @@ -222,7 +222,7 @@ static void flac_callback_metadata (const FLAC__StreamDecoder *, const FLAC__StreamMetadata *metadata, void *client_data) { - flac_data *data = (flac_data *) client_data; + flac_data *data = static_cast<flac_data *>(client_data); if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO) { @@ -262,12 +262,10 @@ static void flac_callback_error (const FLAC__StreamDecoder *, // Decoder class -DecoderFLAC::DecoderFLAC(const QString &path, QIODevice *i) - : Decoder(i) +DecoderFLAC::DecoderFLAC(const QString &path, QIODevice *i) : Decoder(i), + m_path(path) { - m_path = path; m_data = new flac_data; - m_data->decoder = nullptr; m_data->input = i; } diff --git a/src/plugins/Input/flac/decoder_flac.h b/src/plugins/Input/flac/decoder_flac.h index 73ad194e3..500ebe2a3 100644 --- a/src/plugins/Input/flac/decoder_flac.h +++ b/src/plugins/Input/flac/decoder_flac.h @@ -61,7 +61,7 @@ struct flac_data class DecoderFLAC : public Decoder { public: - DecoderFLAC(const QString &path, QIODevice *i); + explicit DecoderFLAC(const QString &path, QIODevice *i); virtual ~DecoderFLAC(); // Standard Decoder API diff --git a/src/plugins/Input/flac/flacmetadatamodel.cpp b/src/plugins/Input/flac/flacmetadatamodel.cpp index b42922f21..ee7824ae9 100644 --- a/src/plugins/Input/flac/flacmetadatamodel.cpp +++ b/src/plugins/Input/flac/flacmetadatamodel.cpp @@ -33,12 +33,12 @@ FLACMetaDataModel::FLACMetaDataModel(const QString &path, bool readOnly) #ifdef HAS_PICTURE_LIST - : MetaDataModel(true, MetaDataModel::IsCoverEditable) + : MetaDataModel(true, MetaDataModel::IsCoverEditable), #else - : MetaDataModel(true) + : MetaDataModel(true), #endif + m_path(path) { - m_path = path; if(path.startsWith("flac://")) { m_path.remove("flac://"); diff --git a/src/plugins/Input/gme/decoder_gme.cpp b/src/plugins/Input/gme/decoder_gme.cpp index fd9754a8e..171137311 100644 --- a/src/plugins/Input/gme/decoder_gme.cpp +++ b/src/plugins/Input/gme/decoder_gme.cpp @@ -23,11 +23,9 @@ #include "decoder_gme.h" // Decoder class -DecoderGme::DecoderGme(const QString &path) : Decoder() -{ - m_path = path; - m_emu = nullptr; -} +DecoderGme::DecoderGme(const QString &path) : Decoder(), + m_path(path) +{} DecoderGme::~DecoderGme() {} diff --git a/src/plugins/Input/gme/decoder_gme.h b/src/plugins/Input/gme/decoder_gme.h index bd871931d..a0707a3be 100644 --- a/src/plugins/Input/gme/decoder_gme.h +++ b/src/plugins/Input/gme/decoder_gme.h @@ -32,7 +32,7 @@ class GmeHelper; class DecoderGme : public Decoder { public: - DecoderGme(const QString &path); + explicit DecoderGme(const QString &path); virtual ~DecoderGme(); // Standard Decoder API @@ -44,7 +44,7 @@ public: private: GmeHelper m_helper; - Music_Emu *m_emu; + Music_Emu *m_emu = nullptr; qint64 m_totalTime; QString m_path; }; diff --git a/src/plugins/Input/modplug/archivereader.h b/src/plugins/Input/modplug/archivereader.h index 7a714e385..3c55da753 100644 --- a/src/plugins/Input/modplug/archivereader.h +++ b/src/plugins/Input/modplug/archivereader.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * + * Copyright (C) 2008-2020 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -32,7 +32,7 @@ class ArchiveReader : public QObject { Q_OBJECT public: - ArchiveReader(QObject *parent = nullptr); + explicit ArchiveReader(QObject *parent = nullptr); ~ArchiveReader(); diff --git a/src/plugins/Input/modplug/decoder_modplug.cpp b/src/plugins/Input/modplug/decoder_modplug.cpp index a2924c183..db046dd1d 100644 --- a/src/plugins/Input/modplug/decoder_modplug.cpp +++ b/src/plugins/Input/modplug/decoder_modplug.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2016 by Ilya Kotov * + * Copyright (C) 2008-2020 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -41,19 +41,10 @@ DecoderModPlug* DecoderModPlug::m_instance = nullptr; -DecoderModPlug::DecoderModPlug(const QString &path) : Decoder(nullptr) +DecoderModPlug::DecoderModPlug(const QString &path) : Decoder(nullptr), + m_path(path) { - m_path = path; - m_freq = 0; - m_bitrate = 0; - m_totalTime = 0; - m_chan = 0; - m_soundFile = nullptr; - m_sampleSize = 0; - m_instance = this; - m_bps = 0; - m_preampFactor = 0.0f; - m_usePreamp = false; + m_instance = this; } DecoderModPlug::~DecoderModPlug() diff --git a/src/plugins/Input/modplug/decoder_modplug.h b/src/plugins/Input/modplug/decoder_modplug.h index 8797b2d59..7adbeb463 100644 --- a/src/plugins/Input/modplug/decoder_modplug.h +++ b/src/plugins/Input/modplug/decoder_modplug.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2009 by Ilya Kotov * + * Copyright (C) 2008-2020 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -28,7 +28,7 @@ class CSoundFile; class DecoderModPlug : public Decoder { public: - DecoderModPlug(const QString &path); + explicit DecoderModPlug(const QString &path); virtual ~DecoderModPlug(); void readSettings(); @@ -45,15 +45,15 @@ private: //helper function void deinit(); - CSoundFile *m_soundFile; + CSoundFile *m_soundFile = nullptr; int m_bps; //bits per sample QByteArray m_input_buf; //input buffer - quint32 m_freq; - int m_chan, m_sampleSize, m_bitrate; - qint64 m_totalTime; - double m_preampFactor; - bool m_usePreamp; + quint32 m_freq = 0; + int m_chan = 0, m_sampleSize = 0, m_bitrate = 0; + qint64 m_totalTime = 0; + double m_preampFactor = 0.0f; + bool m_usePreamp = false; QString m_path; static DecoderModPlug* m_instance; }; diff --git a/src/plugins/Input/modplug/modplugmetadatamodel.cpp b/src/plugins/Input/modplug/modplugmetadatamodel.cpp index a76d7c449..604e15b5f 100644 --- a/src/plugins/Input/modplug/modplugmetadatamodel.cpp +++ b/src/plugins/Input/modplug/modplugmetadatamodel.cpp @@ -29,10 +29,9 @@ #define MAX_MESSAGE_LENGTH 4000 -ModPlugMetaDataModel::ModPlugMetaDataModel(const QString &path) : MetaDataModel(true) +ModPlugMetaDataModel::ModPlugMetaDataModel(const QString &path) : MetaDataModel(true), + m_path(path) { - m_soundFile = nullptr; - m_path = path; ArchiveReader reader(nullptr); if(reader.isSupported(m_path)) { diff --git a/src/plugins/Input/modplug/modplugmetadatamodel.h b/src/plugins/Input/modplug/modplugmetadatamodel.h index bc930ecfb..e80fc452c 100644 --- a/src/plugins/Input/modplug/modplugmetadatamodel.h +++ b/src/plugins/Input/modplug/modplugmetadatamodel.h @@ -29,14 +29,14 @@ class ModPlugMetaDataModel : public MetaDataModel { Q_DECLARE_TR_FUNCTIONS(ModPlugMetaDataModel) public: - ModPlugMetaDataModel(const QString &path); + explicit ModPlugMetaDataModel(const QString &path); ~ModPlugMetaDataModel(); QList<MetaDataItem> extraProperties() const override; QList<MetaDataItem> descriptions() const override; static QString getTypeName(quint32 type); private: - CSoundFile* m_soundFile; + CSoundFile* m_soundFile = nullptr; QByteArray m_buffer; QString m_path; }; diff --git a/src/plugins/Input/mpc/decoder_mpc.cpp b/src/plugins/Input/mpc/decoder_mpc.cpp index 22d721d27..63827c4a4 100644 --- a/src/plugins/Input/mpc/decoder_mpc.cpp +++ b/src/plugins/Input/mpc/decoder_mpc.cpp @@ -18,7 +18,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ - #include <QObject> #include <QIODevice> #include <qmmp/buffer.h> @@ -30,44 +29,38 @@ static mpc_int32_t mpc_callback_read (mpc_reader *reader, void *buffer, mpc_int32_t size) { - DecoderMPC *dmpc = (DecoderMPC *) reader->data; + DecoderMPC *dmpc = static_cast<DecoderMPC *>(reader->data); return dmpc->input()->read((char *)buffer, size); } static mpc_bool_t mpc_callback_seek (mpc_reader *reader, mpc_int32_t offset) { - DecoderMPC *dmpc = (DecoderMPC *) reader->data; + DecoderMPC *dmpc = static_cast<DecoderMPC *>(reader->data); return dmpc->input()->seek(offset); } static mpc_int32_t mpc_callback_tell (mpc_reader *reader) { - DecoderMPC *dmpc = (DecoderMPC *) reader->data; + DecoderMPC *dmpc = static_cast<DecoderMPC *>(reader->data); return dmpc->input()->pos (); } static mpc_bool_t mpc_callback_canseek (mpc_reader *reader) { - DecoderMPC *dmpc = (DecoderMPC *) reader->data; + DecoderMPC *dmpc = static_cast<DecoderMPC *>(reader->data); return !dmpc->input()->isSequential () ; } static mpc_int32_t mpc_callback_get_size (mpc_reader *reader) { - DecoderMPC *dmpc = (DecoderMPC *) reader->data; + DecoderMPC *dmpc = static_cast<DecoderMPC *>(reader->data); return dmpc->input()->size(); } // Decoder class -DecoderMPC::DecoderMPC(QIODevice *i) - : Decoder(i) -{ - m_len = 0; - m_bitrate = 0; - m_totalTime = 0.0; - m_data = nullptr; -} +DecoderMPC::DecoderMPC(QIODevice *i) : Decoder(i) +{} DecoderMPC::~DecoderMPC() { @@ -164,5 +157,4 @@ qint64 DecoderMPC::read(unsigned char *audio, qint64 maxSize) void DecoderMPC::seek(qint64 pos) { mpc_demux_seek_second(data()->demuxer, (double)pos/1000); - } diff --git a/src/plugins/Input/mpc/decoder_mpc.h b/src/plugins/Input/mpc/decoder_mpc.h index 7024020d3..007f3adad 100644 --- a/src/plugins/Input/mpc/decoder_mpc.h +++ b/src/plugins/Input/mpc/decoder_mpc.h @@ -26,7 +26,7 @@ struct mpc_data { - mpc_demux *demuxer; + mpc_demux *demuxer = nullptr; mpc_reader reader; mpc_streaminfo info; }; @@ -34,7 +34,7 @@ struct mpc_data class DecoderMPC : public Decoder { public: - DecoderMPC(QIODevice *i); + explicit DecoderMPC(QIODevice *i); virtual ~DecoderMPC(); struct mpc_data *data() @@ -50,11 +50,10 @@ public: void seek(qint64 time) override; private: - - struct mpc_data *m_data; - long m_len; - int m_bitrate; - qint64 m_totalTime; + struct mpc_data *m_data = nullptr; + long m_len = 0; + int m_bitrate = 0; + qint64 m_totalTime = 0; }; diff --git a/src/plugins/Input/mpc/mpcmetadatamodel.cpp b/src/plugins/Input/mpc/mpcmetadatamodel.cpp index ee9368477..81eeca5b7 100644 --- a/src/plugins/Input/mpc/mpcmetadatamodel.cpp +++ b/src/plugins/Input/mpc/mpcmetadatamodel.cpp @@ -45,11 +45,11 @@ QList<TagModel* > MPCMetaDataModel::tags() const return m_tags; } -MPCFileTagModel::MPCFileTagModel(TagLib::MPC::File *file, TagLib::MPC::File::TagTypes tagType) - : TagModel() +MPCFileTagModel::MPCFileTagModel(TagLib::MPC::File *file, TagLib::MPC::File::TagTypes tagType): TagModel(), + m_file(file), + m_tagType(tagType) { - m_tagType = tagType; - m_file = file; + if (m_tagType == TagLib::MPC::File::ID3v1) { m_tag = m_file->ID3v1Tag(); diff --git a/src/plugins/Input/mpeg/decoder_mad.cpp b/src/plugins/Input/mpeg/decoder_mad.cpp index f6645119d..58f48f680 100644 --- a/src/plugins/Input/mpeg/decoder_mad.cpp +++ b/src/plugins/Input/mpeg/decoder_mad.cpp @@ -3,7 +3,7 @@ * * * Copyright (c) 2000-2001 Brad Hughes <bhughes@trolltech.com> * * Copyright (C) 2000-2004 Robert Leslie <rob@mars.org> * - * Copyright (C) 2009-2018 Ilya Kotov forkotov02@ya.ru * + * Copyright (C) 2009-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 * @@ -34,20 +34,7 @@ #define INPUT_BUFFER_SIZE (32*1024) DecoderMAD::DecoderMAD(QIODevice *i) : Decoder(i) -{ - m_inited = false; - m_totalTime = 0; - m_channels = 0; - m_bitrate = 0; - m_freq = 0; - m_len = 0; - m_input_buf = nullptr; - m_input_bytes = 0; - m_skip_frames = 0; - m_eof = false; - m_skip_bytes = 0; - m_play_bytes = -1; -} +{} DecoderMAD::~DecoderMAD() { diff --git a/src/plugins/Input/mpeg/decoder_mad.h b/src/plugins/Input/mpeg/decoder_mad.h index bd986b80f..d8640634c 100644 --- a/src/plugins/Input/mpeg/decoder_mad.h +++ b/src/plugins/Input/mpeg/decoder_mad.h @@ -3,7 +3,7 @@ * * * Copyright (c) 2000-2001 Brad Hughes <bhughes@trolltech.com> * * Copyright (C) 2000-2004 Robert Leslie <rob@mars.org> * - * Copyright (C) 2009-2018 Ilya Kotov forkotov02@ya.ru * + * Copyright (C) 2009-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 * @@ -31,7 +31,7 @@ class DecoderMAD : public Decoder { public: - DecoderMAD(QIODevice *i); + explicit DecoderMAD(QIODevice *i); virtual ~DecoderMAD(); // standard decoder API @@ -61,36 +61,28 @@ private: bool findXingHeader(struct mad_bitptr, unsigned int bitlen); LameHeader *findLameHeader(struct mad_bitptr ptr, unsigned int bitlen); uint findID3v2(uchar *data, ulong size); - bool m_inited, m_eof; - qint64 m_totalTime; - int m_channels, m_skip_frames; - uint m_bitrate; - long m_freq, m_len; + + bool m_inited = false, m_eof = false; + qint64 m_totalTime = 0; + int m_channels = 0, m_skip_frames = 0; + uint m_bitrate = 0; + long m_freq = 0, m_len = 0; // file input buffer - char *m_input_buf; - qint64 m_input_bytes; + char *m_input_buf = nullptr; + qint64 m_input_bytes = 0; // MAD decoder //xing header struct XingHeader { - int flags; - unsigned long frames; - unsigned long bytes; - unsigned char toc[100]; - long scale; - LameHeader *lame; - - XingHeader() - { - flags = 0; - frames = 0; - bytes = 0; - scale = 0; - lame = nullptr; - } + int flags = 0; + unsigned long frames = 0; + unsigned long bytes = 0; + unsigned char toc[100] = { 0 }; + long scale = 0; + LameHeader *lame = nullptr; }; XingHeader m_xing; @@ -105,7 +97,7 @@ private: struct mad_stream m_stream; struct mad_frame m_frame; struct mad_synth m_synth; - qint64 m_skip_bytes, m_play_bytes; + qint64 m_skip_bytes = 0, m_play_bytes = -1; }; diff --git a/src/plugins/Input/mpeg/decoder_mpg123.cpp b/src/plugins/Input/mpeg/decoder_mpg123.cpp index e359f455d..a830c2c0c 100644 --- a/src/plugins/Input/mpeg/decoder_mpg123.cpp +++ b/src/plugins/Input/mpeg/decoder_mpg123.cpp @@ -29,13 +29,13 @@ ssize_t mpg123_read_cb (void *src, void *buf, size_t size) { - DecoderMPG123 *d = (DecoderMPG123 *) src; + DecoderMPG123 *d = static_cast<DecoderMPG123 *>(src); return d->input()->read((char *)buf, size); } off_t mpg123_seek_cb(void *src, off_t offset, int whence) { - DecoderMPG123 *d = (DecoderMPG123 *) src; + DecoderMPG123 *d = static_cast<DecoderMPG123 *>(src); if (d->input()->isSequential()) return -1; @@ -61,14 +61,7 @@ off_t mpg123_seek_cb(void *src, off_t offset, int whence) } DecoderMPG123::DecoderMPG123(QIODevice *i) : Decoder(i) -{ - m_totalTime = 0; - m_rate = 0; - m_frame_info.bitrate = 0; - m_mpg123_encoding = MPG123_ENC_SIGNED_16; - m_handle = nullptr; - m_errors = 0; -} +{} DecoderMPG123::~DecoderMPG123() { diff --git a/src/plugins/Input/mpeg/decoder_mpg123.h b/src/plugins/Input/mpeg/decoder_mpg123.h index 80f4a61ac..a72d7e15a 100644 --- a/src/plugins/Input/mpeg/decoder_mpg123.h +++ b/src/plugins/Input/mpeg/decoder_mpg123.h @@ -30,7 +30,7 @@ class QIODevice; class DecoderMPG123 : public Decoder { public: - DecoderMPG123(QIODevice *i); + explicit DecoderMPG123(QIODevice *i); virtual ~DecoderMPG123(); // standard decoder API @@ -43,12 +43,12 @@ public: private: void cleanup(mpg123_handle *handle); void setMPG123Format(int encoding); - mpg123_handle *m_handle; + mpg123_handle *m_handle = nullptr; mpg123_frameinfo m_frame_info; - qint64 m_totalTime; - long m_rate; - int m_mpg123_encoding; - int m_errors; + qint64 m_totalTime = 0; + long m_rate = 0; + int m_mpg123_encoding = MPG123_ENC_SIGNED_16; + int m_errors = 0; }; diff --git a/src/plugins/Input/mpeg/mpegmetadatamodel.cpp b/src/plugins/Input/mpeg/mpegmetadatamodel.cpp index 31b6bad07..a9ecad0ce 100644 --- a/src/plugins/Input/mpeg/mpegmetadatamodel.cpp +++ b/src/plugins/Input/mpeg/mpegmetadatamodel.cpp @@ -146,11 +146,11 @@ void MPEGMetaDataModel::removeCover() } MpegFileTagModel::MpegFileTagModel(bool using_rusxmms, TagLib::MPEG::File *file, TagLib::MPEG::File::TagTypes tagType) - : TagModel() + : TagModel(), + m_using_rusxmms(using_rusxmms), + m_file(file), + m_tagType(tagType) { - m_tagType = tagType; - m_file = file; - m_using_rusxmms = using_rusxmms; QSettings settings(Qmmp::configFile(), QSettings::IniFormat); settings.beginGroup("MPEG"); if (m_tagType == TagLib::MPEG::File::ID3v1) diff --git a/src/plugins/Input/mpeg/settingsdialog.h b/src/plugins/Input/mpeg/settingsdialog.h index 26a5f23da..d2faf9b67 100644 --- a/src/plugins/Input/mpeg/settingsdialog.h +++ b/src/plugins/Input/mpeg/settingsdialog.h @@ -30,7 +30,7 @@ class SettingsDialog : public QDialog { Q_OBJECT public: - SettingsDialog(bool using_rusxmms, QWidget *parent = nullptr); + explicit SettingsDialog(bool using_rusxmms, QWidget *parent = nullptr); ~SettingsDialog(); diff --git a/src/plugins/Input/mpeg/tagextractor.cpp b/src/plugins/Input/mpeg/tagextractor.cpp index e94a1368f..715cc1ace 100644 --- a/src/plugins/Input/mpeg/tagextractor.cpp +++ b/src/plugins/Input/mpeg/tagextractor.cpp @@ -29,11 +29,8 @@ #include "tagextractor.h" -TagExtractor::TagExtractor(QIODevice *d) -{ - m_d = d; -} - +TagExtractor::TagExtractor(QIODevice *d) : m_d(d) +{} TagExtractor::~TagExtractor() { @@ -100,14 +97,19 @@ const QMap<Qmmp::MetaData, QString> TagExtractor::id3v2tag() return m_tag; } -ID3v2Tag::ID3v2Tag(QByteArray *array, long offset) : TagLib::ID3v2::Tag() +ID3v2Tag::ID3v2Tag(QByteArray *array, long offset) : TagLib::ID3v2::Tag(), + m_offset(offset) { m_buf = new QBuffer(array); m_buf->open(QIODevice::ReadOnly); - m_offset = offset; read(); } +ID3v2Tag::~ID3v2Tag() +{ + delete m_buf; +} + void ID3v2Tag::read () { m_buf->seek(m_offset); diff --git a/src/plugins/Input/mpeg/tagextractor.h b/src/plugins/Input/mpeg/tagextractor.h index cabccf4b8..45280daf9 100644 --- a/src/plugins/Input/mpeg/tagextractor.h +++ b/src/plugins/Input/mpeg/tagextractor.h @@ -40,7 +40,7 @@ class QByteArray; class TagExtractor { public: - TagExtractor(QIODevice *d); + explicit TagExtractor(QIODevice *d); ~TagExtractor(); @@ -56,9 +56,10 @@ class ID3v2Tag : public TagLib::ID3v2::Tag { public: ID3v2Tag(QByteArray *array, long offset); + ~ID3v2Tag(); protected: - void read (); + void read(); private: QBuffer *m_buf; diff --git a/src/plugins/Input/opus/decoder_opus.cpp b/src/plugins/Input/opus/decoder_opus.cpp index 5a6ffdb78..0f6cca847 100644 --- a/src/plugins/Input/opus/decoder_opus.cpp +++ b/src/plugins/Input/opus/decoder_opus.cpp @@ -27,13 +27,13 @@ // ic functions for libopusfile static int opusread (void *src, unsigned char *buf,int size) { - DecoderOpus *d = (DecoderOpus *) src; + DecoderOpus *d = static_cast<DecoderOpus *>(src); return d->input()->read((char *) buf, size); } static int opusseek(void *src, opus_int64 offset, int whence) { - DecoderOpus *d = (DecoderOpus *) src; + DecoderOpus *d = static_cast<DecoderOpus *>(src); if (d->input()->isSequential()) return -1; long start = 0; @@ -57,21 +57,16 @@ static int opusseek(void *src, opus_int64 offset, int whence) return -1; } -static opus_int64 opustell(void *src) +static opus_int64 opustell(void *src) { - DecoderOpus *dogg = (DecoderOpus *) src; - return (long) dogg->input()->pos(); + DecoderOpus *d = static_cast<DecoderOpus *>(src); + return (opus_int64)d->input()->pos(); } // Decoder class -DecoderOpus::DecoderOpus(const QString &url, QIODevice *i) : Decoder(i) -{ - m_totalTime = 0; - m_opusfile = nullptr; - m_chan = 0; - m_bitrate = 0; - m_url = url; -} +DecoderOpus::DecoderOpus(const QString &url, QIODevice *i) : Decoder(i), + m_url(url) +{} DecoderOpus::~DecoderOpus() { diff --git a/src/plugins/Input/opus/decoder_opus.h b/src/plugins/Input/opus/decoder_opus.h index b31492938..f2abbffcf 100644 --- a/src/plugins/Input/opus/decoder_opus.h +++ b/src/plugins/Input/opus/decoder_opus.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2013-2016 by Ilya Kotov * + * Copyright (C) 2013-2020 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -44,10 +44,10 @@ private: // helper functions ChannelMap findChannelMap(int channels); - OggOpusFile *m_opusfile; - qint64 m_totalTime; - int m_bitrate; - int m_chan; + OggOpusFile *m_opusfile = nullptr; + qint64 m_totalTime = 0; + int m_bitrate = 0; + int m_chan = 0; QString m_url; }; diff --git a/src/plugins/Input/opus/opusmetadatamodel.cpp b/src/plugins/Input/opus/opusmetadatamodel.cpp index c847f2587..bc132a5a6 100644 --- a/src/plugins/Input/opus/opusmetadatamodel.cpp +++ b/src/plugins/Input/opus/opusmetadatamodel.cpp @@ -30,12 +30,12 @@ OpusMetaDataModel::OpusMetaDataModel(const QString &path, bool readOnly) #ifdef HAS_PICTURE_LIST - : MetaDataModel(readOnly, MetaDataModel::IsCoverEditable) + : MetaDataModel(readOnly, MetaDataModel::IsCoverEditable), #else - : MetaDataModel(readOnly) + : MetaDataModel(readOnly), #endif + m_path(path) { - m_path = path; m_stream = new TagLib::FileStream(QStringToFileName(path), readOnly); m_file = new TagLib::Ogg::Opus::File(m_stream); m_tags << new VorbisCommentModel(m_file); diff --git a/src/plugins/Input/opus/opusmetadatamodel.h b/src/plugins/Input/opus/opusmetadatamodel.h index f0dc88f42..725cb100b 100644 --- a/src/plugins/Input/opus/opusmetadatamodel.h +++ b/src/plugins/Input/opus/opusmetadatamodel.h @@ -54,7 +54,7 @@ private: class VorbisCommentModel : public TagModel { public: - VorbisCommentModel(TagLib::Ogg::Opus::File *file); + explicit VorbisCommentModel(TagLib::Ogg::Opus::File *file); ~VorbisCommentModel(); QString name() const override; QString value(Qmmp::MetaData key) const override; diff --git a/src/plugins/Input/sid/decoder_sid.cpp b/src/plugins/Input/sid/decoder_sid.cpp index 31994a2cc..2a6c8e566 100644 --- a/src/plugins/Input/sid/decoder_sid.cpp +++ b/src/plugins/Input/sid/decoder_sid.cpp @@ -32,15 +32,12 @@ #include "decoder_sid.h" // Decoder class -DecoderSID::DecoderSID(SidDatabase *db, const QString &url) : Decoder(), m_tune(nullptr) -{ - m_db = db; - m_url = url; - m_player = new sidplayfp(); - m_length = 0; - m_length_in_bytes = 0; - m_read_bytes = 0; -} +DecoderSID::DecoderSID(SidDatabase *db, const QString &url) : Decoder(), + m_url(url), + m_player(new sidplayfp()), + m_db(db), + m_tune(nullptr) +{} DecoderSID::~DecoderSID() { diff --git a/src/plugins/Input/sid/decoder_sid.h b/src/plugins/Input/sid/decoder_sid.h index a97f90ba6..36dd9bbc1 100644 --- a/src/plugins/Input/sid/decoder_sid.h +++ b/src/plugins/Input/sid/decoder_sid.h @@ -47,9 +47,9 @@ private: QString m_url; sidplayfp *m_player; SidDatabase *m_db; - int m_length; - qint64 m_length_in_bytes; - qint64 m_read_bytes; + int m_length = 0; + qint64 m_length_in_bytes = 0; + qint64 m_read_bytes = 0; SidTune m_tune; }; diff --git a/src/plugins/Input/sid/settingsdialog.cpp b/src/plugins/Input/sid/settingsdialog.cpp index dc247d97b..9b028f156 100644 --- a/src/plugins/Input/sid/settingsdialog.cpp +++ b/src/plugins/Input/sid/settingsdialog.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2013-2016 by Ilya Kotov * + * Copyright (C) 2013-2020 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -24,9 +24,9 @@ #include <sidplayfp/SidConfig.h> #include "settingsdialog.h" -SettingsDialog::SettingsDialog(SidDatabase *db, QWidget *parent) : QDialog(parent) +SettingsDialog::SettingsDialog(SidDatabase *db, QWidget *parent) : QDialog(parent), + m_db(db) { - m_db = db; m_ui.setupUi(this); setAttribute(Qt::WA_DeleteOnClose); diff --git a/src/plugins/Input/sid/settingsdialog.h b/src/plugins/Input/sid/settingsdialog.h index 42a501176..5749e23fc 100644 --- a/src/plugins/Input/sid/settingsdialog.h +++ b/src/plugins/Input/sid/settingsdialog.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2013 by Ilya Kotov * + * Copyright (C) 2013-2020 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -31,7 +31,7 @@ class SettingsDialog : public QDialog { Q_OBJECT public: - SettingsDialog(SidDatabase *db, QWidget *parent = nullptr); + explicit SettingsDialog(SidDatabase *db, QWidget *parent = nullptr); virtual ~SettingsDialog(); diff --git a/src/plugins/Input/sid/sidhelper.cpp b/src/plugins/Input/sid/sidhelper.cpp index e619cdfc4..701f269a6 100644 --- a/src/plugins/Input/sid/sidhelper.cpp +++ b/src/plugins/Input/sid/sidhelper.cpp @@ -22,11 +22,8 @@ #include <sidplayfp/SidDatabase.h> #include "sidhelper.h" -SIDHelper::SIDHelper(SidDatabase *db) -{ - m_tune = nullptr; - m_db = db; -} +SIDHelper::SIDHelper(SidDatabase *db) : m_db(db) +{} SIDHelper::~SIDHelper() { diff --git a/src/plugins/Input/sid/sidhelper.h b/src/plugins/Input/sid/sidhelper.h index f25a20ff5..9357021cc 100644 --- a/src/plugins/Input/sid/sidhelper.h +++ b/src/plugins/Input/sid/sidhelper.h @@ -34,14 +34,14 @@ class SIDHelper { public: - SIDHelper(SidDatabase *db); + explicit SIDHelper(SidDatabase *db); ~SIDHelper(); SidTune *load(const QString &url); QList<TrackInfo *> createPlayList(TrackInfo::Parts parts); private: QString m_path; - SidTune *m_tune; + SidTune *m_tune = nullptr; SidDatabase *m_db; }; diff --git a/src/plugins/Input/sndfile/decoder_sndfile.cpp b/src/plugins/Input/sndfile/decoder_sndfile.cpp index 45607cb24..94e399996 100644 --- a/src/plugins/Input/sndfile/decoder_sndfile.cpp +++ b/src/plugins/Input/sndfile/decoder_sndfile.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2007-2016 by Ilya Kotov * + * Copyright (C) 2007-2020 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -29,7 +29,7 @@ sf_count_t sndfile_sf_vio_get_filelen(void *data) { - return ((QIODevice*) data)->size(); + return static_cast<QIODevice*>(data)->size(); } sf_count_t sndfile_sf_vio_seek(sf_count_t offset, int whence, void *data) @@ -59,7 +59,7 @@ sf_count_t sndfile_sf_vio_seek(sf_count_t offset, int whence, void *data) sf_count_t sndfile_sf_vio_read(void *ptr, sf_count_t count, void *data) { - return ((QIODevice*) data)->read((char *)ptr, count); + return static_cast<QIODevice*>(data)->read((char *)ptr, count); } sf_count_t sndfile_sf_vio_write(const void *, sf_count_t, void *) @@ -69,19 +69,13 @@ sf_count_t sndfile_sf_vio_write(const void *, sf_count_t, void *) sf_count_t sndfile_sf_vio_tell(void *data) { - return ((QIODevice*) data)->pos(); + return static_cast<QIODevice*>(data)->pos(); } // Decoder class DecoderSndFile::DecoderSndFile(QIODevice *input) : Decoder(input) -{ - //m_path = input; - m_bitrate = 0; - m_totalTime = 0; - m_sndfile = nullptr; - m_freq = 0; -} +{} DecoderSndFile::~DecoderSndFile() { diff --git a/src/plugins/Input/sndfile/decoder_sndfile.h b/src/plugins/Input/sndfile/decoder_sndfile.h index d202ad546..d651a87f7 100644 --- a/src/plugins/Input/sndfile/decoder_sndfile.h +++ b/src/plugins/Input/sndfile/decoder_sndfile.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2007-2016 by Ilya Kotov * + * Copyright (C) 2007-2020 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -32,7 +32,7 @@ class DecoderSndFile : public Decoder { public: - DecoderSndFile(QIODevice *input); + explicit DecoderSndFile(QIODevice *input); virtual ~DecoderSndFile(); // Standard Decoder API @@ -43,14 +43,13 @@ public: void seek(qint64 time) override; private: - // helper functions void deinit(); - SNDFILE *m_sndfile; - int m_bitrate; - quint32 m_freq; - qint64 m_totalTime; + SNDFILE *m_sndfile = nullptr; + int m_bitrate = 0; + quint32 m_freq = 0; + qint64 m_totalTime = 0; SF_VIRTUAL_IO m_vio; }; diff --git a/src/plugins/Input/vorbis/decoder_vorbis.cpp b/src/plugins/Input/vorbis/decoder_vorbis.cpp index bcf051c04..cad4a2082 100644 --- a/src/plugins/Input/vorbis/decoder_vorbis.cpp +++ b/src/plugins/Input/vorbis/decoder_vorbis.cpp @@ -16,16 +16,14 @@ // ic functions for OggVorbis static size_t oggread (void *buf, size_t size, size_t nmemb, void *src) { - if (! src) return 0; - - DecoderVorbis *dogg = (DecoderVorbis *) src; + DecoderVorbis *dogg = static_cast<DecoderVorbis *>(src); int len = dogg->input()->read((char *) buf, (size * nmemb)); return len / size; } static int oggseek(void *src, ogg_int64_t offset, int whence) { - DecoderVorbis *dogg = (DecoderVorbis *) src; + DecoderVorbis *dogg = static_cast<DecoderVorbis *>(src); if ( dogg->input()->isSequential ()) return -1; @@ -60,7 +58,7 @@ static int oggclose(void *) static long oggtell(void *src) { - DecoderVorbis *dogg = (DecoderVorbis *) src; + DecoderVorbis *dogg = static_cast<DecoderVorbis *>(src); long t = dogg->input()->pos(); return t; } @@ -68,14 +66,8 @@ static long oggtell(void *src) // Decoder class -DecoderVorbis::DecoderVorbis(QIODevice *i) - : Decoder(i) +DecoderVorbis::DecoderVorbis(QIODevice *i) : Decoder(i) { - m_inited = false; - m_totalTime = 0; - m_last_section = -1; - m_bitrate = 0; - len = 0; memset(&oggfile, 0, sizeof(OggVorbis_File)); } @@ -150,7 +142,6 @@ int DecoderVorbis::bitrate() const return m_bitrate; } - void DecoderVorbis::deinit() { if (m_inited) diff --git a/src/plugins/Input/vorbis/decoder_vorbis.h b/src/plugins/Input/vorbis/decoder_vorbis.h index 8f23236c4..60660e779 100644 --- a/src/plugins/Input/vorbis/decoder_vorbis.h +++ b/src/plugins/Input/vorbis/decoder_vorbis.h @@ -15,7 +15,7 @@ class DecoderVorbis : public Decoder { public: - DecoderVorbis(QIODevice *i); + explicit DecoderVorbis(QIODevice *i); virtual ~DecoderVorbis(); // Standard Decoder API @@ -34,11 +34,11 @@ private: // OggVorbis Decoder OggVorbis_File oggfile; - qint64 m_totalTime; - long len; - int m_last_section; - int m_bitrate; - bool m_inited; + qint64 m_totalTime = 0; + long len = 0; + int m_last_section = -1; + int m_bitrate = 0; + bool m_inited = false; }; diff --git a/src/plugins/Input/vorbis/vorbismetadatamodel.cpp b/src/plugins/Input/vorbis/vorbismetadatamodel.cpp index 9c1117c6c..3ff4c8c46 100644 --- a/src/plugins/Input/vorbis/vorbismetadatamodel.cpp +++ b/src/plugins/Input/vorbis/vorbismetadatamodel.cpp @@ -30,12 +30,12 @@ VorbisMetaDataModel::VorbisMetaDataModel(const QString &path, bool readOnly) #ifdef HAS_PICTURE_LIST - : MetaDataModel(readOnly, MetaDataModel::IsCoverEditable) + : MetaDataModel(readOnly, MetaDataModel::IsCoverEditable), #else - : MetaDataModel(readOnly) + : MetaDataModel(readOnly), #endif + m_path(path) { - m_path = path; m_stream = new TagLib::FileStream(QStringToFileName(path), readOnly); m_file = new TagLib::Ogg::Vorbis::File(m_stream); m_tag = m_file->tag(); diff --git a/src/plugins/Input/vorbis/vorbismetadatamodel.h b/src/plugins/Input/vorbis/vorbismetadatamodel.h index e773ef6d5..064c9da39 100644 --- a/src/plugins/Input/vorbis/vorbismetadatamodel.h +++ b/src/plugins/Input/vorbis/vorbismetadatamodel.h @@ -58,7 +58,7 @@ private: class VorbisCommentModel : public TagModel { public: - VorbisCommentModel(VorbisMetaDataModel *model); + explicit VorbisCommentModel(VorbisMetaDataModel *model); ~VorbisCommentModel(); QString name() const override; QString value(Qmmp::MetaData key) const override; diff --git a/src/plugins/Input/wavpack/decoder_wavpack.cpp b/src/plugins/Input/wavpack/decoder_wavpack.cpp index db0dad1c2..c134e6659 100644 --- a/src/plugins/Input/wavpack/decoder_wavpack.cpp +++ b/src/plugins/Input/wavpack/decoder_wavpack.cpp @@ -31,11 +31,9 @@ // Decoder class -DecoderWavPack::DecoderWavPack(const QString &path) - : Decoder() -{ - m_path = path; -} +DecoderWavPack::DecoderWavPack(const QString &path) : Decoder(), + m_path(path) +{} DecoderWavPack::~DecoderWavPack() { diff --git a/src/plugins/Input/wavpack/decoder_wavpack.h b/src/plugins/Input/wavpack/decoder_wavpack.h index 503aed11c..14fd58eea 100644 --- a/src/plugins/Input/wavpack/decoder_wavpack.h +++ b/src/plugins/Input/wavpack/decoder_wavpack.h @@ -31,7 +31,7 @@ class CueParser; class DecoderWavPack : public Decoder { public: - DecoderWavPack(const QString &); + explicit DecoderWavPack(const QString &); virtual ~DecoderWavPack(); // Standard Decoder API diff --git a/src/plugins/Input/wavpack/wavpackmetadatamodel.cpp b/src/plugins/Input/wavpack/wavpackmetadatamodel.cpp index 414d27d70..bbb56d0a1 100644 --- a/src/plugins/Input/wavpack/wavpackmetadatamodel.cpp +++ b/src/plugins/Input/wavpack/wavpackmetadatamodel.cpp @@ -22,10 +22,9 @@ #include <qmmp/metadatamanager.h> #include "wavpackmetadatamodel.h" -WavPackMetaDataModel::WavPackMetaDataModel(const QString &path, bool readOnly) - : MetaDataModel(readOnly) +WavPackMetaDataModel::WavPackMetaDataModel(const QString &path, bool readOnly) : MetaDataModel(readOnly), + m_path(path) { - m_path = path; if(m_path.contains("://")) { m_path.remove("wvpack://"); @@ -82,10 +81,9 @@ QString WavPackMetaDataModel::coverPath() const return MetaDataManager::instance()->findCoverFile(m_path); } -WavPackFileTagModel::WavPackFileTagModel(WavpackContext *ctx) : TagModel(TagModel::Save) -{ - m_ctx = ctx; -} +WavPackFileTagModel::WavPackFileTagModel(WavpackContext *ctx) : TagModel(TagModel::Save), + m_ctx(ctx) +{} WavPackFileTagModel::~WavPackFileTagModel() {} diff --git a/src/plugins/Input/wavpack/wavpackmetadatamodel.h b/src/plugins/Input/wavpack/wavpackmetadatamodel.h index 8ec8db536..af95a885f 100644 --- a/src/plugins/Input/wavpack/wavpackmetadatamodel.h +++ b/src/plugins/Input/wavpack/wavpackmetadatamodel.h @@ -45,7 +45,7 @@ private: class WavPackFileTagModel : public TagModel { public: - WavPackFileTagModel(WavpackContext *ctx); + explicit WavPackFileTagModel(WavpackContext *ctx); ~WavPackFileTagModel(); QString name() const override; QString value(Qmmp::MetaData key) const override; @@ -54,7 +54,6 @@ public: private: WavpackContext *m_ctx; - QString m_path; }; #endif // WAVPACKMETADATAMODEL_H diff --git a/src/plugins/Input/wildmidi/decoder_wildmidi.cpp b/src/plugins/Input/wildmidi/decoder_wildmidi.cpp index f3c2e459c..7ff0c2690 100644 --- a/src/plugins/Input/wildmidi/decoder_wildmidi.cpp +++ b/src/plugins/Input/wildmidi/decoder_wildmidi.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2016 by Ilya Kotov * + * Copyright (C) 2008-2020 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -23,12 +23,9 @@ #include "decoder_wildmidi.h" // Decoder class -DecoderWildMidi::DecoderWildMidi(const QString &path) : Decoder() -{ - m_path = path; - midi_ptr = nullptr; - m_sample_rate = 0; -} +DecoderWildMidi::DecoderWildMidi(const QString &path) : Decoder(), + m_path(path) +{} DecoderWildMidi::~DecoderWildMidi() { diff --git a/src/plugins/Input/wildmidi/decoder_wildmidi.h b/src/plugins/Input/wildmidi/decoder_wildmidi.h index 0f2ded8c4..5931ed21e 100644 --- a/src/plugins/Input/wildmidi/decoder_wildmidi.h +++ b/src/plugins/Input/wildmidi/decoder_wildmidi.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2016 by Ilya Kotov * + * Copyright (C) 2008-2020 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -29,7 +29,7 @@ extern "C"{ class DecoderWildMidi : public Decoder { public: - DecoderWildMidi(const QString &path); + explicit DecoderWildMidi(const QString &path); virtual ~DecoderWildMidi(); // Standard Decoder API @@ -40,9 +40,9 @@ public: void seek(qint64) override; private: - void *midi_ptr; - qint64 m_totalTime; - quint32 m_sample_rate; + void *midi_ptr = nullptr; + qint64 m_totalTime = 0; + quint32 m_sample_rate = 0; QString m_path; }; diff --git a/src/plugins/Input/wildmidi/wildmidihelper.cpp b/src/plugins/Input/wildmidi/wildmidihelper.cpp index 186389b7d..3af943ba6 100644 --- a/src/plugins/Input/wildmidi/wildmidihelper.cpp +++ b/src/plugins/Input/wildmidi/wildmidihelper.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010-2013 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 * @@ -31,8 +31,6 @@ WildMidiHelper *WildMidiHelper::m_instance = nullptr; WildMidiHelper::WildMidiHelper(QObject *parent) : QObject(parent) { - m_inited = false; - m_sample_rate = 0; m_instance = this; } diff --git a/src/plugins/Input/wildmidi/wildmidihelper.h b/src/plugins/Input/wildmidi/wildmidihelper.h index 7d50775c7..b81d9eb27 100644 --- a/src/plugins/Input/wildmidi/wildmidihelper.h +++ b/src/plugins/Input/wildmidi/wildmidihelper.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010-2013 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 * @@ -41,10 +41,10 @@ public: private: static WildMidiHelper *m_instance; - bool m_inited; + bool m_inited = false; QMutex m_mutex; QList <void *> m_ptrs; - quint32 m_sample_rate; + quint32 m_sample_rate = 0; }; #endif // WILDMIDIHELPER_H |
