diff --git a/client/browseZeroConf/browseAvahi.cpp b/client/browseZeroConf/browseAvahi.cpp index 78084909..ac2068a1 100644 --- a/client/browseZeroConf/browseAvahi.cpp +++ b/client/browseZeroConf/browseAvahi.cpp @@ -27,10 +27,10 @@ #include -static AvahiSimplePoll* simple_poll = NULL; +static AvahiSimplePoll* simple_poll = nullptr; -BrowseAvahi::BrowseAvahi() : client_(NULL), sb_(NULL) +BrowseAvahi::BrowseAvahi() : client_(nullptr), sb_(nullptr) { } @@ -45,15 +45,15 @@ void BrowseAvahi::cleanUp() { if (sb_) avahi_service_browser_free(sb_); - sb_ = NULL; + sb_ = nullptr; if (client_) avahi_client_free(client_); - client_ = NULL; + client_ = nullptr; if (simple_poll) avahi_simple_poll_free(simple_poll); - simple_poll = NULL; + simple_poll = nullptr; } @@ -180,7 +180,7 @@ bool BrowseAvahi::browse(const std::string& serviceName, mDNSResult& result, int /* Create the service browser */ if (!(sb_ = - avahi_service_browser_new(client_, AVAHI_IF_UNSPEC, AVAHI_PROTO_INET, serviceName.c_str(), NULL, (AvahiLookupFlags)0, browse_callback, this))) + avahi_service_browser_new(client_, AVAHI_IF_UNSPEC, AVAHI_PROTO_INET, serviceName.c_str(), nullptr, (AvahiLookupFlags)0, browse_callback, this))) throw SnapException("BrowseAvahi - Failed to create service browser: " + std::string(avahi_strerror(avahi_client_errno(client_)))); result_.valid = false; diff --git a/client/clientConnection.cpp b/client/clientConnection.cpp index f66ee002..6bc7ef94 100644 --- a/client/clientConnection.cpp +++ b/client/clientConnection.cpp @@ -29,7 +29,7 @@ using namespace std; ClientConnection::ClientConnection(MessageReceiver* receiver, const std::string& host, size_t port) - : socket_(nullptr), active_(false), connected_(false), messageReceiver_(receiver), reqId_(1), host_(host), port_(port), readerThread_(NULL), + : socket_(nullptr), active_(false), connected_(false), messageReceiver_(receiver), reqId_(1), host_(host), port_(port), readerThread_(nullptr), sumTimeout_(chronos::msec(0)) { } @@ -116,7 +116,7 @@ void ClientConnection::stop() catch (...) { } - readerThread_ = NULL; + readerThread_ = nullptr; socket_.reset(); LOG(DEBUG) << "readerThread terminated\n"; } @@ -142,7 +142,7 @@ bool ClientConnection::send(const msg::BaseMessage* message) const shared_ptr ClientConnection::sendRequest(const msg::BaseMessage* message, const chronos::msec& timeout) { - shared_ptr response(NULL); + shared_ptr response(nullptr); if (++reqId_ >= 10000) reqId_ = 1; message->id = reqId_; @@ -209,7 +209,7 @@ void ClientConnection::getNextMessage() } } - if (messageReceiver_ != NULL) + if (messageReceiver_ != nullptr) messageReceiver_->onMessageReceived(this, baseMessage, &buffer[0]); } @@ -226,7 +226,7 @@ void ClientConnection::reader() } catch (const std::exception& e) { - if (messageReceiver_ != NULL) + if (messageReceiver_ != nullptr) messageReceiver_->onException(this, make_shared(e.what())); } catch (...) diff --git a/client/clientConnection.h b/client/clientConnection.h index 7e26403f..4bd58a13 100644 --- a/client/clientConnection.h +++ b/client/clientConnection.h @@ -40,7 +40,7 @@ class ClientConnection; /// Used to synchronize server requests (wait for server response) struct PendingRequest { - PendingRequest(uint16_t reqId) : id(reqId), response(NULL){}; + PendingRequest(uint16_t reqId) : id(reqId), response(nullptr){}; uint16_t id; std::shared_ptr response; @@ -87,7 +87,7 @@ public: { std::shared_ptr reply = sendRequest(message, timeout); if (!reply) - return NULL; + return nullptr; std::shared_ptr msg(new T); msg->deserialize(reply->message, reply->buffer); return msg; diff --git a/client/controller.cpp b/client/controller.cpp index 4ce7e041..ddcb1fbd 100644 --- a/client/controller.cpp +++ b/client/controller.cpp @@ -57,7 +57,7 @@ void Controller::onMessageReceived(ClientConnection* connection, const msg::Base { if (stream_ && decoder_) { - msg::PcmChunk* pcmChunk = new msg::PcmChunk(sampleFormat_, 0); + auto* pcmChunk = new msg::PcmChunk(sampleFormat_, 0); pcmChunk->deserialize(baseMessage, buffer); // LOG(DEBUG) << "chunk: " << pcmChunk->payloadSize << ", sampleFormat: " << sampleFormat_.rate << "\n"; if (decoder_->decode(pcmChunk)) diff --git a/client/controller.h b/client/controller.h index eb2c7415..5fc04dc7 100644 --- a/client/controller.h +++ b/client/controller.h @@ -54,11 +54,11 @@ public: /// Implementation of MessageReceiver. /// ClientConnection passes messages from the server through these callbacks - virtual void onMessageReceived(ClientConnection* connection, const msg::BaseMessage& baseMessage, char* buffer); + void onMessageReceived(ClientConnection* connection, const msg::BaseMessage& baseMessage, char* buffer) override; /// Implementation of MessageReceiver. /// Used for async exception reporting - virtual void onException(ClientConnection* connection, shared_exception_ptr exception); + void onException(ClientConnection* connection, shared_exception_ptr exception) override; private: void worker(); diff --git a/client/decoder/decoder.h b/client/decoder/decoder.h index ca3c131c..742e1ee9 100644 --- a/client/decoder/decoder.h +++ b/client/decoder/decoder.h @@ -28,7 +28,7 @@ class Decoder { public: Decoder(){}; - virtual ~Decoder(){}; + virtual ~Decoder()= default;; virtual bool decode(msg::PcmChunk* chunk) = 0; virtual SampleFormat setHeader(msg::CodecHeader* chunk) = 0; diff --git a/client/decoder/flacDecoder.cpp b/client/decoder/flacDecoder.cpp index 8489f86f..3ee716e8 100644 --- a/client/decoder/flacDecoder.cpp +++ b/client/decoder/flacDecoder.cpp @@ -35,11 +35,11 @@ static void metadata_callback(const FLAC__StreamDecoder* decoder, const FLAC__St static void error_callback(const FLAC__StreamDecoder* decoder, FLAC__StreamDecoderErrorStatus status, void* client_data); -static msg::CodecHeader* flacHeader = NULL; -static msg::PcmChunk* flacChunk = NULL; -static msg::PcmChunk* pcmChunk = NULL; +static msg::CodecHeader* flacHeader = nullptr; +static msg::PcmChunk* flacChunk = nullptr; +static msg::PcmChunk* pcmChunk = nullptr; static SampleFormat sampleFormat; -static FLAC__StreamDecoder* decoder = NULL; +static FLAC__StreamDecoder* decoder = nullptr; @@ -101,11 +101,11 @@ SampleFormat FlacDecoder::setHeader(msg::CodecHeader* chunk) flacHeader = chunk; FLAC__StreamDecoderInitStatus init_status; - if ((decoder = FLAC__stream_decoder_new()) == NULL) + if ((decoder = FLAC__stream_decoder_new()) == nullptr) throw SnapException("ERROR: allocating decoder"); // (void)FLAC__stream_decoder_set_md5_checking(decoder, true); - init_status = FLAC__stream_decoder_init_stream(decoder, read_callback, NULL, NULL, NULL, NULL, write_callback, metadata_callback, error_callback, this); + init_status = FLAC__stream_decoder_init_stream(decoder, read_callback, nullptr, nullptr, nullptr, nullptr, write_callback, metadata_callback, error_callback, this); if (init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK) throw SnapException("ERROR: initializing decoder: " + string(FLAC__StreamDecoderInitStatusString[init_status])); @@ -120,13 +120,13 @@ SampleFormat FlacDecoder::setHeader(msg::CodecHeader* chunk) FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder* decoder, FLAC__byte buffer[], size_t* bytes, void* client_data) { - if (flacHeader != NULL) + if (flacHeader != nullptr) { *bytes = flacHeader->payloadSize; memcpy(buffer, flacHeader->payload, *bytes); - flacHeader = NULL; + flacHeader = nullptr; } - else if (flacChunk != NULL) + else if (flacChunk != nullptr) { // cerr << "read_callback: " << *bytes << ", avail: " << flacChunk->payloadSize << "\n"; static_cast(client_data)->cacheInfo_.isCachedChunk_ = false; @@ -150,7 +150,7 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder* decoder { (void)decoder; - if (pcmChunk != NULL) + if (pcmChunk != nullptr) { size_t bytes = frame->header.blocksize * sampleFormat.frameSize; @@ -162,7 +162,7 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder* decoder for (size_t channel = 0; channel < sampleFormat.channels; ++channel) { - if (buffer[channel] == NULL) + if (buffer[channel] == nullptr) { SLOG(ERROR) << "ERROR: buffer[" << channel << "] is NULL\n"; return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; diff --git a/client/decoder/flacDecoder.h b/client/decoder/flacDecoder.h index 8d85f369..2b34e46f 100644 --- a/client/decoder/flacDecoder.h +++ b/client/decoder/flacDecoder.h @@ -50,9 +50,9 @@ class FlacDecoder : public Decoder { public: FlacDecoder(); - virtual ~FlacDecoder(); - virtual bool decode(msg::PcmChunk* chunk); - virtual SampleFormat setHeader(msg::CodecHeader* chunk); + ~FlacDecoder() override; + bool decode(msg::PcmChunk* chunk) override; + SampleFormat setHeader(msg::CodecHeader* chunk) override; CacheInfo cacheInfo_; std::unique_ptr lastError_; diff --git a/client/decoder/oggDecoder.h b/client/decoder/oggDecoder.h index bc9dddcf..6393142c 100644 --- a/client/decoder/oggDecoder.h +++ b/client/decoder/oggDecoder.h @@ -30,9 +30,9 @@ class OggDecoder : public Decoder { public: OggDecoder(); - virtual ~OggDecoder(); - virtual bool decode(msg::PcmChunk* chunk); - virtual SampleFormat setHeader(msg::CodecHeader* chunk); + ~OggDecoder() override; + bool decode(msg::PcmChunk* chunk) override; + SampleFormat setHeader(msg::CodecHeader* chunk) override; private: bool decodePayload(msg::PcmChunk* chunk); diff --git a/client/decoder/pcmDecoder.h b/client/decoder/pcmDecoder.h index b0b49cdd..f4c58464 100644 --- a/client/decoder/pcmDecoder.h +++ b/client/decoder/pcmDecoder.h @@ -25,8 +25,8 @@ class PcmDecoder : public Decoder { public: PcmDecoder(); - virtual bool decode(msg::PcmChunk* chunk); - virtual SampleFormat setHeader(msg::CodecHeader* chunk); + bool decode(msg::PcmChunk* chunk) override; + SampleFormat setHeader(msg::CodecHeader* chunk) override; }; diff --git a/client/metadata.h b/client/metadata.h index 14131967..43658081 100644 --- a/client/metadata.h +++ b/client/metadata.h @@ -93,7 +93,7 @@ class MetaStderrAdapter : public MetadataAdapter public: using MetadataAdapter::push; - int push() + int push() override { std::cerr << serialize() << "\n"; return 0; diff --git a/client/player/alsaPlayer.cpp b/client/player/alsaPlayer.cpp index 8dd29b8a..a1c2c081 100644 --- a/client/player/alsaPlayer.cpp +++ b/client/player/alsaPlayer.cpp @@ -26,7 +26,7 @@ using namespace std; -AlsaPlayer::AlsaPlayer(const PcmDevice& pcmDevice, std::shared_ptr stream) : Player(pcmDevice, stream), handle_(NULL), buff_(NULL) +AlsaPlayer::AlsaPlayer(const PcmDevice& pcmDevice, std::shared_ptr stream) : Player(pcmDevice, stream), handle_(nullptr), buff_(nullptr) { } @@ -105,18 +105,18 @@ void AlsaPlayer::initAlsa() if ((pcm = snd_pcm_hw_params_set_channels(handle_, params, channels)) < 0) throw SnapException("Can't set channels number: " + string(snd_strerror(pcm))); - if ((pcm = snd_pcm_hw_params_set_rate_near(handle_, params, &rate, 0)) < 0) + if ((pcm = snd_pcm_hw_params_set_rate_near(handle_, params, &rate, nullptr)) < 0) throw SnapException("Can't set rate: " + string(snd_strerror(pcm))); unsigned int period_time; - snd_pcm_hw_params_get_period_time_max(params, &period_time, 0); + snd_pcm_hw_params_get_period_time_max(params, &period_time, nullptr); if (period_time > PERIOD_TIME) period_time = PERIOD_TIME; unsigned int buffer_time = 4 * period_time; - snd_pcm_hw_params_set_period_time_near(handle_, params, &period_time, 0); - snd_pcm_hw_params_set_buffer_time_near(handle_, params, &buffer_time, 0); + snd_pcm_hw_params_set_period_time_near(handle_, params, &period_time, nullptr); + snd_pcm_hw_params_set_buffer_time_near(handle_, params, &buffer_time, nullptr); // long unsigned int periodsize = stream_->format.msRate() * 50;//2*rate/50; // if ((pcm = snd_pcm_hw_params_set_buffer_size_near(pcm_handle, params, &periodsize)) < 0) @@ -132,17 +132,17 @@ void AlsaPlayer::initAlsa() snd_pcm_hw_params_get_channels(params, &tmp); LOG(DEBUG) << "channels: " << tmp << "\n"; - snd_pcm_hw_params_get_rate(params, &tmp, 0); + snd_pcm_hw_params_get_rate(params, &tmp, nullptr); LOG(DEBUG) << "rate: " << tmp << " bps\n"; /* Allocate buffer to hold single period */ - snd_pcm_hw_params_get_period_size(params, &frames_, 0); + snd_pcm_hw_params_get_period_size(params, &frames_, nullptr); LOG(INFO) << "frames: " << frames_ << "\n"; buff_size = frames_ * format.frameSize; // channels * 2 /* 2 -> sample size */; buff_ = (char*)malloc(buff_size); - snd_pcm_hw_params_get_period_time(params, &tmp, NULL); + snd_pcm_hw_params_get_period_time(params, &tmp, nullptr); LOG(DEBUG) << "period time: " << tmp << "\n"; snd_pcm_sw_params_t* swparams; @@ -158,17 +158,17 @@ void AlsaPlayer::initAlsa() void AlsaPlayer::uninitAlsa() { - if (handle_ != NULL) + if (handle_ != nullptr) { snd_pcm_drain(handle_); snd_pcm_close(handle_); - handle_ = NULL; + handle_ = nullptr; } - if (buff_ != NULL) + if (buff_ != nullptr) { free(buff_); - buff_ = NULL; + buff_ = nullptr; } } @@ -201,7 +201,7 @@ void AlsaPlayer::worker() while (active_) { - if (handle_ == NULL) + if (handle_ == nullptr) { try { @@ -240,7 +240,7 @@ void AlsaPlayer::worker() while (active_ && !stream_->waitForChunk(100)) { LOG(DEBUG) << "Waiting for chunk\n"; - if ((handle_ != NULL) && (chronos::getTickCount() - lastChunkTick > 5000)) + if ((handle_ != nullptr) && (chronos::getTickCount() - lastChunkTick > 5000)) { LOG(NOTICE) << "No chunk received for 5000ms. Closing ALSA.\n"; uninitAlsa(); @@ -253,7 +253,7 @@ void AlsaPlayer::worker() -vector AlsaPlayer::pcm_list(void) +vector AlsaPlayer::pcm_list() { void **hints, **n; char *name, *descr, *io; @@ -264,15 +264,15 @@ vector AlsaPlayer::pcm_list(void) return result; n = hints; size_t idx(0); - while (*n != NULL) + while (*n != nullptr) { name = snd_device_name_get_hint(*n, "NAME"); descr = snd_device_name_get_hint(*n, "DESC"); io = snd_device_name_get_hint(*n, "IOID"); - if (io != NULL && strcmp(io, "Output") != 0) + if (io != nullptr && strcmp(io, "Output") != 0) goto __end; pcmDevice.name = name; - if (descr == NULL) + if (descr == nullptr) { pcmDevice.description = ""; } @@ -284,11 +284,11 @@ vector AlsaPlayer::pcm_list(void) result.push_back(pcmDevice); __end: - if (name != NULL) + if (name != nullptr) free(name); - if (descr != NULL) + if (descr != nullptr) free(descr); - if (io != NULL) + if (io != nullptr) free(io); n++; } diff --git a/client/player/alsaPlayer.h b/client/player/alsaPlayer.h index 9138f706..6c4824c4 100644 --- a/client/player/alsaPlayer.h +++ b/client/player/alsaPlayer.h @@ -31,17 +31,17 @@ class AlsaPlayer : public Player { public: AlsaPlayer(const PcmDevice& pcmDevice, std::shared_ptr stream); - virtual ~AlsaPlayer(); + ~AlsaPlayer() override; /// Set audio volume in range [0..1] - virtual void start(); - virtual void stop(); + void start() override; + void stop() override; /// List the system's audio output devices static std::vector pcm_list(void); protected: - virtual void worker(); + void worker() override; private: void initAlsa(); diff --git a/client/stream.cpp b/client/stream.cpp index 5ef2c3bd..67b25df1 100644 --- a/client/stream.cpp +++ b/client/stream.cpp @@ -262,7 +262,7 @@ bool Stream::getPlayerChunk(void* outputBuffer, const cs::usec& outputBufferDacT if (!chunks_.try_pop(chunk_, outputBufferDacTime)) { LOG(INFO) << "no chunks available\n"; - chunk_ = NULL; + chunk_ = nullptr; sleep_ = cs::usec(0); return false; } @@ -362,7 +362,7 @@ else if (miniBuffer_.full() && (cs::usec(abs(miniBuffer_.median())) > cs::msec(5 updateBuffers(age.count()); // print sync stats - time_t now = time(NULL); + time_t now = time(nullptr); if (now != lastUpdate_) { lastUpdate_ = now; diff --git a/common/message/codecHeader.h b/common/message/codecHeader.h index 8eb496c3..8829ce07 100644 --- a/common/message/codecHeader.h +++ b/common/message/codecHeader.h @@ -35,18 +35,18 @@ public: payload = (char*)malloc(size); } - virtual ~CodecHeader() + ~CodecHeader() override { free(payload); } - virtual void read(std::istream& stream) + void read(std::istream& stream) override { readVal(stream, codec); readVal(stream, &payload, payloadSize); } - virtual uint32_t getSize() const + uint32_t getSize() const override { return sizeof(uint32_t) + codec.size() + sizeof(uint32_t) + payloadSize; } @@ -56,7 +56,7 @@ public: std::string codec; protected: - virtual void doserialize(std::ostream& stream) const + void doserialize(std::ostream& stream) const override { writeVal(stream, codec); writeVal(stream, payload, payloadSize); diff --git a/common/message/hello.h b/common/message/hello.h index f610ddfc..01bac5b7 100644 --- a/common/message/hello.h +++ b/common/message/hello.h @@ -48,9 +48,8 @@ public: msg["SnapStreamProtocolVersion"] = 2; } - virtual ~Hello() - { - } + ~Hello() override + = default; std::string getMacAddress() const { diff --git a/common/message/jsonMessage.h b/common/message/jsonMessage.h index 1f01cd2c..c730d7d4 100644 --- a/common/message/jsonMessage.h +++ b/common/message/jsonMessage.h @@ -36,18 +36,17 @@ public: { } - virtual ~JsonMessage() - { - } + ~JsonMessage() override + = default; - virtual void read(std::istream& stream) + void read(std::istream& stream) override { std::string s; readVal(stream, s); msg = json::parse(s); } - virtual uint32_t getSize() const + uint32_t getSize() const override { return sizeof(uint32_t) + msg.dump().size(); } @@ -56,7 +55,7 @@ public: protected: - virtual void doserialize(std::ostream& stream) const + void doserialize(std::ostream& stream) const override { writeVal(stream, msg.dump()); } diff --git a/common/message/message.h b/common/message/message.h index 8743279f..dffd9b25 100644 --- a/common/message/message.h +++ b/common/message/message.h @@ -127,8 +127,7 @@ struct BaseMessage } virtual ~BaseMessage() - { - } + = default; virtual void read(std::istream& stream) { diff --git a/common/message/pcmChunk.h b/common/message/pcmChunk.h index 68e56a68..a4e6579f 100644 --- a/common/message/pcmChunk.h +++ b/common/message/pcmChunk.h @@ -48,9 +48,8 @@ public: { } - virtual ~PcmChunk() - { - } + ~PcmChunk() override + = default; int readFrames(void* outputBuffer, size_t frameCount) { @@ -60,7 +59,7 @@ public: result = (payloadSize / format.frameSize) - idx_; // logd << ", from: " << format.frameSize*idx << ", to: " << format.frameSize*idx + format.frameSize*result; - if (outputBuffer != NULL) + if (outputBuffer != nullptr) memcpy((char*)outputBuffer, (char*)(payload) + format.frameSize * idx_, format.frameSize * result); idx_ += result; @@ -82,7 +81,7 @@ public: } - virtual chronos::time_point_clk start() const + chronos::time_point_clk start() const override { return chronos::time_point_clk(chronos::sec(timestamp.sec) + chronos::usec(timestamp.usec) + chronos::usec((chronos::usec::rep)(1000000. * ((double)idx_ / (double)format.rate)))); diff --git a/common/message/serverSettings.h b/common/message/serverSettings.h index a23a391c..a926da5a 100644 --- a/common/message/serverSettings.h +++ b/common/message/serverSettings.h @@ -36,9 +36,8 @@ public: setMuted(false); } - virtual ~ServerSettings() - { - } + ~ServerSettings() override + = default; int32_t getBufferMs() { diff --git a/common/message/streamTags.h b/common/message/streamTags.h index c3eee316..62539d38 100644 --- a/common/message/streamTags.h +++ b/common/message/streamTags.h @@ -65,9 +65,8 @@ public: { } - virtual ~StreamTags() - { - } + ~StreamTags() override + = default; }; } diff --git a/common/message/time.h b/common/message/time.h index 43391aeb..59d79483 100644 --- a/common/message/time.h +++ b/common/message/time.h @@ -31,17 +31,16 @@ public: { } - virtual ~Time() - { - } + ~Time() override + = default; - virtual void read(std::istream& stream) + void read(std::istream& stream) override { readVal(stream, latency.sec); readVal(stream, latency.usec); } - virtual uint32_t getSize() const + uint32_t getSize() const override { return sizeof(tv); } @@ -49,7 +48,7 @@ public: tv latency; protected: - virtual void doserialize(std::ostream& stream) const + void doserialize(std::ostream& stream) const override { writeVal(stream, latency.sec); writeVal(stream, latency.usec); diff --git a/common/message/wireChunk.h b/common/message/wireChunk.h index f8c65e71..3ee2d8e8 100644 --- a/common/message/wireChunk.h +++ b/common/message/wireChunk.h @@ -50,19 +50,19 @@ public: memcpy(payload, wireChunk.payload, payloadSize); } - virtual ~WireChunk() + ~WireChunk() override { free(payload); } - virtual void read(std::istream& stream) + void read(std::istream& stream) override { readVal(stream, timestamp.sec); readVal(stream, timestamp.usec); readVal(stream, &payload, payloadSize); } - virtual uint32_t getSize() const + uint32_t getSize() const override { return sizeof(tv) + sizeof(int32_t) + payloadSize; } @@ -77,7 +77,7 @@ public: char* payload; protected: - virtual void doserialize(std::ostream& stream) const + void doserialize(std::ostream& stream) const override { writeVal(stream, timestamp.sec); writeVal(stream, timestamp.usec); diff --git a/common/sampleFormat.cpp b/common/sampleFormat.cpp index 2de06cd7..5351bd36 100644 --- a/common/sampleFormat.cpp +++ b/common/sampleFormat.cpp @@ -31,8 +31,7 @@ using namespace std; SampleFormat::SampleFormat() -{ -} += default; SampleFormat::SampleFormat(const std::string& format) diff --git a/common/snapException.h b/common/snapException.h index 2ca86487..4439c46e 100644 --- a/common/snapException.h +++ b/common/snapException.h @@ -43,12 +43,12 @@ public: { } - virtual ~SnapException() throw() + ~SnapException() throw() override { delete[] text_; } - virtual const char* what() const noexcept + const char* what() const noexcept override { return text_; } @@ -72,9 +72,8 @@ public: } - virtual ~AsyncSnapException() throw() - { - } + ~AsyncSnapException() throw() override + = default; }; diff --git a/common/timeDefs.h b/common/timeDefs.h index 9e6f2221..de97c889 100644 --- a/common/timeDefs.h +++ b/common/timeDefs.h @@ -47,7 +47,7 @@ inline static void timeofday(struct timeval* tv) inline static void systemtimeofday(struct timeval* tv) { - gettimeofday(tv, NULL); + gettimeofday(tv, nullptr); // timeofday(tv); } diff --git a/common/utils.h b/common/utils.h index 8c6cc256..d56930d9 100644 --- a/common/utils.h +++ b/common/utils.h @@ -69,7 +69,7 @@ static std::string execGetOutput(const std::string& cmd) std::string result = ""; while (!feof(pipe.get())) { - if (fgets(buffer, 1024, pipe.get()) != NULL) + if (fgets(buffer, 1024, pipe.get()) != nullptr) result += buffer; } return strutils::trim(result); @@ -182,7 +182,7 @@ static std::string generateUUID() static bool initialized(false); if (!initialized) { - std::srand(std::time(0)); + std::srand(std::time(nullptr)); initialized = true; } std::stringstream ss; diff --git a/common/utils/file_utils.h b/common/utils/file_utils.h index ee7a1e60..ec9f3f64 100644 --- a/common/utils/file_utils.h +++ b/common/utils/file_utils.h @@ -54,7 +54,7 @@ static void do_chown(const std::string& file_path, const std::string& user_name, if (!user_name.empty()) { struct passwd* pwd = getpwnam(user_name.c_str()); - if (pwd == NULL) + if (pwd == nullptr) throw std::runtime_error("Failed to get uid"); uid = pwd->pw_uid; } @@ -62,7 +62,7 @@ static void do_chown(const std::string& file_path, const std::string& user_name, if (!group_name.empty()) { struct group* grp = getgrnam(group_name.c_str()); - if (grp == NULL) + if (grp == nullptr) throw std::runtime_error("Failed to get gid"); gid = grp->gr_gid; } diff --git a/server/config.cpp b/server/config.cpp index 46fec0a0..2b2bbbed 100644 --- a/server/config.cpp +++ b/server/config.cpp @@ -46,7 +46,7 @@ void Config::init(const std::string& root_directory, const std::string& user, co string dir; if (!root_directory.empty()) dir = root_directory; - else if (getenv("HOME") == NULL) + else if (getenv("HOME") == nullptr) dir = "/var/lib/snapserver/"; else dir = getenv("HOME"); @@ -97,10 +97,10 @@ void Config::init(const std::string& root_directory, const std::string& user, co if (j.count("ConfigVersion")) { json jGroups = j["Groups"]; - for (auto it = jGroups.begin(); it != jGroups.end(); ++it) + for (auto & jGroup : jGroups) { GroupPtr group = make_shared(); - group->fromJson(*it); + group->fromJson(jGroup); // if (client->id.empty() || getClientInfo(client->id)) // continue; groups.push_back(group); diff --git a/server/config.h b/server/config.h index 81db9cb2..e5be9583 100644 --- a/server/config.h +++ b/server/config.h @@ -161,8 +161,7 @@ struct Snapcast } virtual ~Snapcast() - { - } + = default; virtual void fromJson(const json& j) { @@ -200,13 +199,13 @@ struct Snapserver : public Snapcast { } - virtual void fromJson(const json& j) + void fromJson(const json& j) override { Snapcast::fromJson(j); controlProtocolVersion = jGet(j, "controlProtocolVersion", 1); } - virtual json toJson() + json toJson() override { json j = Snapcast::toJson(); j["controlProtocolVersion"] = controlProtocolVersion; diff --git a/server/controlServer.cpp b/server/controlServer.cpp index 8f437ea4..24acb5cb 100644 --- a/server/controlServer.cpp +++ b/server/controlServer.cpp @@ -94,7 +94,7 @@ void ControlServer::onMessageReceived(ControlSession* connection, const std::str } else { - if (controlMessageReceiver_ != NULL) + if (controlMessageReceiver_ != nullptr) controlMessageReceiver_->onMessageReceived(connection, message); } } diff --git a/server/controlServer.h b/server/controlServer.h index 13c7eecc..6459b4b2 100644 --- a/server/controlServer.h +++ b/server/controlServer.h @@ -46,17 +46,17 @@ typedef std::shared_ptr socket_ptr; class ControlServer : public ControlMessageReceiver { public: - ControlServer(asio::io_service* io_service, size_t port, ControlMessageReceiver* controlMessageReceiver = NULL); + ControlServer(asio::io_service* io_service, size_t port, ControlMessageReceiver* controlMessageReceiver = nullptr); virtual ~ControlServer(); void start(); void stop(); /// Send a message to all connceted clients - void send(const std::string& message, const ControlSession* excludeSession = NULL); + void send(const std::string& message, const ControlSession* excludeSession = nullptr); /// Clients call this when they receive a message. Implementation of MessageReceiver::onMessageReceived - virtual void onMessageReceived(ControlSession* connection, const std::string& message); + void onMessageReceived(ControlSession* connection, const std::string& message) override; private: void startAccept(); diff --git a/server/controlSession.cpp b/server/controlSession.cpp index 53436bb4..21e549f2 100644 --- a/server/controlSession.cpp +++ b/server/controlSession.cpp @@ -82,7 +82,7 @@ void ControlSession::stop() catch (...) { } - socket_ = NULL; + socket_ = nullptr; LOG(DEBUG) << "ControlSession ControlSession stopped\n"; } @@ -137,7 +137,7 @@ void ControlSession::reader() if ((len >= 2) && line[len - 2] == '\r') --len; line.resize(len); - if ((messageReceiver_ != NULL) && !line.empty()) + if ((messageReceiver_ != nullptr) && !line.empty()) messageReceiver_->onMessageReceived(this, line); } message.str(""); diff --git a/server/encoder/encoder.h b/server/encoder/encoder.h index a58ed8ef..a70dad00 100644 --- a/server/encoder/encoder.h +++ b/server/encoder/encoder.h @@ -50,13 +50,12 @@ class Encoder { public: /// ctor. Codec options (E.g. compression level) are passed as string and are codec dependend - Encoder(const std::string& codecOptions = "") : headerChunk_(NULL), codecOptions_(codecOptions) + Encoder(const std::string& codecOptions = "") : headerChunk_(nullptr), codecOptions_(codecOptions) { } virtual ~Encoder() - { - } + = default; /// The listener will receive the encoded stream virtual void init(EncoderListener* listener, const SampleFormat& format) diff --git a/server/encoder/flacEncoder.cpp b/server/encoder/flacEncoder.cpp index 59d934cd..8a0b7c0e 100644 --- a/server/encoder/flacEncoder.cpp +++ b/server/encoder/flacEncoder.cpp @@ -26,7 +26,7 @@ using namespace std; -FlacEncoder::FlacEncoder(const std::string& codecOptions) : Encoder(codecOptions), encoder_(NULL), pcmBufferSize_(0), encodedSamples_(0) +FlacEncoder::FlacEncoder(const std::string& codecOptions) : Encoder(codecOptions), encoder_(nullptr), pcmBufferSize_(0), encodedSamples_(0) { flacChunk_ = new msg::PcmChunk(); headerChunk_.reset(new msg::CodecHeader("flac")); @@ -36,7 +36,7 @@ FlacEncoder::FlacEncoder(const std::string& codecOptions) : Encoder(codecOptions FlacEncoder::~FlacEncoder() { - if (encoder_ != NULL) + if (encoder_ != nullptr) { FLAC__stream_encoder_finish(encoder_); FLAC__metadata_object_delete(metadata_[0]); @@ -163,7 +163,7 @@ void FlacEncoder::initEncoder() FLAC__StreamMetadata_VorbisComment_Entry entry; // allocate the encoder - if ((encoder_ = FLAC__stream_encoder_new()) == NULL) + if ((encoder_ = FLAC__stream_encoder_new()) == nullptr) throw SnapException("error allocating encoder"); ok &= FLAC__stream_encoder_set_verify(encoder_, true); @@ -181,8 +181,8 @@ void FlacEncoder::initEncoder() throw SnapException("error setting up encoder"); // now add some metadata; we'll add some tags and a padding block - if ((metadata_[0] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT)) == NULL || - (metadata_[1] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING)) == NULL || + if ((metadata_[0] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT)) == nullptr || + (metadata_[1] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING)) == nullptr || // there are many tag (vorbiscomment) functions but these are convenient for this particular use: !FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, "TITLE", "SnapStream") || !FLAC__metadata_object_vorbiscomment_append_comment(metadata_[0], entry, false) || @@ -196,7 +196,7 @@ void FlacEncoder::initEncoder() throw SnapException("error setting meta data"); // initialize encoder - init_status = FLAC__stream_encoder_init_stream(encoder_, ::write_callback, NULL, NULL, NULL, this); + init_status = FLAC__stream_encoder_init_stream(encoder_, ::write_callback, nullptr, nullptr, nullptr, this); if (init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK) throw SnapException("ERROR: initializing encoder: " + string(FLAC__StreamEncoderInitStatusString[init_status])); } diff --git a/server/encoder/flacEncoder.h b/server/encoder/flacEncoder.h index eed3ac4a..6e5de9b0 100644 --- a/server/encoder/flacEncoder.h +++ b/server/encoder/flacEncoder.h @@ -31,17 +31,17 @@ class FlacEncoder : public Encoder { public: FlacEncoder(const std::string& codecOptions = ""); - ~FlacEncoder(); - virtual void encode(const msg::PcmChunk* chunk); - virtual std::string getAvailableOptions() const; - virtual std::string getDefaultOptions() const; - virtual std::string name() const; + ~FlacEncoder() override; + void encode(const msg::PcmChunk* chunk) override; + std::string getAvailableOptions() const override; + std::string getDefaultOptions() const override; + std::string name() const override; FLAC__StreamEncoderWriteStatus write_callback(const FLAC__StreamEncoder* encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame); protected: - virtual void initEncoder(); + void initEncoder() override; FLAC__StreamEncoder* encoder_; FLAC__StreamMetadata* metadata_[2]; diff --git a/server/encoder/oggEncoder.cpp b/server/encoder/oggEncoder.cpp index e3c745a0..f942d48b 100644 --- a/server/encoder/oggEncoder.cpp +++ b/server/encoder/oggEncoder.cpp @@ -86,7 +86,7 @@ void OggEncoder::encode(const msg::PcmChunk* chunk) /* tell the library how much we actually submitted */ vorbis_analysis_wrote(&vd_, frames); - msg::PcmChunk* oggChunk = new msg::PcmChunk(chunk->format, 0); + auto* oggChunk = new msg::PcmChunk(chunk->format, 0); /* vorbis does some data preanalysis, then divvies up blocks for more involved (potentially parallel) processing. Get a single @@ -95,7 +95,7 @@ void OggEncoder::encode(const msg::PcmChunk* chunk) while (vorbis_analysis_blockout(&vd_, &vb_) == 1) { /* analysis, assume we want to use bitrate management */ - vorbis_analysis(&vb_, NULL); + vorbis_analysis(&vb_, nullptr); vorbis_bitrate_addblock(&vb_); while (vorbis_bitrate_flushpacket(&vd_, &op_)) @@ -219,7 +219,7 @@ void OggEncoder::initEncoder() /* set up our packet->stream encoder */ /* pick a random serial number; that way we can more likely build chained streams just by concatenation */ - srand(time(NULL)); + srand(time(nullptr)); ogg_stream_init(&os_, rand()); /* Vorbis streams begin with three headers; the initial header (with diff --git a/server/encoder/oggEncoder.h b/server/encoder/oggEncoder.h index be5df60e..583a45cf 100644 --- a/server/encoder/oggEncoder.h +++ b/server/encoder/oggEncoder.h @@ -26,13 +26,13 @@ class OggEncoder : public Encoder { public: OggEncoder(const std::string& codecOptions = ""); - virtual void encode(const msg::PcmChunk* chunk); - virtual std::string getAvailableOptions() const; - virtual std::string getDefaultOptions() const; - virtual std::string name() const; + void encode(const msg::PcmChunk* chunk) override; + std::string getAvailableOptions() const override; + std::string getDefaultOptions() const override; + std::string name() const override; protected: - virtual void initEncoder(); + void initEncoder() override; private: ogg_stream_state os_; /// take physical pages, weld into a logical stream of packets diff --git a/server/encoder/pcmEncoder.cpp b/server/encoder/pcmEncoder.cpp index 8e25e344..08a574fb 100644 --- a/server/encoder/pcmEncoder.cpp +++ b/server/encoder/pcmEncoder.cpp @@ -35,7 +35,7 @@ PcmEncoder::PcmEncoder(const std::string& codecOptions) : Encoder(codecOptions) void PcmEncoder::encode(const msg::PcmChunk* chunk) { - msg::PcmChunk* pcmChunk = new msg::PcmChunk(*chunk); + auto* pcmChunk = new msg::PcmChunk(*chunk); listener_->onChunkEncoded(this, pcmChunk, pcmChunk->duration().count()); } diff --git a/server/encoder/pcmEncoder.h b/server/encoder/pcmEncoder.h index 0fbd3d86..208abbac 100644 --- a/server/encoder/pcmEncoder.h +++ b/server/encoder/pcmEncoder.h @@ -25,11 +25,11 @@ class PcmEncoder : public Encoder { public: PcmEncoder(const std::string& codecOptions = ""); - virtual void encode(const msg::PcmChunk* chunk); - virtual std::string name() const; + void encode(const msg::PcmChunk* chunk) override; + std::string name() const override; protected: - virtual void initEncoder(); + void initEncoder() override; template void assign(void* pointer, T val) diff --git a/server/publishZeroConf/publishAvahi.cpp b/server/publishZeroConf/publishAvahi.cpp index 7031d3fe..c7282de5 100644 --- a/server/publishZeroConf/publishAvahi.cpp +++ b/server/publishZeroConf/publishAvahi.cpp @@ -27,10 +27,10 @@ static AvahiEntryGroup* group; static AvahiSimplePoll* simple_poll; static char* name; -PublishAvahi::PublishAvahi(const std::string& serviceName) : PublishmDNS(serviceName), client_(NULL), active_(false) +PublishAvahi::PublishAvahi(const std::string& serviceName) : PublishmDNS(serviceName), client_(nullptr), active_(false) { - group = NULL; - simple_poll = NULL; + group = nullptr; + simple_poll = nullptr; name = avahi_strdup(serviceName_.c_str()); } @@ -85,7 +85,7 @@ PublishAvahi::~PublishAvahi() void PublishAvahi::entry_group_callback(AvahiEntryGroup* g, AvahiEntryGroupState state, AVAHI_GCC_UNUSED void* userdata) { - assert(g == group || group == NULL); + assert(g == group || group == nullptr); group = g; /// Called whenever the entry group state changes @@ -149,7 +149,7 @@ void PublishAvahi::create_services(AvahiClient* c) /// We will now add two services and one subtype to the entry group for (const auto& service : services_) { - if ((ret = avahi_entry_group_add_service(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AvahiPublishFlags(0), name, service.name_.c_str(), NULL, NULL, + if ((ret = avahi_entry_group_add_service(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AvahiPublishFlags(0), name, service.name_.c_str(), nullptr, nullptr, service.port_, NULL)) < 0) { if (ret == AVAHI_ERR_COLLISION) diff --git a/server/publishZeroConf/publishAvahi.h b/server/publishZeroConf/publishAvahi.h index 79e02613..cc9135d4 100644 --- a/server/publishZeroConf/publishAvahi.h +++ b/server/publishZeroConf/publishAvahi.h @@ -41,8 +41,8 @@ class PublishAvahi : public PublishmDNS { public: PublishAvahi(const std::string& serviceName); - virtual ~PublishAvahi(); - virtual void publish(const std::vector& services); + ~PublishAvahi() override; + void publish(const std::vector& services) override; private: static void entry_group_callback(AvahiEntryGroup* g, AvahiEntryGroupState state, AVAHI_GCC_UNUSED void* userdata); diff --git a/server/publishZeroConf/publishmDNS.h b/server/publishZeroConf/publishmDNS.h index affd26c4..237deeda 100644 --- a/server/publishZeroConf/publishmDNS.h +++ b/server/publishZeroConf/publishmDNS.h @@ -24,8 +24,7 @@ public: } virtual ~PublishmDNS() - { - } + = default; virtual void publish(const std::vector& services) = 0; diff --git a/server/streamServer.cpp b/server/streamServer.cpp index 79d0a327..f3da1d15 100644 --- a/server/streamServer.cpp +++ b/server/streamServer.cpp @@ -36,8 +36,7 @@ StreamServer::StreamServer(asio::io_service* io_service, const StreamServerSetti StreamServer::~StreamServer() -{ -} += default; void StreamServer::onMetaChanged(const PcmStream* pcmStream) @@ -57,7 +56,7 @@ void StreamServer::onMetaChanged(const PcmStream* pcmStream) LOG(INFO) << "onMetaChanged (" << pcmStream->getName() << ")\n"; json notification = jsonrpcpp::Notification("Stream.OnMetadata", jsonrpcpp::Parameter("id", pcmStream->getId(), "meta", meta->msg)).to_json(); - controlServer_->send(notification.dump(), NULL); + controlServer_->send(notification.dump(), nullptr); ////cout << "Notification: " << notification.dump() << "\n"; } @@ -69,7 +68,7 @@ void StreamServer::onStateChanged(const PcmStream* pcmStream, const ReaderState& LOG(INFO) << "onStateChanged (" << pcmStream->getName() << "): " << state << "\n"; // LOG(INFO) << pcmStream->toJson().dump(4); json notification = jsonrpcpp::Notification("Stream.OnUpdate", jsonrpcpp::Parameter("id", pcmStream->getId(), "stream", pcmStream->toJson())).to_json(); - controlServer_->send(notification.dump(), NULL); + controlServer_->send(notification.dump(), nullptr); ////cout << "Notification: " << notification.dump() << "\n"; } diff --git a/server/streamServer.h b/server/streamServer.h index 3229ede0..5c286036 100644 --- a/server/streamServer.h +++ b/server/streamServer.h @@ -79,17 +79,17 @@ public: // void send(const msg::BaseMessage* message); /// Clients call this when they receive a message. Implementation of MessageReceiver::onMessageReceived - virtual void onMessageReceived(StreamSession* connection, const msg::BaseMessage& baseMessage, char* buffer); - virtual void onDisconnect(StreamSession* connection); + void onMessageReceived(StreamSession* connection, const msg::BaseMessage& baseMessage, char* buffer) override; + void onDisconnect(StreamSession* connection) override; /// Implementation of ControllMessageReceiver::onMessageReceived, called by ControlServer::onMessageReceived - virtual void onMessageReceived(ControlSession* connection, const std::string& message); + void onMessageReceived(ControlSession* connection, const std::string& message) override; /// Implementation of PcmListener - virtual void onMetaChanged(const PcmStream* pcmStream); - virtual void onStateChanged(const PcmStream* pcmStream, const ReaderState& state); - virtual void onChunkRead(const PcmStream* pcmStream, msg::PcmChunk* chunk, double duration); - virtual void onResync(const PcmStream* pcmStream, double ms); + void onMetaChanged(const PcmStream* pcmStream) override; + void onStateChanged(const PcmStream* pcmStream, const ReaderState& state) override; + void onChunkRead(const PcmStream* pcmStream, msg::PcmChunk* chunk, double duration) override; + void onResync(const PcmStream* pcmStream, double ms) override; private: void startAccept(); diff --git a/server/streamSession.cpp b/server/streamSession.cpp index 63e22d60..632760d7 100644 --- a/server/streamSession.cpp +++ b/server/streamSession.cpp @@ -200,7 +200,7 @@ void StreamSession::getNextMessage() tv t; baseMessage.received = t; - if (active_ && (messageReceiver_ != NULL)) + if (active_ && (messageReceiver_ != nullptr)) messageReceiver_->onMessageReceived(this, baseMessage, &buffer[0]); } @@ -219,7 +219,7 @@ void StreamSession::reader() SLOG(ERROR) << "Exception in StreamSession::reader(): " << e.what() << endl; } - if (active_ && (messageReceiver_ != NULL)) + if (active_ && (messageReceiver_ != nullptr)) messageReceiver_->onDisconnect(this); } @@ -238,7 +238,7 @@ void StreamSession::writer() if (bufferMs_ > 0) { const msg::WireChunk* wireChunk = dynamic_cast(message.get()); - if (wireChunk != NULL) + if (wireChunk != nullptr) { chronos::time_point_clk now = chronos::clk::now(); size_t age = 0; @@ -258,6 +258,6 @@ void StreamSession::writer() SLOG(ERROR) << "Exception in StreamSession::writer(): " << e.what() << endl; } - if (active_ && (messageReceiver_ != NULL)) + if (active_ && (messageReceiver_ != nullptr)) messageReceiver_->onDisconnect(this); } diff --git a/server/streamreader/airplayStream.cpp b/server/streamreader/airplayStream.cpp index 38a7de8f..5e17678b 100644 --- a/server/streamreader/airplayStream.cpp +++ b/server/streamreader/airplayStream.cpp @@ -28,7 +28,7 @@ using namespace std; static string hex2str(string input) { typedef unsigned char byte; - unsigned long x = strtoul(input.c_str(), 0, 16); + unsigned long x = strtoul(input.c_str(), nullptr, 16); byte a[] = {byte(x >> 24), byte(x >> 16), byte(x >> 8), byte(x), 0}; return string((char*)a); } diff --git a/server/streamreader/airplayStream.h b/server/streamreader/airplayStream.h index d8a6ae68..4c69f13d 100644 --- a/server/streamreader/airplayStream.h +++ b/server/streamreader/airplayStream.h @@ -57,7 +57,7 @@ class AirplayStream : public ProcessStream public: /// ctor. Encoded PCM data is passed to the PipeListener AirplayStream(PcmListener* pcmListener, const StreamUri& uri); - virtual ~AirplayStream(); + ~AirplayStream() override; protected: #ifdef HAS_EXPAT @@ -74,8 +74,8 @@ protected: void push(); #endif - virtual void onStderrMsg(const char* buffer, size_t n); - virtual void initExeAndPath(const std::string& filename); + void onStderrMsg(const char* buffer, size_t n) override; + void initExeAndPath(const std::string& filename) override; size_t port_; std::string pipePath_; std::string params_wo_port_; diff --git a/server/streamreader/fileStream.h b/server/streamreader/fileStream.h index 333a50b5..2c68ea46 100644 --- a/server/streamreader/fileStream.h +++ b/server/streamreader/fileStream.h @@ -34,10 +34,10 @@ class FileStream : public PcmStream public: /// ctor. Encoded PCM data is passed to the PipeListener FileStream(PcmListener* pcmListener, const StreamUri& uri); - virtual ~FileStream(); + ~FileStream() override; protected: - virtual void worker(); + void worker() override; std::ifstream ifs; }; diff --git a/server/streamreader/pcmStream.h b/server/streamreader/pcmStream.h index 9311f177..a4ced5a8 100644 --- a/server/streamreader/pcmStream.h +++ b/server/streamreader/pcmStream.h @@ -75,7 +75,7 @@ public: virtual void stop(); /// Implementation of EncoderListener::onChunkEncoded - virtual void onChunkEncoded(const Encoder* encoder, msg::PcmChunk* chunk, double duration); + void onChunkEncoded(const Encoder* encoder, msg::PcmChunk* chunk, double duration) override; virtual std::shared_ptr getHeader(); virtual const StreamUri& getUri() const; diff --git a/server/streamreader/pipeStream.h b/server/streamreader/pipeStream.h index dafbe82f..18937b34 100644 --- a/server/streamreader/pipeStream.h +++ b/server/streamreader/pipeStream.h @@ -34,10 +34,10 @@ class PipeStream : public PcmStream public: /// ctor. Encoded PCM data is passed to the PipeListener PipeStream(PcmListener* pcmListener, const StreamUri& uri); - virtual ~PipeStream(); + ~PipeStream() override; protected: - virtual void worker(); + void worker() override; int fd_; }; diff --git a/server/streamreader/processStream.h b/server/streamreader/processStream.h index 883ccd13..78644941 100644 --- a/server/streamreader/processStream.h +++ b/server/streamreader/processStream.h @@ -37,10 +37,10 @@ class ProcessStream : public PcmStream public: /// ctor. Encoded PCM data is passed to the PipeListener ProcessStream(PcmListener* pcmListener, const StreamUri& uri); - virtual ~ProcessStream(); + ~ProcessStream() override; - virtual void start(); - virtual void stop(); + void start() override; + void stop() override; protected: std::string exe_; @@ -50,7 +50,7 @@ protected: std::thread stderrReaderThread_; bool logStderr_; - virtual void worker(); + void worker() override; virtual void stderrReader(); virtual void onStderrMsg(const char* buffer, size_t n); virtual void initExeAndPath(const std::string& filename); diff --git a/server/streamreader/spotifyStream.cpp b/server/streamreader/spotifyStream.cpp index 4968b679..c2183e91 100644 --- a/server/streamreader/spotifyStream.cpp +++ b/server/streamreader/spotifyStream.cpp @@ -64,8 +64,7 @@ SpotifyStream::SpotifyStream(PcmListener* pcmListener, const StreamUri& uri) : P SpotifyStream::~SpotifyStream() -{ -} += default; void SpotifyStream::initExeAndPath(const std::string& filename) diff --git a/server/streamreader/spotifyStream.h b/server/streamreader/spotifyStream.h index 2557c815..8fc647b4 100644 --- a/server/streamreader/spotifyStream.h +++ b/server/streamreader/spotifyStream.h @@ -36,16 +36,16 @@ class SpotifyStream : public ProcessStream, WatchdogListener public: /// ctor. Encoded PCM data is passed to the PipeListener SpotifyStream(PcmListener* pcmListener, const StreamUri& uri); - virtual ~SpotifyStream(); + ~SpotifyStream() override; protected: std::unique_ptr watchdog_; - virtual void stderrReader(); - virtual void onStderrMsg(const char* buffer, size_t n); - virtual void initExeAndPath(const std::string& filename); + void stderrReader() override; + void onStderrMsg(const char* buffer, size_t n) override; + void initExeAndPath(const std::string& filename) override; - virtual void onTimeout(const Watchdog* watchdog, size_t ms); + void onTimeout(const Watchdog* watchdog, size_t ms) override; };