Fix Linter issues

This commit is contained in:
badaix 2025-01-05 17:50:58 +01:00
parent 72358cd912
commit ce743ce4c6
6 changed files with 60 additions and 42 deletions

View file

@ -4,7 +4,7 @@ WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: file
User: johannes
User: badaix
CheckOptions:
- key: modernize-loop-convert.MaxCopySize
value: '16'

View file

@ -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`
@ -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
```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:
```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:
``` 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)
@ -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:
```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:

View file

@ -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
@ -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

View file

@ -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
```
@ -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`.
```
```ini
SNAPCLIENT_OPTS=" --host <hostname> -s <dervice_name> "
```
9. Restart the snapclient service.
```
```shell
sudo service snapclient restart
```

View file

@ -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)

View file

@ -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);
@ -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");
@ -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);
@ -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);
@ -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());
}
{