diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 46fc1602..5d0e429c 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -8,7 +8,7 @@ * This project loosely follows the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html) -* For better compatibility with embedded toolchains, the used C++ standard should be limited to C++14 +* For better compatibility with embedded toolchains, the used C++ standard should be limited to C++17 * Code should be formatted by running `make reformat` diff --git a/CMakeLists.txt b/CMakeLists.txt index 4381a71c..5373f658 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,7 +127,7 @@ if(NOT ANDROID) endif() # Configure compiler options -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) # Get arch include(${CMAKE_SOURCE_DIR}/cmake/TargetArch.cmake) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6cdb7cea..af94520c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,7 +46,7 @@ The following rule governs code contributions: * This project loosely follows the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html) -* For better compatibility with embedded toolchains, the used C++ standard should be limited to C++14 +* For better compatibility with embedded toolchains, the used C++ standard should be limited to C++17 * Code should be formatted by running `make reformat` diff --git a/client/Makefile b/client/Makefile index fb825398..735448d4 100644 --- a/client/Makefile +++ b/client/Makefile @@ -42,7 +42,7 @@ ifneq ($(SANITIZE), ) LDFLAGS += -fsanitize=$(SANITIZE) endif -CXXFLAGS += $(ADD_CFLAGS) -std=c++14 -Wall -Wextra -Wpedantic -Wno-unused-function -DBOOST_ERROR_CODE_HEADER_ONLY -DHAS_FLAC -DHAS_OGG -DHAS_OPUS -DHAS_SOXR -DVERSION=\"$(VERSION)\" -I. -I.. -I../common +CXXFLAGS += $(ADD_CFLAGS) -std=c++17 -Wall -Wextra -Wpedantic -Wno-unused-function -DBOOST_ERROR_CODE_HEADER_ONLY -DHAS_FLAC -DHAS_OGG -DHAS_OPUS -DHAS_SOXR -DVERSION=\"$(VERSION)\" -I. -I.. -I../common LDFLAGS += $(ADD_LDFLAGS) -logg -lFLAC -lopus -lsoxr OBJ = snapclient.o stream.o client_connection.o time_provider.o player/player.o player/file_player.o decoder/pcm_decoder.o decoder/ogg_decoder.o decoder/flac_decoder.o decoder/opus_decoder.o controller.o ../common/sample_format.o ../common/resampler.o diff --git a/client/player/alsa_player.hpp b/client/player/alsa_player.hpp index 65eedcd2..6d9ec21f 100644 --- a/client/player/alsa_player.hpp +++ b/client/player/alsa_player.hpp @@ -22,8 +22,8 @@ #include "player.hpp" #include -#include #include +#include namespace player @@ -83,8 +83,8 @@ private: std::recursive_mutex mutex_; boost::asio::steady_timer timer_; - boost::optional buffer_time_; - boost::optional periods_; + std::optional buffer_time_; + std::optional periods_; }; } // namespace player diff --git a/client/player/pulse_player.cpp b/client/player/pulse_player.cpp index fe20a6e5..d6c76a19 100644 --- a/client/player/pulse_player.cpp +++ b/client/player/pulse_player.cpp @@ -136,7 +136,7 @@ vector PulsePlayer::pcm_list(const std::string& parameter) PulsePlayer::PulsePlayer(boost::asio::io_context& io_context, const ClientSettings::Player& settings, std::shared_ptr stream) : Player(io_context, settings, stream), latency_(BUFFER_TIME), pa_ml_(nullptr), pa_ctx_(nullptr), playstream_(nullptr), proplist_(nullptr), - server_(boost::none) + server_(std::nullopt) { auto params = utils::string::split_pairs_to_container>(settings.parameter, ',', '='); if (params.find("buffer_time") != params.end()) diff --git a/client/player/pulse_player.hpp b/client/player/pulse_player.hpp index f414e987..052e8d2c 100644 --- a/client/player/pulse_player.hpp +++ b/client/player/pulse_player.hpp @@ -22,9 +22,9 @@ #include "player.hpp" #include -#include #include #include +#include #include @@ -74,7 +74,7 @@ protected: pa_context* pa_ctx_; pa_stream* playstream_; pa_proplist* proplist_; - boost::optional server_; + std::optional server_; std::map properties_; // cache of the last volume change diff --git a/common/metatags.hpp b/common/metatags.hpp index 0e82da44..6f7145fa 100644 --- a/common/metatags.hpp +++ b/common/metatags.hpp @@ -19,7 +19,7 @@ #ifndef METATAGS_HPP #define METATAGS_HPP -#include +#include #include #include @@ -41,92 +41,92 @@ public: /// https://www.musicpd.org/doc/html/protocol.html#tags /// the duration of the song - boost::optional duration; + std::optional duration; /// the artist name. Its meaning is not well-defined; see “composer” and “performer” for more specific tags. - boost::optional> artist; + std::optional> artist; /// same as artist, but for sorting. This usually omits prefixes such as “The”. - boost::optional> artist_sort; + std::optional> artist_sort; /// the album name. - boost::optional album; + std::optional album; /// same as album, but for sorting. - boost::optional album_sort; + std::optional album_sort; /// on multi-artist albums, this is the artist name which shall be used for the whole album. The exact meaning of this tag is not well-defined. - boost::optional> album_artist; + std::optional> album_artist; /// same as albumartist, but for sorting. - boost::optional> album_artist_sort; + std::optional> album_artist_sort; /// a name for this song. This is not the song title. The exact meaning of this tag is not well-defined. It is often used by badly configured internet radio /// stations with broken tags to squeeze both the artist name and the song title in one tag. - boost::optional name; + std::optional name; /// the song’s release date. This is usually a 4-digit year. - boost::optional date; + std::optional date; /// the song’s original release date. - boost::optional original_date; + std::optional original_date; /// the artist who performed the song. - boost::optional performer; + std::optional performer; /// the conductor who conducted the song. - boost::optional conductor; + std::optional conductor; /// “a work is a distinct intellectual or artistic creation, which can be expressed in the form of one or more audio recordings” - boost::optional work; + std::optional work; /// “used if the sound belongs to a larger category of sounds/music” (from the IDv2.4.0 TIT1 description). - boost::optional grouping; + std::optional grouping; /// the name of the label or publisher. - boost::optional label; + std::optional label; /// the artist id in the MusicBrainz database. - boost::optional musicbrainz_artist_id; + std::optional musicbrainz_artist_id; /// the album id in the MusicBrainz database. - boost::optional musicbrainz_album_id; + std::optional musicbrainz_album_id; /// the album artist id in the MusicBrainz database. - boost::optional musicbrainz_album_artist_id; + std::optional musicbrainz_album_artist_id; /// the track id in the MusicBrainz database. - boost::optional musicbrainz_track_id; + std::optional musicbrainz_track_id; /// the release track id in the MusicBrainz database. - boost::optional musicbrainz_release_track_id; + std::optional musicbrainz_release_track_id; /// the work id in the MusicBrainz database. - boost::optional musicbrainz_work_id; + std::optional musicbrainz_work_id; /// https://www.freedesktop.org/wiki/Specifications/mpris-spec/metadata/ /// A unique identity for this track within the context of an MPRIS object (eg: tracklist). - boost::optional track_id; + std::optional track_id; /// URI: The location of an image representing the track or album. Clients should not assume this will continue to exist when the media player stops giving /// out the URL - boost::optional art_url; + std::optional art_url; /// The track lyrics - boost::optional lyrics; + std::optional lyrics; /// The speed of the music, in beats per minute - boost::optional bpm; + std::optional bpm; /// Float: An automatically-generated rating, based on things such as how often it has been played. This should be in the range 0.0 to 1.0 - boost::optional auto_rating; + std::optional auto_rating; /// A (list of) freeform comment(s) - boost::optional> comment; + std::optional> comment; /// The composer(s) of the track - boost::optional> composer; + std::optional> composer; /// Date/Time: When the track was created. Usually only the year component will be useful - boost::optional content_created; + std::optional content_created; /// Integer: The disc number on the album that this track is from - boost::optional disc_number; + std::optional disc_number; /// Date/Time: When the track was first played - boost::optional first_used; + std::optional first_used; /// List of Strings: The genre(s) of the track - boost::optional> genre; + std::optional> genre; /// Date/Time: When the track was last played - boost::optional last_used; + std::optional last_used; /// List of Strings: The lyricist(s) of the track - boost::optional> lyricist; + std::optional> lyricist; /// String: The track title - boost::optional title; + std::optional title; /// Integer: The track number on the album disc - boost::optional track_number; + std::optional track_number; /// URI: The location of the media file. - boost::optional url; + std::optional url; /// Integer: The number of times the track has been played. - boost::optional use_count; + std::optional use_count; /// Float: A user-specified rating. This should be in the range 0.0 to 1.0. - boost::optional user_rating; + std::optional user_rating; /// Spotify artist id - boost::optional spotify_artist_id; + std::optional spotify_artist_id; /// Spotify track id - boost::optional spotify_track_id; + std::optional spotify_track_id; json toJson() const { @@ -275,12 +275,12 @@ public: private: template - void readTag(const json& j, const std::string& tag, boost::optional& dest) const + void readTag(const json& j, const std::string& tag, std::optional& dest) const { try { if (!j.contains(tag)) - dest = boost::none; + dest = std::nullopt; else dest = j[tag].get(); } @@ -291,7 +291,7 @@ private: } template - void addTag(json& j, const std::string& tag, const boost::optional& source) const + void addTag(json& j, const std::string& tag, const std::optional& source) const { try { diff --git a/common/properties.hpp b/common/properties.hpp index 2f3ce6ec..43408e11 100644 --- a/common/properties.hpp +++ b/common/properties.hpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include "common/aixlog.hpp" #include "common/json.hpp" @@ -154,22 +154,22 @@ public: /// https://www.musicpd.org/doc/html/protocol.html#tags /// The current playback status - boost::optional playback_status; + std::optional playback_status; /// The current loop / repeat status - boost::optional loop_status; + std::optional loop_status; /// The current playback rate - boost::optional rate; + std::optional rate; /// A value of false indicates that playback is progressing linearly through a playlist, while true means playback is progressing through a playlist in some /// other order. - boost::optional shuffle; + std::optional shuffle; /// The volume level between 0-100 - boost::optional volume; + std::optional volume; /// The current track position in seconds - boost::optional position; + std::optional position; /// The minimum value which the Rate property can take. Clients should not attempt to set the Rate property below this value - boost::optional minimum_rate; + std::optional minimum_rate; /// The maximum value which the Rate property can take. Clients should not attempt to set the Rate property above this value - boost::optional maximum_rate; + std::optional maximum_rate; /// Whether the client can call the Next method on this interface and expect the current track to change bool can_go_next = false; /// Whether the client can call the Previous method on this interface and expect the current track to change @@ -187,9 +187,9 @@ public: { json j; if (playback_status.has_value()) - addTag(j, "playbackStatus", boost::optional(to_string(playback_status.value()))); + addTag(j, "playbackStatus", std::optional(to_string(playback_status.value()))); if (loop_status.has_value()) - addTag(j, "loopStatus", boost::optional(to_string(loop_status.value()))); + addTag(j, "loopStatus", std::optional(to_string(loop_status.value()))); addTag(j, "rate", rate); addTag(j, "shuffle", shuffle); addTag(j, "volume", volume); @@ -218,19 +218,19 @@ public: LOG(WARNING, LOG_TAG) << "Property not supoorted: " << element.key() << "\n"; } - boost::optional opt; + std::optional opt; readTag(j, "playbackStatus", opt); if (opt.has_value()) playback_status = playback_status_from_string(opt.value()); else - playback_status = boost::none; + playback_status = std::nullopt; readTag(j, "loopStatus", opt); if (opt.has_value()) loop_status = loop_status_from_string(opt.value()); else - loop_status = boost::none; + loop_status = std::nullopt; readTag(j, "rate", rate); readTag(j, "shuffle", shuffle); readTag(j, "volume", volume); @@ -253,12 +253,12 @@ public: private: template - void readTag(const json& j, const std::string& tag, boost::optional& dest) const + void readTag(const json& j, const std::string& tag, std::optional& dest) const { try { if (!j.contains(tag)) - dest = boost::none; + dest = std::nullopt; else dest = j[tag].get(); } @@ -271,7 +271,7 @@ private: template void readTag(const json& j, const std::string& tag, T& dest, const T& def) const { - boost::optional val; + std::optional val; readTag(j, tag, val); if (val.has_value()) dest = val.value(); @@ -280,7 +280,7 @@ private: } template - void addTag(json& j, const std::string& tag, const boost::optional& source) const + void addTag(json& j, const std::string& tag, const std::optional& source) const { if (!source.has_value()) { diff --git a/server/Makefile b/server/Makefile index 8bd0a638..388e9d28 100644 --- a/server/Makefile +++ b/server/Makefile @@ -42,7 +42,7 @@ ifneq ($(SANITIZE), ) LDFLAGS += -fsanitize=$(SANITIZE) endif -CXXFLAGS += $(ADD_CFLAGS) -std=c++14 -Wall -Wextra -Wpedantic -Wno-unused-function -DBOOST_ERROR_CODE_HEADER_ONLY -DHAS_FLAC -DHAS_OGG -DHAS_VORBIS -DHAS_VORBIS_ENC -DHAS_OPUS -DHAS_SOXR -DVERSION=\"$(VERSION)\" -I. -I.. -I../common +CXXFLAGS += $(ADD_CFLAGS) -std=c++17 -Wall -Wextra -Wpedantic -Wno-unused-function -DBOOST_ERROR_CODE_HEADER_ONLY -DHAS_FLAC -DHAS_OGG -DHAS_VORBIS -DHAS_VORBIS_ENC -DHAS_OPUS -DHAS_SOXR -DVERSION=\"$(VERSION)\" -I. -I.. -I../common LDFLAGS += $(ADD_LDFLAGS) -lvorbis -lvorbisenc -logg -lFLAC -lopus -lsoxr OBJ = snapserver.o server.o config.o control_server.o control_session_tcp.o control_session_http.o control_session_ws.o stream_server.o stream_session.o stream_session_tcp.o stream_session_ws.o streamreader/stream_uri.o streamreader/base64.o streamreader/stream_manager.o streamreader/pcm_stream.o streamreader/posix_stream.o streamreader/pipe_stream.o streamreader/file_stream.o streamreader/tcp_stream.o streamreader/process_stream.o streamreader/airplay_stream.o streamreader/meta_stream.o streamreader/librespot_stream.o streamreader/watchdog.o encoder/encoder_factory.o encoder/flac_encoder.o encoder/opus_encoder.o encoder/pcm_encoder.o encoder/null_encoder.o encoder/ogg_encoder.o ../common/sample_format.o ../common/resampler.o diff --git a/server/streamreader/pcm_stream.hpp b/server/streamreader/pcm_stream.hpp index aff5b97b..8a22e2d8 100644 --- a/server/streamreader/pcm_stream.hpp +++ b/server/streamreader/pcm_stream.hpp @@ -27,7 +27,6 @@ #include #include #include -#include #include "common/json.hpp" #include "common/metatags.hpp"