Skip to content

Commit

Permalink
Fix Linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
badaix committed Jan 5, 2025
1 parent 72358cd commit ce743ce
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: file
User: johannes
User: badaix
CheckOptions:
- key: modernize-loop-convert.MaxCopySize
value: '16'
Expand Down
26 changes: 17 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ Available audio backends are configured using the `--player` command line parame

| Backend | OS | Description | Parameters |
| --------- | ------- | ------------ | ---------- |
| alsa | Linux | ALSA | `buffer_time=<total buffer size [ms]>` (default 80, min 10)<br />`fragments=<number of buffers>` (default 4, min 2) |
| pulse | Linux | PulseAudio | `buffer_time=<buffer size [ms]>` (default 100, min 10)<br />`server=<PulseAudio server>` - default not-set: use the default server<br />`property=<key>=<value>` set PA property, can be used multiple times (default `media.role=music`) |
| alsa | Linux | ALSA | `buffer_time=<total buffer size [ms]>` (default 80, min 10)<br>`fragments=<number of buffers>` (default 4, min 2) |
| pulse | Linux | PulseAudio | `buffer_time=<buffer size [ms]>` (default 100, min 10)<br>`server=<PulseAudio server>` - default not-set: use the default server<br>`property=<key>=<value>` set PA property, can be used multiple times (default `media.role=music`) |
| oboe | Android | Oboe, using OpenSL ES on Android 4.1 and AAudio on 8.1 | |
| opensl | Android | OpenSL ES | |
| coreaudio | macOS | Core Audio | |
| wasapi | Windows | Windows Audio Session API | |
| file | All | Write audio to file | `filename=<filename>` (`<filename>` = `stdout`, `stderr`, `null` or a filename)<br />`mode=[w|a]` (`w`: write (discarding the content), `a`: append (keeping the content) |
| file | All | Write audio to file | `filename=<filename>` (`<filename>` = `stdout`, `stderr`, `null` or a filename)<br>`mode=[w\|a]` (`w`: write (discarding the content), `a`: append (keeping the content) |

Parameters are appended to the player name, e.g. `--player alsa:buffer_time=100`. Use `--player <name>:?` to get a list of available options.
For some audio backends you can configure the PCM device using the `-s` or `--soundcard` parameter, the device is chosen by index or name. Available PCM devices can be listed with `-l` or `--list`
Expand All @@ -131,18 +131,24 @@ If you are running MPD and Shairport-sync into a soundcard that only supports 48

You can test your installation by copying random data into the server's fifo file

cat /dev/urandom > /tmp/snapfifo
```shell
cat /dev/urandom > /tmp/snapfifo
```

All connected clients should play random noise now. You might raise the client's volume with "alsamixer".
It's also possible to let the server play a WAV file. Simply configure a `file` stream in `/etc/snapserver.conf`, and restart the server:

[stream]
source = file:///home/user/Musik/Some%20wave%20file.wav?name=test
```ini
[stream]
source = file:///home/user/Musik/Some%20wave%20file.wav?name=test
```

When you are using a Raspberry Pi, you might have to change your audio output to the 3.5mm jack:

#The last number is the audio output with 1 being the 3.5 jack, 2 being HDMI and 0 being auto.
amixer cset numid=3 1
``` shell
# The last number is the audio output with 1 being the 3.5 jack, 2 being HDMI and 0 being auto.
amixer cset numid=3 1
```

To setup WiFi on a Raspberry Pi, you can follow this [guide](https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md)

Expand Down Expand Up @@ -195,7 +201,9 @@ The only requirement is that the player's audio can be redirected into the Snaps

The goal is to build the following chain:

audio player software -> snapfifo -> snapserver -> network -> snapclient -> alsa
```plain
audio player software -> snapfifo -> snapserver -> network -> snapclient -> alsa
```

This [guide](doc/player_setup.md) shows how to configure different players/audio sources to redirect their audio signal into the Snapserver's fifo:

Expand Down
5 changes: 2 additions & 3 deletions doc/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pipe:///<path/to/pipe>?name=<name>[&mode=create]
`mode` can be `create` or `read`. Sometimes your audio source might insist in creating the pipe itself. So the pipe creation mode can by changed to "not create, but only read mode", using the `mode` option set to `read`
**NOTE** With newer kernels using FIFO pipes in a world writeable sticky dir (e.g. `/tmp`) one might also have to turn off `fs.protected_fifos`, as default settings have changed recently: `sudo sysctl fs.protected_fifos=0`.
**NOTE** With newer kernels using FIFO pipes in a world writeable sticky dir (e.g. `/tmp`) one might also have to turn off `fs.protected_fifos`, as default settings have changed recently: `sudo sysctl fs.protected_fifos=0`.
See [stackexchange](https://unix.stackexchange.com/questions/503111/group-permissions-for-root-not-working-in-tmp) for more details. You need to run this after each reboot or add it to /etc/sysctl.conf or /etc/sysctl.d/50-default.conf depending on distribution.
Expand Down Expand Up @@ -292,7 +292,7 @@ have a Jack client named "system" with four output ports ("playback_1",
could either autoconnect to the exact ports, or you use an `autoconnect` search
term that returns all ports and use `autoconnect_skip` to pick the right one:
```
```ini
jack:///?name=Channel1&sampleformat=48000:16:1&autoconnect=system:playback_
jack:///?name=Channel2&sampleformat=48000:16:1&autoconnect=system:playback_&autoconnect_skip=1
jack:///?name=Channel3&sampleformat=48000:16:1&autoconnect=system:playback_&autoconnect_skip=2
Expand All @@ -306,7 +306,6 @@ jack:///?name=Channel4&sampleformat=48000:16:1&autoconnect=system:playback_&auto
- The `chunk_ms` parameter is ignored for jack streams. The Jack buffer size
(Frames/Period) is used instead.
### meta
Read and mix audio from other stream sources
Expand Down
35 changes: 23 additions & 12 deletions doc/player_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The goal is to build the following chain:
audio player software -> snapfifo -> snapserver -> network -> snapclient -> alsa
```

**NOTE** With newer kernels using FIFO pipes in a world writeable sticky dir (e.g. `/tmp`) one might also have to turn off `fs.protected_fifos`, as default settings have changed recently: `sudo sysctl fs.protected_fifos=0`.
**NOTE** With newer kernels using FIFO pipes in a world writeable sticky dir (e.g. `/tmp`) one might also have to turn off `fs.protected_fifos`, as default settings have changed recently: `sudo sysctl fs.protected_fifos=0`.

See [stackexchange](https://unix.stackexchange.com/questions/503111/group-permissions-for-root-not-working-in-tmp) for more details. You need to run this after each reboot or add it to /etc/sysctl.conf or /etc/sysctl.d/50-default.conf depending on distribution.

Expand Down Expand Up @@ -200,9 +200,9 @@ sudo apt install -y shairport-sync
sudo systemctl disable --now shairport-sync
```

Here is an example configuration line for /etc/snapserver.conf but please see [the Snapcast Airplay configuration guide](configuration.md#airplay) for more details on the syntax and options.
Here is an example configuration line for `/etc/snapserver.conf` but please see [the Snapcast Airplay configuration guide](configuration.md#airplay) for more details on the syntax and options.

```plaintext
```ini
source = airplay:///shairport-sync?name=Airplay
```

Expand All @@ -212,11 +212,11 @@ Although this _might_ be a quick and convenient way to set up an Airplay source

1. Install dependencies. For debian derivates: `apt-get install autoconf libpopt-dev libconfig-dev libssl-dev`
2. Build shairport-sync (version 3.3 or later) with `stdout` backend:
* `autoreconf -i -f`
* `autoreconf -i -f`
* `./configure --with-stdout --with-avahi --with-ssl=openssl --with-metadata`
3. Copy the `shairport-sync` binary somewhere to your `PATH`, e.g. `/usr/local/bin/`
4. Configure snapserver with `source = airplay:///shairport-sync?name=Airplay[&devicename=Snapcast][&port=PORT]`
* `PORT` is 5000 for Airplay 1 and 7000 for Airplay 2
* `PORT` is 5000 for Airplay 1 and 7000 for Airplay 2

### Spotify

Expand Down Expand Up @@ -266,28 +266,39 @@ Audio can be played directly through the line-in via ALSA. The following guide w
```

3. Edit the file `/etc/snapserver.conf` and add the following line, substituting `<device_name>` for the value derived from the previous step. Pick whatever you'd like for `<stream_name>`.
```
```ini
stream = alsa:///?name=<stream_name>&device=hw:<device_name>
```
4. Restart the snapserver service.
```
```shell
sudo service snapserver restart
```
5. You are done. Enjoy your new snapserver with line in. However, if you'd like to run the client on the same machine as the server then continue with the remaining steps.
6. Get the sound devices as far as snapclient is concerned. You are looking for the device name. This is probably the same as the `aplay -l` device names so may be able to use that instead.
```

```shell
snapclient -l
```

7. In the output you are looking for the `hw:CARD` line that corresponds with the output device you want to use. Note the `<device_name>` for the next step.
```

```plain
<number> hw:CARD=<device_name>,DEV=<device_number>
```
8. Edit the file `/etc/default/snapclient` and modify the `SNAPCLIENT_OPTS`.
```

8. Edit the file `/etc/default/snapclient` and modify the `SNAPCLIENT_OPTS`.

```ini
SNAPCLIENT_OPTS=" --host <hostname> -s <dervice_name> "
```

9. Restart the snapclient service.
```

```shell
sudo service snapclient restart
```

Expand Down
4 changes: 2 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ if(ANDROID)
target_link_libraries(snapcast_test log)
endif(ANDROID)

target_link_libraries(snapcast_test Catch2::Catch2WithMain OpenSSL::Crypto
OpenSSL::SSL Catch2::Catch2)
target_link_libraries(snapcast_test OpenSSL::Crypto OpenSSL::SSL)
target_link_libraries(snapcast_test Catch2::Catch2WithMain Catch2::Catch2)
30 changes: 15 additions & 15 deletions test/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ TEST_CASE("String utils")

strings = split("*", '*');
REQUIRE(strings.size() == 2);
REQUIRE(strings[0] == "");
REQUIRE(strings[1] == "");
REQUIRE(strings[0].empty());
REQUIRE(strings[1].empty());

strings = split("**", '*');
REQUIRE(strings.size() == 3);
REQUIRE(strings[0] == "");
REQUIRE(strings[1] == "");
REQUIRE(strings[2] == "");
REQUIRE(strings[0].empty());
REQUIRE(strings[1].empty());
REQUIRE(strings[2].empty());

strings = split("1*2", '*');
REQUIRE(strings.size() == 2);
Expand All @@ -70,21 +70,21 @@ TEST_CASE("String utils")
strings = split("1**2", '*');
REQUIRE(strings.size() == 3);
REQUIRE(strings[0] == "1");
REQUIRE(strings[1] == "");
REQUIRE(strings[1].empty());
REQUIRE(strings[2] == "2");

strings = split("*1*2", '*');
REQUIRE(strings.size() == 3);
REQUIRE(strings[0] == "");
REQUIRE(strings[0].empty());
REQUIRE(strings[1] == "1");
REQUIRE(strings[2] == "2");

strings = split("*1*2*", '*');
REQUIRE(strings.size() == 4);
REQUIRE(strings[0] == "");
REQUIRE(strings[0].empty());
REQUIRE(strings[1] == "1");
REQUIRE(strings[2] == "2");
REQUIRE(strings[3] == "");
REQUIRE(strings[3].empty());

std::vector<std::string> vec{"1", "2", "3"};
REQUIRE(container_to_string(vec) == "1, 2, 3");
Expand Down Expand Up @@ -442,11 +442,11 @@ TEST_CASE("Librespot2")
size_t n = 0;
size_t title_pos = 0;
size_t ms_pos = 0;
if (((title_pos = line.find("<")) != std::string::npos) && ((n = line.find(">", title_pos)) != std::string::npos) &&
((ms_pos = line.find("(", n)) != std::string::npos) && ((n = line.find("ms) loaded", ms_pos)) != std::string::npos))
if (((title_pos = line.find('<')) != std::string::npos) && ((n = line.find('>', title_pos)) != std::string::npos) &&
((ms_pos = line.find('(', n)) != std::string::npos) && ((n = line.find("ms) loaded", ms_pos)) != std::string::npos))
{
title_pos += 1;
std::string title = line.substr(title_pos, line.find(">", title_pos) - title_pos);
std::string title = line.substr(title_pos, line.find('>', title_pos) - title_pos);
REQUIRE(title == "Tunnel");
ms_pos += 1;
std::string ms = line.substr(ms_pos, n - ms_pos - 1);
Expand Down Expand Up @@ -616,11 +616,11 @@ TEST_CASE("Error")
REQUIRE(ec);
REQUIRE(ec == ControlErrc::can_not_control);
REQUIRE(ec != ControlErrc::success);
std::cout << ec << std::endl;
std::cout << ec << '\n';

ec = make_error_code(ControlErrc::can_not_control);
REQUIRE(ec.category() == snapcast::error::control::category());
std::cout << "Category: " << ec.category().name() << ", " << ec.message() << std::endl;
std::cout << "Category: " << ec.category().name() << ", " << ec.message() << '\n';

snapcast::ErrorCode error_code{};
REQUIRE(!error_code);
Expand All @@ -639,7 +639,7 @@ TEST_CASE("ErrorOr")
// Move value out
REQUIRE(error_or.takeValue() == "test");
// Value has been moved out, get will return an empty string
REQUIRE(error_or.getValue() == "");
REQUIRE(error_or.getValue().empty());
}

{
Expand Down

0 comments on commit ce743ce

Please sign in to comment.