mirror of
https://github.com/badaix/snapcast.git
synced 2025-08-03 08:39:49 +02:00
Clean up mutexes
This commit is contained in:
parent
12aeb5859c
commit
2efd00d8ef
8 changed files with 19 additions and 18 deletions
|
@ -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<std::recursive_mutex> lock(mutex_);
|
||||
// std::lock_guard<std::recursive_mutex> 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<std::recursive_mutex> lock(mutex_);
|
||||
// std::lock_guard<std::recursive_mutex> 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<std::recursive_mutex> lock(mutex_);
|
||||
// std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (pcmStream != active_stream_.get())
|
||||
return;
|
||||
// active_stream_->sampleFormat_
|
||||
|
@ -195,7 +195,7 @@ void MetaStream::onChunkEncoded(const PcmStream* pcmStream, std::shared_ptr<msg:
|
|||
void MetaStream::onResync(const PcmStream* pcmStream, double ms)
|
||||
{
|
||||
LOG(DEBUG, LOG_TAG) << "onResync: " << pcmStream->getName() << ", duration: " << ms << " ms\n";
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
// std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (pcmStream != active_stream_.get())
|
||||
return;
|
||||
resync(std::chrono::nanoseconds(static_cast<int64_t>(ms * 1000000)));
|
||||
|
|
|
@ -71,7 +71,7 @@ protected:
|
|||
protected:
|
||||
std::vector<std::shared_ptr<PcmStream>> streams_;
|
||||
std::shared_ptr<PcmStream> active_stream_;
|
||||
std::recursive_mutex mutex_;
|
||||
// std::recursive_mutex mutex_;
|
||||
std::unique_ptr<Resampler> resampler_;
|
||||
bool first_read_;
|
||||
std::chrono::time_point<std::chrono::steady_clock> next_tick_;
|
||||
|
|
|
@ -288,6 +288,7 @@ void PcmStream::resync(const std::chrono::nanoseconds& duration)
|
|||
|
||||
json PcmStream::toJson() const
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> 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<std::recursive_mutex> lock(mutex_);
|
||||
// std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
return properties_;
|
||||
}
|
||||
|
||||
|
@ -447,8 +448,7 @@ void PcmStream::play(ResultHandler handler)
|
|||
|
||||
void PcmStream::setProperties(const Properties& properties)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
// std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
Properties props = properties;
|
||||
// Missing metadata means the data didn't change, so
|
||||
// enrich the new properites with old metadata
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue