diff --git a/control/meta_mpd.py b/control/meta_mpd.py index 1c2fb82a..32259afe 100755 --- a/control/meta_mpd.py +++ b/control/meta_mpd.py @@ -576,7 +576,7 @@ def get_metadata(self): logger.debug( f'key: {key}, value: {value}, mapped key: {tag_mapping[key][0]}, mapped value: {snapmeta[tag_mapping[key][0]]}') except KeyError: - logger.warning(f'tag "{key}" not supported') + logger.debug(f'tag "{key}" not supported') except (ValueError, TypeError): logger.warning( f"Can't cast value {value} to {tag_mapping[key][1]}") @@ -602,7 +602,6 @@ def get_metadata(self): if art_url is not None: logger.info(f'album art cache hit: "{art_url}"') snapmeta['artUrl'] = art_url - return snapmeta def __diff_map(self, old_map, new_map): @@ -647,12 +646,12 @@ def _update_properties(self, force=False): new_song = self.client.currentsong() if not new_song: - logger.debug("_update_properties: failed to get current song") + logger.warning("_update_properties: failed to get current song") new_song = {} new_status = self.client.status() if not new_status: - logger.debug("_update_properties: failed to get new status") + logger.warning("_update_properties: failed to get new status") new_status = {} changed_status = self.__diff_map(self._status, new_status) diff --git a/server/server.cpp b/server/server.cpp index 12c67523..a69f036f 100644 --- a/server/server.cpp +++ b/server/server.cpp @@ -153,7 +153,7 @@ void Server::processRequest(const jsonrpcpp::request_ptr request, const OnRespon // Notification: {"jsonrpc":"2.0","method":"Client.OnVolumeChanged","params":{"id":"00:21:6a:7d:74:fc","volume":{"muted":false,"percent":74}}} // clang-format on - std::lock_guard lock(clientMutex_); + // std::lock_guard lock(clientMutex_); clientInfo->config.volume.fromJson(request->params().get("volume")); result["volume"] = clientInfo->config.volume.toJson(); notification = std::make_shared( @@ -825,6 +825,8 @@ void Server::onMessageReceived(StreamSession* streamSession, const msg::BaseMess void Server::saveConfig(const std::chrono::milliseconds& deferred) { + static std::mutex mutex; + std::lock_guard lock(mutex); config_timer_.cancel(); config_timer_.expires_after(deferred); config_timer_.async_wait([](const boost::system::error_code& ec) { diff --git a/server/server.hpp b/server/server.hpp index 41144490..a4d428fa 100644 --- a/server/server.hpp +++ b/server/server.hpp @@ -90,8 +90,8 @@ class Server : public StreamMessageReceiver, public ControlMessageReceiver, publ /// @param deferred the delay after the last call to saveConfig void saveConfig(const std::chrono::milliseconds& deferred = std::chrono::seconds(2)); - mutable std::recursive_mutex sessionsMutex_; - mutable std::recursive_mutex clientMutex_; + // mutable std::recursive_mutex controlMutex_; + // mutable std::recursive_mutex clientMutex_; boost::asio::io_context& io_context_; boost::asio::steady_timer config_timer_; diff --git a/server/stream_server.cpp b/server/stream_server.cpp index b906ed94..5af12970 100644 --- a/server/stream_server.cpp +++ b/server/stream_server.cpp @@ -84,7 +84,7 @@ void StreamServer::onChunkEncoded(const PcmStream* pcmStream, bool isDefaultStre { if (!settings_.stream.sendAudioToMutedClients) { - std::lock_guard lock(clientMutex_); + // std::lock_guard lock(clientMutex_); GroupPtr group = Config::instance().getGroupFromClient(session->clientId); if (group) { diff --git a/server/stream_session.cpp b/server/stream_session.cpp index adcfebde..66d98e5e 100644 --- a/server/stream_session.cpp +++ b/server/stream_session.cpp @@ -38,14 +38,14 @@ StreamSession::StreamSession(const net::any_io_executor& executor, StreamMessage void StreamSession::setPcmStream(PcmStreamPtr pcmStream) { - std::lock_guard lock(mutex_); + // std::lock_guard lock(mutex_); pcmStream_ = pcmStream; } const PcmStreamPtr StreamSession::pcmStream() const { - std::lock_guard lock(mutex_); + // std::lock_guard lock(mutex_); return pcmStream_; } diff --git a/server/streamreader/meta_stream.cpp b/server/streamreader/meta_stream.cpp index 3b7e11b4..c4462dd5 100644 --- a/server/streamreader/meta_stream.cpp +++ b/server/streamreader/meta_stream.cpp @@ -87,7 +87,7 @@ void MetaStream::stop() void MetaStream::onPropertiesChanged(const PcmStream* pcmStream, const Properties& properties) { LOG(DEBUG, LOG_TAG) << "onPropertiesChanged: " << pcmStream->getName() << "\n"; - std::lock_guard lock(mutex_); + // std::lock_guard lock(mutex_); if (pcmStream != active_stream_.get()) return; setProperties(properties); @@ -97,7 +97,7 @@ void MetaStream::onPropertiesChanged(const PcmStream* pcmStream, const Propertie void MetaStream::onStateChanged(const PcmStream* pcmStream, ReaderState state) { LOG(DEBUG, LOG_TAG) << "onStateChanged: " << pcmStream->getName() << ", state: " << state << "\n"; - std::lock_guard lock(mutex_); + // std::lock_guard lock(mutex_); if (active_stream_->getProperties().playback_status == PlaybackStatus::kPaused) return; @@ -137,7 +137,7 @@ void MetaStream::onStateChanged(const PcmStream* pcmStream, ReaderState state) void MetaStream::onChunkRead(const PcmStream* pcmStream, const msg::PcmChunk& chunk) { // LOG(TRACE, LOG_TAG) << "onChunkRead: " << pcmStream->getName() << ", duration: " << chunk.durationMs() << "\n"; - std::lock_guard lock(mutex_); + // std::lock_guard lock(mutex_); if (pcmStream != active_stream_.get()) return; // active_stream_->sampleFormat_ @@ -195,7 +195,7 @@ void MetaStream::onChunkEncoded(const PcmStream* pcmStream, std::shared_ptrgetName() << ", duration: " << ms << " ms\n"; - std::lock_guard lock(mutex_); + // std::lock_guard lock(mutex_); if (pcmStream != active_stream_.get()) return; resync(std::chrono::nanoseconds(static_cast(ms * 1000000))); diff --git a/server/streamreader/meta_stream.hpp b/server/streamreader/meta_stream.hpp index 6f1632bf..279a2f36 100644 --- a/server/streamreader/meta_stream.hpp +++ b/server/streamreader/meta_stream.hpp @@ -71,7 +71,7 @@ class MetaStream : public PcmStream, public PcmListener protected: std::vector> streams_; std::shared_ptr active_stream_; - std::recursive_mutex mutex_; + // std::recursive_mutex mutex_; std::unique_ptr resampler_; bool first_read_; std::chrono::time_point next_tick_; diff --git a/server/streamreader/pcm_stream.cpp b/server/streamreader/pcm_stream.cpp index aa2bdbc2..59507a53 100644 --- a/server/streamreader/pcm_stream.cpp +++ b/server/streamreader/pcm_stream.cpp @@ -288,6 +288,7 @@ void PcmStream::resync(const std::chrono::nanoseconds& duration) json PcmStream::toJson() const { + std::lock_guard lock(mutex_); json j = { {"uri", uri_.toJson()}, {"id", getId()}, @@ -316,7 +317,7 @@ const Metatags& PcmStream::getMetadata() const const Properties& PcmStream::getProperties() const { - std::lock_guard lock(mutex_); + // std::lock_guard lock(mutex_); return properties_; } @@ -447,8 +448,7 @@ void PcmStream::play(ResultHandler handler) void PcmStream::setProperties(const Properties& properties) { - std::lock_guard lock(mutex_); - + // std::lock_guard lock(mutex_); Properties props = properties; // Missing metadata means the data didn't change, so // enrich the new properites with old metadata