mirror of
https://github.com/badaix/snapcast.git
synced 2025-06-26 22:47:07 +02:00
Add option to not kill all librespot instances
This commit is contained in:
parent
2158c3e085
commit
678f102a98
3 changed files with 10 additions and 4 deletions
|
@ -151,11 +151,11 @@ Snapserver supports [shairport-sync](https://github.com/mikebrady/shairport-sync
|
||||||
### Spotify
|
### Spotify
|
||||||
Snapserver supports [librespot](https://github.com/librespot-org/librespot) with the `pipe` backend.
|
Snapserver supports [librespot](https://github.com/librespot-org/librespot) with the `pipe` backend.
|
||||||
1. Build and copy the `librespot` binary somewhere to your `PATH`, e.g. `/usr/local/bin/`
|
1. Build and copy the `librespot` binary somewhere to your `PATH`, e.g. `/usr/local/bin/`
|
||||||
2. Configure snapserver with `stream = spotify:///librespot?name=Spotify[&username=<my username>&password=<my password>][&devicename=Snapcast][&bitrate=320][&onstart=<start command>][&onstop=<stop command>][&volume=<volume in percent>][&cache=<cache dir>]`
|
2. Configure snapserver with `stream = spotify:///librespot?name=Spotify[&username=<my username>&password=<my password>][&devicename=Snapcast][&bitrate=320][&onstart=<start command>][&onstop=<stop command>][&volume=<volume in percent>][&cache=<cache dir>][&killall=true]`
|
||||||
* Valid bitrates are 96, 160, 320
|
* Valid bitrates are 96, 160, 320
|
||||||
* `start command` and `stop command` are executed by Librespot at start/stop
|
* `start command` and `stop command` are executed by Librespot at start/stop
|
||||||
* For example: `onstart=/usr/bin/logger -t Snapcast Starting spotify...`
|
* For example: `onstart=/usr/bin/logger -t Snapcast Starting spotify...`
|
||||||
|
* If `killall` is `true` (default), all running instances of Librespot will be killed. This MUST be disabled on all spotify streams by setting it to `false` if you want to use multiple spotify streams.
|
||||||
|
|
||||||
### Process
|
### Process
|
||||||
Snapserver can start any process and read PCM data from the stdout of the process:
|
Snapserver can start any process and read PCM data from the stdout of the process:
|
||||||
|
|
|
@ -44,6 +44,7 @@ LibrespotStream::LibrespotStream(PcmListener* pcmListener, boost::asio::io_conte
|
||||||
string devicename = uri_.getQuery("devicename", "Snapcast");
|
string devicename = uri_.getQuery("devicename", "Snapcast");
|
||||||
string onevent = uri_.getQuery("onevent", "");
|
string onevent = uri_.getQuery("onevent", "");
|
||||||
bool normalize = (uri_.getQuery("normalize", "false") == "true");
|
bool normalize = (uri_.getQuery("normalize", "false") == "true");
|
||||||
|
killall_ = (uri_.getQuery("killall", "true") == "true");
|
||||||
|
|
||||||
if (username.empty() != password.empty())
|
if (username.empty() != password.empty())
|
||||||
throw SnapException("missing parameter \"username\" or \"password\" (must provide both, or neither)");
|
throw SnapException("missing parameter \"username\" or \"password\" (must provide both, or neither)");
|
||||||
|
@ -87,8 +88,11 @@ void LibrespotStream::initExeAndPath(const std::string& filename)
|
||||||
exe_ = exe_.substr(exe_.find_last_of("/") + 1);
|
exe_ = exe_.substr(exe_.find_last_of("/") + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// kill if it's already running
|
if (killall_)
|
||||||
execGetOutput("killall " + exe_);
|
{
|
||||||
|
/// kill if it's already running
|
||||||
|
execGetOutput("killall " + exe_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,8 @@ public:
|
||||||
LibrespotStream(PcmListener* pcmListener, boost::asio::io_context& ioc, const StreamUri& uri);
|
LibrespotStream(PcmListener* pcmListener, boost::asio::io_context& ioc, const StreamUri& uri);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
bool killall_;
|
||||||
|
|
||||||
void onStderrMsg(const std::string& line) override;
|
void onStderrMsg(const std::string& line) override;
|
||||||
void initExeAndPath(const std::string& filename) override;
|
void initExeAndPath(const std::string& filename) override;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue