mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-12 00:26:41 +02:00
Force unique stream name, use name as id
This commit is contained in:
parent
d76aac0de7
commit
341466ceb5
7 changed files with 32 additions and 39 deletions
|
@ -36,7 +36,7 @@ StreamManager::StreamManager(PcmListener* pcmListener, const std::string& defaul
|
|||
}
|
||||
|
||||
|
||||
PcmStream* StreamManager::addStream(const std::string& uri)
|
||||
PcmStreamPtr StreamManager::addStream(const std::string& uri)
|
||||
{
|
||||
StreamUri streamUri(uri);
|
||||
|
||||
|
@ -54,38 +54,44 @@ PcmStream* StreamManager::addStream(const std::string& uri)
|
|||
|
||||
// for (auto kv: streamUri.query)
|
||||
// logD << "key: '" << kv.first << "' value: '" << kv.second << "'\n";
|
||||
PcmStreamPtr stream(nullptr);
|
||||
|
||||
if (streamUri.scheme == "pipe")
|
||||
{
|
||||
streams_.push_back(make_shared<PipeStream>(pcmListener_, streamUri));
|
||||
return streams_.back().get();
|
||||
stream = make_shared<PipeStream>(pcmListener_, streamUri);
|
||||
}
|
||||
else if (streamUri.scheme == "file")
|
||||
{
|
||||
streams_.push_back(make_shared<FileStream>(pcmListener_, streamUri));
|
||||
return streams_.back().get();
|
||||
stream = make_shared<FileStream>(pcmListener_, streamUri);
|
||||
}
|
||||
else if (streamUri.scheme == "process")
|
||||
{
|
||||
streams_.push_back(make_shared<ProcessStream>(pcmListener_, streamUri));
|
||||
return streams_.back().get();
|
||||
stream = make_shared<ProcessStream>(pcmListener_, streamUri);
|
||||
}
|
||||
else if (streamUri.scheme == "spotify")
|
||||
{
|
||||
streams_.push_back(make_shared<SpotifyStream>(pcmListener_, streamUri));
|
||||
return streams_.back().get();
|
||||
stream = make_shared<SpotifyStream>(pcmListener_, streamUri);
|
||||
}
|
||||
else if (streamUri.scheme == "airplay")
|
||||
{
|
||||
streams_.push_back(make_shared<AirplayStream>(pcmListener_, streamUri));
|
||||
return streams_.back().get();
|
||||
stream = make_shared<AirplayStream>(pcmListener_, streamUri);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw SnapException("Unknown stream type: " + streamUri.scheme);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
if (stream)
|
||||
{
|
||||
for (auto s: streams_)
|
||||
{
|
||||
if (s->getName() == stream->getName())
|
||||
throw SnapException("Stream with name \"" + stream->getName() + "\" already exists");
|
||||
}
|
||||
streams_.push_back(stream);
|
||||
}
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
|
@ -108,7 +114,7 @@ const PcmStreamPtr StreamManager::getStream(const std::string& id)
|
|||
{
|
||||
for (auto stream: streams_)
|
||||
{
|
||||
if (stream->getUri().id() == id)
|
||||
if (stream->getId() == id)
|
||||
return stream;
|
||||
}
|
||||
return nullptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue