mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-29 00:46:17 +02:00
don't send audio to muted clients
This commit is contained in:
parent
69747ec316
commit
39c133e41a
4 changed files with 19 additions and 1 deletions
|
@ -68,6 +68,7 @@ int main(int argc, char* argv[])
|
||||||
Value<size_t> streamBufferValue("", "streamBuffer", "Default stream read buffer [ms]", settings.streamReadMs, &settings.streamReadMs);
|
Value<size_t> streamBufferValue("", "streamBuffer", "Default stream read buffer [ms]", settings.streamReadMs, &settings.streamReadMs);
|
||||||
|
|
||||||
Value<int> bufferValue("b", "buffer", "Buffer [ms]", settings.bufferMs, &settings.bufferMs);
|
Value<int> bufferValue("b", "buffer", "Buffer [ms]", settings.bufferMs, &settings.bufferMs);
|
||||||
|
Switch muteSwitch("", "sendToMuted", "Send audio to muted clients", &settings.sendAudioToMutedClients);
|
||||||
Implicit<int> daemonOption("d", "daemon", "Daemonize\noptional process priority [-20..19]", 0, &processPriority);
|
Implicit<int> daemonOption("d", "daemon", "Daemonize\noptional process priority [-20..19]", 0, &processPriority);
|
||||||
Value<string> userValue("", "user", "the user[:group] to run snapserver as when daemonized", "");
|
Value<string> userValue("", "user", "the user[:group] to run snapserver as when daemonized", "");
|
||||||
|
|
||||||
|
@ -81,6 +82,7 @@ int main(int argc, char* argv[])
|
||||||
.add(codecValue)
|
.add(codecValue)
|
||||||
.add(streamBufferValue)
|
.add(streamBufferValue)
|
||||||
.add(bufferValue)
|
.add(bufferValue)
|
||||||
|
.add(muteSwitch)
|
||||||
#ifdef HAS_DAEMON
|
#ifdef HAS_DAEMON
|
||||||
.add(daemonOption)
|
.add(daemonOption)
|
||||||
.add(userValue)
|
.add(userValue)
|
||||||
|
|
|
@ -44,6 +44,9 @@ Default stream read buffer [ms] (default = 20)
|
||||||
\fB-b, --buffer\fR
|
\fB-b, --buffer\fR
|
||||||
buffer [ms] (default = 1000)
|
buffer [ms] (default = 1000)
|
||||||
.TP
|
.TP
|
||||||
|
\fB-b, --sendToMuted\fR
|
||||||
|
Send audio to muted clients
|
||||||
|
.TP
|
||||||
\fB-d, --daemon\fR
|
\fB-d, --daemon\fR
|
||||||
daemonize, optional process priority [-20..19]
|
daemonize, optional process priority [-20..19]
|
||||||
.TP
|
.TP
|
||||||
|
|
|
@ -58,6 +58,17 @@ void StreamServer::onChunkRead(const PcmStream* pcmStream, const msg::PcmChunk*
|
||||||
std::lock_guard<std::recursive_mutex> mlock(sessionsMutex_);
|
std::lock_guard<std::recursive_mutex> mlock(sessionsMutex_);
|
||||||
for (auto s : sessions_)
|
for (auto s : sessions_)
|
||||||
{
|
{
|
||||||
|
if (!settings_.sendAudioToMutedClients)
|
||||||
|
{
|
||||||
|
GroupPtr group = Config::instance().getGroupFromClient(s->clientId);
|
||||||
|
if (group)
|
||||||
|
{
|
||||||
|
ClientInfoPtr client = group->getClient(s->clientId);
|
||||||
|
if ((client && client->config.volume.muted) || group->muted)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!s->pcmStream() && isDefaultStream)//->getName() == "default")
|
if (!s->pcmStream() && isDefaultStream)//->getName() == "default")
|
||||||
s->sendAsync(shared_message);
|
s->sendAsync(shared_message);
|
||||||
else if (s->pcmStream().get() == pcmStream)
|
else if (s->pcmStream().get() == pcmStream)
|
||||||
|
|
|
@ -50,7 +50,8 @@ struct StreamServerSettings
|
||||||
codec("flac"),
|
codec("flac"),
|
||||||
bufferMs(1000),
|
bufferMs(1000),
|
||||||
sampleFormat("48000:16:2"),
|
sampleFormat("48000:16:2"),
|
||||||
streamReadMs(20)
|
streamReadMs(20),
|
||||||
|
sendAudioToMutedClients(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
size_t port;
|
size_t port;
|
||||||
|
@ -60,6 +61,7 @@ struct StreamServerSettings
|
||||||
int32_t bufferMs;
|
int32_t bufferMs;
|
||||||
std::string sampleFormat;
|
std::string sampleFormat;
|
||||||
size_t streamReadMs;
|
size_t streamReadMs;
|
||||||
|
bool sendAudioToMutedClients;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue