mirror of
https://github.com/badaix/snapcast.git
synced 2025-07-30 22:59:51 +02:00
Tidy up code
This commit is contained in:
parent
f5d4fcaf43
commit
7597f15d24
22 changed files with 74 additions and 85 deletions
|
@ -33,7 +33,7 @@ static constexpr auto LOG_TAG = "AirplayStream";
|
|||
|
||||
namespace
|
||||
{
|
||||
string hex2str(string input)
|
||||
string hex2str(const string& input)
|
||||
{
|
||||
using byte = unsigned char;
|
||||
unsigned long x = strtoul(input.c_str(), nullptr, 16);
|
||||
|
@ -88,7 +88,7 @@ AirplayStream::~AirplayStream()
|
|||
}
|
||||
|
||||
#ifdef HAS_EXPAT
|
||||
int AirplayStream::parse(string line)
|
||||
int AirplayStream::parse(const string& line)
|
||||
{
|
||||
enum XML_Status result;
|
||||
|
||||
|
@ -345,7 +345,7 @@ void XMLCALL AirplayStream::element_end(void* userdata, const char* element_name
|
|||
self->entry_->type.assign(hex2str(self->buf_));
|
||||
|
||||
else if (name == "length")
|
||||
self->entry_->length = strtoul(self->buf_.c_str(), 0, 10);
|
||||
self->entry_->length = strtoul(self->buf_.c_str(), nullptr, 10);
|
||||
|
||||
else if (name == "data")
|
||||
self->entry_->data = self->buf_;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/***
|
||||
This file is part of snapcast
|
||||
Copyright (C) 2014-2020 Johannes Pohl
|
||||
Copyright (C) 2014-2021 Johannes Pohl
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -74,7 +74,7 @@ protected:
|
|||
|
||||
void pipeReadLine();
|
||||
#ifdef HAS_EXPAT
|
||||
int parse(std::string line);
|
||||
int parse(const std::string& line);
|
||||
void createParser();
|
||||
void push();
|
||||
void setMetaData(const std::string& key, const std::string& newValue);
|
||||
|
|
|
@ -134,17 +134,13 @@ void AlsaStream::initAlsa()
|
|||
if ((err = snd_pcm_hw_params_set_format(handle_, hw_params, snd_pcm_format)) < 0)
|
||||
throw SnapException("Can't set sample format: " + string(snd_strerror(err)));
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_rate_near(handle_, hw_params, &rate, 0)) < 0)
|
||||
{
|
||||
if ((err = snd_pcm_hw_params_set_rate_near(handle_, hw_params, &rate, nullptr)) < 0)
|
||||
throw SnapException("Can't set rate: " + string(snd_strerror(err)));
|
||||
}
|
||||
else
|
||||
|
||||
if (rate != sampleFormat_.rate())
|
||||
{
|
||||
if (rate != sampleFormat_.rate())
|
||||
{
|
||||
LOG(WARNING, LOG_TAG) << "Rate is not accurate (requested: " << sampleFormat_.rate() << ", got: " << rate << "), using: " << rate << "\n";
|
||||
sampleFormat_.setFormat(rate, sampleFormat_.bits(), sampleFormat_.channels());
|
||||
}
|
||||
LOG(WARNING, LOG_TAG) << "Rate is not accurate (requested: " << sampleFormat_.rate() << ", got: " << rate << "), using: " << rate << "\n";
|
||||
sampleFormat_.setFormat(rate, sampleFormat_.bits(), sampleFormat_.channels());
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_channels(handle_, hw_params, sampleFormat_.channels())) < 0)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/***
|
||||
This file is part of snapcast
|
||||
Copyright (C) 2014-2020 Johannes Pohl
|
||||
Copyright (C) 2014-2021 Johannes Pohl
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -32,7 +32,7 @@ static constexpr auto LOG_TAG = "MetaStream";
|
|||
// static constexpr auto kResyncTolerance = 50ms;
|
||||
|
||||
|
||||
MetaStream::MetaStream(PcmListener* pcmListener, std::vector<std::shared_ptr<PcmStream>> streams, boost::asio::io_context& ioc, const StreamUri& uri)
|
||||
MetaStream::MetaStream(PcmListener* pcmListener, const std::vector<std::shared_ptr<PcmStream>>& streams, boost::asio::io_context& ioc, const StreamUri& uri)
|
||||
: PcmStream(pcmListener, ioc, uri), first_read_(true)
|
||||
{
|
||||
auto path_components = utils::string::split(uri.path, '/');
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/***
|
||||
This file is part of snapcast
|
||||
Copyright (C) 2014-2020 Johannes Pohl
|
||||
Copyright (C) 2014-2021 Johannes Pohl
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -37,7 +37,7 @@ class MetaStream : public PcmStream, public PcmListener
|
|||
{
|
||||
public:
|
||||
/// ctor. Encoded PCM data is passed to the PcmListener
|
||||
MetaStream(PcmListener* pcmListener, std::vector<std::shared_ptr<PcmStream>> streams, boost::asio::io_context& ioc, const StreamUri& uri);
|
||||
MetaStream(PcmListener* pcmListener, const std::vector<std::shared_ptr<PcmStream>>& streams, boost::asio::io_context& ioc, const StreamUri& uri);
|
||||
virtual ~MetaStream();
|
||||
|
||||
void start() override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue