mirror of
https://github.com/badaix/snapcast.git
synced 2025-04-29 10:17:16 +02:00
Forward metadata and properties in meta stream
This commit is contained in:
parent
fba20fb7fe
commit
3120a18326
4 changed files with 36 additions and 13 deletions
|
@ -86,18 +86,21 @@ void MetaStream::stop()
|
||||||
|
|
||||||
void MetaStream::onMetadataChanged(const PcmStream* pcmStream, const Metatags& metadata)
|
void MetaStream::onMetadataChanged(const PcmStream* pcmStream, const Metatags& metadata)
|
||||||
{
|
{
|
||||||
std::ignore = metadata;
|
|
||||||
LOG(DEBUG, LOG_TAG) << "onMetadataChanged: " << pcmStream->getName() << "\n";
|
LOG(DEBUG, LOG_TAG) << "onMetadataChanged: " << pcmStream->getName() << "\n";
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
std::lock_guard<std::mutex> lock(mutex_);
|
||||||
if (pcmStream != active_stream_.get())
|
if (pcmStream != active_stream_.get())
|
||||||
return;
|
return;
|
||||||
|
setMetadata(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MetaStream::onPropertiesChanged(const PcmStream* pcmStream, const Properties& properties)
|
void MetaStream::onPropertiesChanged(const PcmStream* pcmStream, const Properties& properties)
|
||||||
{
|
{
|
||||||
std::ignore = properties;
|
|
||||||
LOG(DEBUG, LOG_TAG) << "onPropertiesChanged: " << pcmStream->getName() << "\n";
|
LOG(DEBUG, LOG_TAG) << "onPropertiesChanged: " << pcmStream->getName() << "\n";
|
||||||
|
std::lock_guard<std::mutex> lock(mutex_);
|
||||||
|
if (pcmStream != active_stream_.get())
|
||||||
|
return;
|
||||||
|
setProperties(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,6 +120,8 @@ void MetaStream::onStateChanged(const PcmStream* pcmStream, ReaderState state)
|
||||||
LOG(INFO, LOG_TAG) << "Stream: " << name_ << ", switching active stream: " << (active_stream_ ? active_stream_->getName() : "<null>") << " => "
|
LOG(INFO, LOG_TAG) << "Stream: " << name_ << ", switching active stream: " << (active_stream_ ? active_stream_->getName() : "<null>") << " => "
|
||||||
<< stream->getName() << "\n";
|
<< stream->getName() << "\n";
|
||||||
active_stream_ = stream;
|
active_stream_ = stream;
|
||||||
|
setMetadata(active_stream_->getMetadata());
|
||||||
|
setProperties(active_stream_->getProperties());
|
||||||
resampler_ = make_unique<Resampler>(active_stream_->getSampleFormat(), sampleFormat_);
|
resampler_ = make_unique<Resampler>(active_stream_->getSampleFormat(), sampleFormat_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -158,6 +158,9 @@ void PcmStream::onControlNotification(const jsonrpcpp::Notification& notificatio
|
||||||
if (response.error().code() == 0)
|
if (response.error().code() == 0)
|
||||||
setMetadata(response.result());
|
setMetadata(response.result());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO: Add capabilities or settings?
|
||||||
|
// {"jsonrpc": "2.0", "method": "Plugin.Stream.Ready", "params": {"pollProperties": 10, "responseTimeout": 5}}
|
||||||
pollProperties();
|
pollProperties();
|
||||||
}
|
}
|
||||||
else if (notification.method() == "Plugin.Stream.Log")
|
else if (notification.method() == "Plugin.Stream.Log")
|
||||||
|
|
|
@ -136,6 +136,13 @@ void StreamControl::onLog(std::string message)
|
||||||
|
|
||||||
ScriptStreamControl::ScriptStreamControl(boost::asio::io_context& ioc, const std::string& script) : StreamControl(ioc), script_(script)
|
ScriptStreamControl::ScriptStreamControl(boost::asio::io_context& ioc, const std::string& script) : StreamControl(ioc), script_(script)
|
||||||
{
|
{
|
||||||
|
// auto fileExists = [](const std::string& filename) {
|
||||||
|
// struct stat buffer;
|
||||||
|
// return (stat(filename.c_str(), &buffer) == 0);
|
||||||
|
// };
|
||||||
|
|
||||||
|
// if (!fileExists(script_))
|
||||||
|
// throw SnapException("Control script not found: \"" + script_ + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,16 +154,24 @@ void ScriptStreamControl::doStart(const std::string& stream_id, const ServerSett
|
||||||
params << " \"--stream=" + stream_id + "\"";
|
params << " \"--stream=" + stream_id + "\"";
|
||||||
if (server_setttings.http.enabled)
|
if (server_setttings.http.enabled)
|
||||||
params << " --snapcast-port=" << server_setttings.http.port;
|
params << " --snapcast-port=" << server_setttings.http.port;
|
||||||
process_ = bp::child(
|
try
|
||||||
script_ + params.str(), bp::std_out > pipe_stdout_, bp::std_err > pipe_stderr_, bp::std_in < in_,
|
{
|
||||||
bp::on_exit =
|
process_ = bp::child(
|
||||||
[](int exit, const std::error_code& ec_in) {
|
script_ + params.str(), bp::std_out > pipe_stdout_, bp::std_err > pipe_stderr_, bp::std_in < in_,
|
||||||
auto severity = AixLog::Severity::debug;
|
bp::on_exit =
|
||||||
if (exit != 0)
|
[](int exit, const std::error_code& ec_in) {
|
||||||
severity = AixLog::Severity::error;
|
auto severity = AixLog::Severity::debug;
|
||||||
LOG(severity, LOG_TAG) << "Exit code: " << exit << ", message: " << ec_in.message() << "\n";
|
if (exit != 0)
|
||||||
},
|
severity = AixLog::Severity::error;
|
||||||
ioc_);
|
LOG(severity, LOG_TAG) << "Exit code: " << exit << ", message: " << ec_in.message() << "\n";
|
||||||
|
},
|
||||||
|
ioc_);
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
throw SnapException("Failed to start control script: '" + script_ + "', exception: " + e.what());
|
||||||
|
}
|
||||||
|
|
||||||
stream_stdout_ = make_unique<boost::asio::posix::stream_descriptor>(ioc_, pipe_stdout_.native_source());
|
stream_stdout_ = make_unique<boost::asio::posix::stream_descriptor>(ioc_, pipe_stdout_.native_source());
|
||||||
stream_stderr_ = make_unique<boost::asio::posix::stream_descriptor>(ioc_, pipe_stderr_.native_source());
|
stream_stderr_ = make_unique<boost::asio::posix::stream_descriptor>(ioc_, pipe_stderr_.native_source());
|
||||||
stdoutReadLine();
|
stdoutReadLine();
|
||||||
|
|
Loading…
Add table
Reference in a new issue