mirror of
https://github.com/badaix/snapcast.git
synced 2025-04-29 10:17:16 +02:00
Fix compile error
This commit is contained in:
parent
17efc6799c
commit
9396a78d71
5 changed files with 16 additions and 15 deletions
|
@ -50,7 +50,7 @@ static constexpr auto DEFAULT_MIXER = "PCM";
|
|||
|
||||
|
||||
AlsaPlayer::AlsaPlayer(boost::asio::io_context& io_context, const ClientSettings::Player& settings, std::shared_ptr<Stream> stream)
|
||||
: Player(io_context, settings, stream), handle_(nullptr), ctl_(nullptr), mixer_(nullptr), elem_(nullptr), sd_(io_context), timer_(io_context)
|
||||
: Player(io_context, settings, std::move(stream)), handle_(nullptr), ctl_(nullptr), mixer_(nullptr), elem_(nullptr), sd_(io_context), timer_(io_context)
|
||||
{
|
||||
if (settings_.mixer.mode == ClientSettings::Mixer::Mode::hardware)
|
||||
{
|
||||
|
@ -93,7 +93,7 @@ AlsaPlayer::AlsaPlayer(boost::asio::io_context& io_context, const ClientSettings
|
|||
|
||||
void AlsaPlayer::setHardwareVolume(const Volume& volume)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(rec_mutex_);
|
||||
if (elem_ == nullptr)
|
||||
return;
|
||||
|
||||
|
@ -140,7 +140,7 @@ bool AlsaPlayer::getHardwareVolume(Volume& volume)
|
|||
{
|
||||
try
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(rec_mutex_);
|
||||
if (elem_ == nullptr)
|
||||
throw SnapException("Mixer not initialized");
|
||||
|
||||
|
@ -201,7 +201,7 @@ void AlsaPlayer::waitForEvent()
|
|||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(rec_mutex_);
|
||||
if (ctl_ == nullptr)
|
||||
return;
|
||||
|
||||
|
@ -250,7 +250,7 @@ void AlsaPlayer::initMixer()
|
|||
return;
|
||||
|
||||
LOG(DEBUG, LOG_TAG) << "initMixer\n";
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(rec_mutex_);
|
||||
int err;
|
||||
if ((err = snd_ctl_open(&ctl_, mixer_device_.c_str(), SND_CTL_READONLY)) < 0)
|
||||
throw SnapException("Can't open control for " + mixer_device_ + ", error: " + snd_strerror(err));
|
||||
|
@ -292,7 +292,7 @@ void AlsaPlayer::initMixer()
|
|||
|
||||
void AlsaPlayer::initAlsa()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(rec_mutex_);
|
||||
|
||||
const SampleFormat& format = stream_->getFormat();
|
||||
uint32_t rate = format.rate();
|
||||
|
@ -461,7 +461,7 @@ void AlsaPlayer::initAlsa()
|
|||
|
||||
void AlsaPlayer::uninitAlsa(bool uninit_mixer)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(rec_mutex_);
|
||||
if (uninit_mixer)
|
||||
uninitMixer();
|
||||
|
||||
|
@ -480,7 +480,7 @@ void AlsaPlayer::uninitMixer()
|
|||
return;
|
||||
|
||||
LOG(DEBUG, LOG_TAG) << "uninitMixer\n";
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(rec_mutex_);
|
||||
if (sd_.is_open())
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
|
@ -587,7 +587,7 @@ void AlsaPlayer::worker()
|
|||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
LOG(ERROR, LOG_TAG) << "Exception in initAlsa: " << e.what() << endl;
|
||||
LOG(ERROR, LOG_TAG) << "Exception in initAlsa: " << e.what() << "\n";
|
||||
chronos::sleep(100);
|
||||
}
|
||||
if (handle_ == nullptr)
|
||||
|
|
|
@ -86,6 +86,7 @@ private:
|
|||
snd_pcm_uframes_t frames_;
|
||||
boost::asio::posix::stream_descriptor sd_;
|
||||
std::chrono::time_point<std::chrono::steady_clock> last_change_;
|
||||
std::recursive_mutex rec_mutex_;
|
||||
boost::asio::steady_timer timer_;
|
||||
|
||||
std::optional<std::chrono::microseconds> buffer_time_;
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace player
|
|||
static constexpr auto LOG_TAG = "Player";
|
||||
|
||||
Player::Player(boost::asio::io_context& io_context, const ClientSettings::Player& settings, std::shared_ptr<Stream> stream)
|
||||
: io_context_(io_context), active_(false), stream_(stream), settings_(settings), volCorrection_(1.0)
|
||||
: io_context_(io_context), active_(false), stream_(std::move(stream)), settings_(settings), volCorrection_(1.0)
|
||||
{
|
||||
string sharing_mode;
|
||||
switch (settings_.sharing_mode)
|
||||
|
@ -92,8 +92,8 @@ Player::Player(boost::asio::io_context& io_context, const ClientSettings::Player
|
|||
break;
|
||||
}
|
||||
LOG(INFO, LOG_TAG) << "Mixer mode: " << mixer << ", parameters: " << not_empty(settings_.mixer.parameter) << "\n";
|
||||
LOG(INFO, LOG_TAG) << "Sampleformat: " << (settings_.sample_format.isInitialized() ? settings_.sample_format.toString() : stream->getFormat().toString())
|
||||
<< ", stream: " << stream->getFormat().toString() << "\n";
|
||||
LOG(INFO, LOG_TAG) << "Sampleformat: " << (settings_.sample_format.isInitialized() ? settings_.sample_format.toString() : stream_->getFormat().toString())
|
||||
<< ", stream: " << stream_->getFormat().toString() << "\n";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ private:
|
|||
template <typename T>
|
||||
void adjustVolume(char* buffer, size_t count, double volume)
|
||||
{
|
||||
auto* bufferT = static_cast<T*>(buffer);
|
||||
auto* bufferT = reinterpret_cast<T*>(buffer);
|
||||
for (size_t n = 0; n < count; ++n)
|
||||
bufferT[n] = endian::swap<T>(static_cast<T>(endian::swap<T>(bufferT[n]) * volume));
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ vector<PcmDevice> PulsePlayer::pcm_list(const std::string& parameter)
|
|||
|
||||
|
||||
PulsePlayer::PulsePlayer(boost::asio::io_context& io_context, const ClientSettings::Player& settings, std::shared_ptr<Stream> stream)
|
||||
: Player(io_context, settings, stream), latency_(BUFFER_TIME), last_chunk_tick_(0), pa_ml_(nullptr), pa_ctx_(nullptr), playstream_(nullptr),
|
||||
: Player(io_context, settings, std::move(stream)), latency_(BUFFER_TIME), last_chunk_tick_(0), pa_ml_(nullptr), pa_ctx_(nullptr), playstream_(nullptr),
|
||||
proplist_(nullptr), server_(std::nullopt)
|
||||
{
|
||||
auto params = utils::string::split_pairs_to_container<std::vector<std::string>>(settings.parameter, ',', '=');
|
||||
|
@ -210,7 +210,7 @@ void PulsePlayer::worker()
|
|||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
LOG(ERROR, LOG_TAG) << "Exception while connecting to pulse: " << e.what() << endl;
|
||||
LOG(ERROR, LOG_TAG) << "Exception while connecting to pulse: " << e.what() << "\n";
|
||||
disconnect();
|
||||
chronos::sleep(100);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue