mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-01 11:17:36 +02:00
Fix crash during shutdown
In case there are multiple PosixStreams with the same name, the server crashed during shutdown
This commit is contained in:
parent
e12fa3fc7d
commit
062e46060c
4 changed files with 9 additions and 7 deletions
|
@ -799,10 +799,11 @@ void StreamServer::start()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
controlServer_.reset(new ControlServer(io_context_, settings_.tcp, settings_.http, this));
|
controlServer_ = std::make_unique<ControlServer>(io_context_, settings_.tcp, settings_.http, this);
|
||||||
controlServer_->start();
|
controlServer_->start();
|
||||||
|
|
||||||
streamManager_.reset(new StreamManager(this, io_context_, settings_.stream.sampleFormat, settings_.stream.codec, settings_.stream.streamChunkMs));
|
streamManager_ =
|
||||||
|
std::make_unique<StreamManager>(this, io_context_, settings_.stream.sampleFormat, settings_.stream.codec, settings_.stream.streamChunkMs);
|
||||||
// throw SnapException("xxx");
|
// throw SnapException("xxx");
|
||||||
for (const auto& streamUri : settings_.stream.pcmStreams)
|
for (const auto& streamUri : settings_.stream.pcmStreams)
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,7 +51,7 @@ using session_ptr = std::shared_ptr<StreamSession>;
|
||||||
* Receives (via the MessageReceiver interface) and answers messages from the clients
|
* Receives (via the MessageReceiver interface) and answers messages from the clients
|
||||||
* Forwards PCM data to the clients
|
* Forwards PCM data to the clients
|
||||||
*/
|
*/
|
||||||
class StreamServer : public MessageReceiver, ControlMessageReceiver, PcmListener
|
class StreamServer : public MessageReceiver, public ControlMessageReceiver, public PcmListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
StreamServer(boost::asio::io_context& io_context, const ServerSettings& serverSettings);
|
StreamServer(boost::asio::io_context& io_context, const ServerSettings& serverSettings);
|
||||||
|
|
|
@ -68,7 +68,7 @@ void PosixStream::connect()
|
||||||
|
|
||||||
void PosixStream::do_disconnect()
|
void PosixStream::do_disconnect()
|
||||||
{
|
{
|
||||||
if (stream_->is_open())
|
if (stream_ && stream_->is_open())
|
||||||
stream_->close();
|
stream_->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,15 +143,16 @@ const PcmStreamPtr StreamManager::getStream(const std::string& id)
|
||||||
|
|
||||||
void StreamManager::start()
|
void StreamManager::start()
|
||||||
{
|
{
|
||||||
for (auto stream : streams_)
|
for (const auto& stream : streams_)
|
||||||
stream->start();
|
stream->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void StreamManager::stop()
|
void StreamManager::stop()
|
||||||
{
|
{
|
||||||
for (auto stream : streams_)
|
for (const auto& stream : streams_)
|
||||||
stream->stop();
|
if (stream)
|
||||||
|
stream->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue