mirror of
https://github.com/badaix/snapcast.git
synced 2025-08-04 00:59:32 +02:00
Merge branch 'master' into develop
This commit is contained in:
commit
8c052e0946
9 changed files with 91 additions and 35 deletions
|
@ -352,7 +352,7 @@ public class MainActivity extends AppCompatActivity implements GroupItem.GroupIt
|
|||
@Override
|
||||
public void onLog(SnapclientService snapclientService, String timestamp, String logClass, String msg) {
|
||||
Log.d(TAG, "[" + logClass + "] " + msg);
|
||||
if ("state".equals(logClass)) {
|
||||
if ("Notice".equals(logClass)) {
|
||||
if (msg.startsWith("sampleformat")) {
|
||||
msg = msg.substring(msg.indexOf(":") + 2);
|
||||
Log.d(TAG, "sampleformat: " + msg);
|
||||
|
|
|
@ -115,8 +115,7 @@ void Controller::onMessageReceived(ClientConnection* connection, const msg::Base
|
|||
throw SnapException("codec not supported: \"" + headerChunk_->codec + "\"");
|
||||
|
||||
sampleFormat_ = decoder_->setHeader(headerChunk_.get());
|
||||
/// TODO: read in Android client
|
||||
LOG(INFO) << TAG("state") << "sampleformat: " << sampleFormat_.rate << ":" << sampleFormat_.bits << ":" << sampleFormat_.channels << "\n";
|
||||
LOG(NOTICE) << TAG("state") << "sampleformat: " << sampleFormat_.rate << ":" << sampleFormat_.bits << ":" << sampleFormat_.channels << "\n";
|
||||
|
||||
stream_ = make_shared<Stream>(sampleFormat_);
|
||||
stream_->setBufferLen(serverSettings_->getBufferMs() - latency_);
|
||||
|
|
|
@ -8,13 +8,15 @@ snapclient (0.12.0) unstable; urgency=low
|
|||
* Bugfixes
|
||||
-Snapclient: more reliable unique client id (Issue #249)
|
||||
-Snapserver: fix config file permissions (Issue #251)
|
||||
-Fix linker error (Issue #255, #274)
|
||||
-Snapserver: fix crash on "bye" from control client (Issue #238)
|
||||
-Fix linker error (Issue #255, #274)
|
||||
-Snapserver: fix crash on "bye" from control client (Issue #238)
|
||||
-Snapserver: fix crash on port scan (Issue #267)
|
||||
* General
|
||||
-Improved logging: Use "--debug" for debug logging
|
||||
-Log to file: Use "--debug=<filename>"
|
||||
-Improved exception handling and error logging (Issue #276)
|
||||
-Android: update to NDK r16 and clang++
|
||||
-hide spotify credentials in json control message (Issue #282)
|
||||
|
||||
-- Johannes Pohl <johannes.pohl@badaix.de> Tue, 04 Oct 2017 00:13:37 +0200
|
||||
|
||||
|
|
|
@ -109,19 +109,26 @@ void ControlServer::startAccept()
|
|||
|
||||
void ControlServer::handleAccept(socket_ptr socket)
|
||||
{
|
||||
struct timeval tv;
|
||||
tv.tv_sec = 5;
|
||||
tv.tv_usec = 0;
|
||||
setsockopt(socket->native_handle(), SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
|
||||
setsockopt(socket->native_handle(), SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
|
||||
// socket->set_option(boost::asio::ip::tcp::no_delay(false));
|
||||
SLOG(NOTICE) << "ControlServer::NewConnection: " << socket->remote_endpoint().address().to_string() << endl;
|
||||
shared_ptr<ControlSession> session = make_shared<ControlSession>(this, socket);
|
||||
try
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> mlock(mutex_);
|
||||
session->start();
|
||||
sessions_.insert(session);
|
||||
cleanup();
|
||||
struct timeval tv;
|
||||
tv.tv_sec = 5;
|
||||
tv.tv_usec = 0;
|
||||
setsockopt(socket->native_handle(), SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
|
||||
setsockopt(socket->native_handle(), SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
|
||||
// socket->set_option(boost::asio::ip::tcp::no_delay(false));
|
||||
SLOG(NOTICE) << "ControlServer::NewConnection: " << socket->remote_endpoint().address().to_string() << endl;
|
||||
shared_ptr<ControlSession> session = make_shared<ControlSession>(this, socket);
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> mlock(mutex_);
|
||||
session->start();
|
||||
sessions_.insert(session);
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
SLOG(ERROR) << "Exception in ControlServer::handleAccept: " << e.what() << endl;
|
||||
}
|
||||
startAccept();
|
||||
}
|
||||
|
|
|
@ -8,13 +8,15 @@ snapserver (0.12.0) unstable; urgency=low
|
|||
* Bugfixes
|
||||
-Snapclient: more reliable unique client id (Issue #249)
|
||||
-Snapserver: fix config file permissions (Issue #251)
|
||||
-Fix linker error (Issue #255, #274)
|
||||
-Snapserver: fix crash on "bye" from control client (Issue #238)
|
||||
-Fix linker error (Issue #255, #274)
|
||||
-Snapserver: fix crash on "bye" from control client (Issue #238)
|
||||
-Snapserver: fix crash on port scan (Issue #267)
|
||||
* General
|
||||
-Improved logging: Use "--debug" for debug logging
|
||||
-Log to file: Use "--debug=<filename>"
|
||||
-Improved exception handling and error logging (Issue #276)
|
||||
-Android: update to NDK r16 and clang++
|
||||
-hide spotify credentials in json control message (Issue #282)
|
||||
|
||||
-- Johannes Pohl <johannes.pohl@badaix.de> Tue, 04 Oct 2017 00:13:37 +0200
|
||||
|
||||
|
|
|
@ -576,24 +576,30 @@ void StreamServer::startAccept()
|
|||
|
||||
void StreamServer::handleAccept(socket_ptr socket)
|
||||
{
|
||||
struct timeval tv;
|
||||
tv.tv_sec = 5;
|
||||
tv.tv_usec = 0;
|
||||
setsockopt(socket->native_handle(), SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
|
||||
setsockopt(socket->native_handle(), SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
|
||||
try
|
||||
{
|
||||
struct timeval tv;
|
||||
tv.tv_sec = 5;
|
||||
tv.tv_usec = 0;
|
||||
setsockopt(socket->native_handle(), SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
|
||||
setsockopt(socket->native_handle(), SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
|
||||
|
||||
/// experimental: turn on tcp::no_delay
|
||||
socket->set_option(tcp::no_delay(true));
|
||||
/// experimental: turn on tcp::no_delay
|
||||
socket->set_option(tcp::no_delay(true));
|
||||
|
||||
SLOG(NOTICE) << "StreamServer::NewConnection: " << socket->remote_endpoint().address().to_string() << endl;
|
||||
shared_ptr<StreamSession> session = make_shared<StreamSession>(this, socket);
|
||||
SLOG(NOTICE) << "StreamServer::NewConnection: " << socket->remote_endpoint().address().to_string() << endl;
|
||||
shared_ptr<StreamSession> session = make_shared<StreamSession>(this, socket);
|
||||
|
||||
session->setBufferMs(settings_.bufferMs);
|
||||
session->start();
|
||||
|
||||
std::lock_guard<std::recursive_mutex> mlock(sessionsMutex_);
|
||||
sessions_.insert(session);
|
||||
session->setBufferMs(settings_.bufferMs);
|
||||
session->start();
|
||||
|
||||
std::lock_guard<std::recursive_mutex> mlock(sessionsMutex_);
|
||||
sessions_.insert(session);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
SLOG(ERROR) << "Exception in StreamServer::handleAccept: " << e.what() << endl;
|
||||
}
|
||||
startAccept();
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,11 @@ SpotifyStream::SpotifyStream(PcmListener* pcmListener, const StreamUri& uri) : P
|
|||
params_ += " --onstart \"" + onstart + "\"";
|
||||
if (!onstop.empty())
|
||||
params_ += " --onstop \"" + onstop + "\"";
|
||||
|
||||
if (uri_.query.find("username") != uri_.query.end())
|
||||
uri_.query["username"] = "xxx";
|
||||
if (uri_.query.find("password") != uri_.query.end())
|
||||
uri_.query["password"] = "xxx";
|
||||
// LOG(INFO) << "params: " << params << "\n";
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,14 @@ using namespace std;
|
|||
namespace strutils = utils::string;
|
||||
|
||||
|
||||
StreamUri::StreamUri(const std::string& streamUri)
|
||||
StreamUri::StreamUri(const std::string& uri)
|
||||
{
|
||||
parse(uri);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void StreamUri::parse(const std::string& streamUri)
|
||||
{
|
||||
// https://en.wikipedia.org/wiki/Uniform_Resource_Identifier
|
||||
// scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
|
||||
|
@ -92,13 +99,38 @@ StreamUri::StreamUri(const std::string& streamUri)
|
|||
query[key] = value;
|
||||
}
|
||||
}
|
||||
LOG(DEBUG) << "StreamUri.toString: " << toString() << "\n";
|
||||
}
|
||||
|
||||
|
||||
std::string StreamUri::toString() const
|
||||
{
|
||||
// scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
|
||||
stringstream ss;
|
||||
ss << scheme << "://" << host << "/" + path;
|
||||
if (!query.empty())
|
||||
{
|
||||
ss << "?";
|
||||
auto iter = query.begin();
|
||||
while (true)
|
||||
{
|
||||
ss << iter->first << "=" << iter->second;
|
||||
if (++iter == query.end())
|
||||
break;
|
||||
ss << "&";
|
||||
}
|
||||
}
|
||||
if (!fragment.empty())
|
||||
ss << "#" << fragment;
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
||||
json StreamUri::toJson() const
|
||||
{
|
||||
json j = {
|
||||
{"raw", uri},
|
||||
{"raw", toString()},
|
||||
{"scheme", scheme},
|
||||
{"host", host},
|
||||
{"path", path},
|
||||
|
|
|
@ -49,6 +49,9 @@ struct StreamUri
|
|||
std::string id() const;
|
||||
json toJson() const;
|
||||
std::string getQuery(const std::string& key, const std::string& def = "") const;
|
||||
|
||||
void parse(const std::string& streamUri);
|
||||
std::string toString() const;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue