Skip to content

Commit 5f64722

Browse files
committed
Merge branch 'development' of github.com:mikebrady/shairport-sync into development
forgot online update
2 parents eaf9236 + 7e16d6f commit 5f64722

File tree

2 files changed

+92
-5
lines changed

2 files changed

+92
-5
lines changed

RELEASENOTES-DEVELOPMENT.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1+
Version 4.3.4-dev-3-g238e4bbf
2+
==
3+
**Enhancement -- HDMI Ports**
4+
* If your device has HDMI ports, the Shairport Sync help command has previously listed them with a `hw:` prefix, e.g. `hw:vc4hdmi0`. Unfortunately, if you use a name like that as an `output_device` name for a HDMI device in Shairport Sync, the device may not be usable.
5+
6+
But if you use the `hdmi:` prefix, e.g. `hdmi:vc4hdmi0`, it _may_ work: something capable of receiving audio must be connected to the HDMI port and it must be powered on _when your device boots up_.
7+
8+
The enhancement is to update the help text for the ALSA backend to denote HDMI devices using the `hdmi:` prefix rather than `hw:`. Now, for example, on a Raspberry Pi 4, the output is:
9+
```
10+
Settings and options for the audio backend "alsa":
11+
-d output-device set the output device, default is "default".
12+
-c mixer-control set the mixer control name, default is to use no mixer.
13+
-m mixer-device set the mixer device, default is the output device.
14+
-i mixer-index set the mixer index, default is 0.
15+
hardware output devices:
16+
"hdmi:vc4hdmi0"
17+
"hdmi:vc4hdmi1"
18+
```
19+
Previously it was:
20+
```
21+
Settings and options for the audio backend "alsa":
22+
-d output-device set the output device, default is "default".
23+
-c mixer-control set the mixer control name, default is to use no mixer.
24+
-m mixer-device set the mixer device, default is the output device.
25+
-i mixer-index set the mixer index, default is 0.
26+
hardware output devices:
27+
"hw:vc4hdmi0"
28+
"hw:vc4hdmi1"
29+
```
30+
...which is technically correct but unfortunately not very useful.
31+
32+
Get more information about the hardware output devices using [sps-alsa-explore](https://github.com/mikebrady/sps-alsa-explore) (also available as a Docker image).
33+
134
Version 4.3.4-dev-1-gc945f3a9
235
==
336
This is effectively release version 4.3.3 -- the starting point for 4.3.4.

audio_alsa.c

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,16 +280,70 @@ uint64_t frames_sent_for_playing;
280280
// frames_sent_for_playing (which Shairport Sync might hold) would be invalid.
281281
int frames_sent_break_occurred;
282282

283+
// if a device name ends in ",DEV=0", drop it. Then if it also begins with "CARD=", drop that too.
284+
static void simplify_and_printf_mutable_device_name(char *device_name) {
285+
if (strstr(device_name, ",DEV=0") == device_name + strlen(device_name) - strlen(",DEV=0")) {
286+
char *shortened_device_name = str_replace(device_name, ",DEV=0", "");
287+
char *simplified_device_name = str_replace(shortened_device_name, "CARD=", "");
288+
printf(" \"%s\"\n", simplified_device_name);
289+
free(simplified_device_name);
290+
free(shortened_device_name);
291+
} else {
292+
printf(" \"%s\"\n", device_name);
293+
}
294+
}
295+
283296
static void help(void) {
297+
284298
printf(" -d output-device set the output device, default is \"default\".\n"
285299
" -c mixer-control set the mixer control name, default is to use no mixer.\n"
286300
" -m mixer-device set the mixer device, default is the output device.\n"
287301
" -i mixer-index set the mixer index, default is 0.\n");
288-
int r = system("if [ -d /proc/asound ] ; then echo \" hardware output devices:\" ; ls -al "
289-
"/proc/asound/ 2>/dev/null | grep '\\->' | tr -s ' ' | cut -d ' ' -f 9 | while "
290-
"read line; do echo \" \\\"hw:$line\\\"\" ; done ; fi");
291-
if (r != 0)
292-
debug(2, "error %d executing a script to list alsa hardware device names", r);
302+
// look for devices with a name prefix of hw: or hdmi:
303+
int card_number = -1;
304+
snd_card_next(&card_number);
305+
306+
if (card_number < 0) {
307+
printf(" no hardware output devices found.\n");
308+
}
309+
310+
int at_least_one_device_found = 0;
311+
while (card_number >= 0) {
312+
void **hints;
313+
char *hdmi_str = NULL;
314+
char *hw_str = NULL;
315+
if (snd_device_name_hint(card_number, "pcm", &hints) == 0) {
316+
void **device_on_card_hints = hints;
317+
while (*device_on_card_hints != NULL) {
318+
char *device_on_card_name = snd_device_name_get_hint(*device_on_card_hints, "NAME");
319+
if ((strstr(device_on_card_name, "hw:") == device_on_card_name) && (hw_str == NULL))
320+
hw_str = strdup(device_on_card_name);
321+
if ((strstr(device_on_card_name, "hdmi:") == device_on_card_name) && (hdmi_str == NULL))
322+
hdmi_str = strdup(device_on_card_name);
323+
free(device_on_card_name);
324+
device_on_card_hints++;
325+
}
326+
snd_device_name_free_hint(hints);
327+
if ((hdmi_str != NULL) || (hw_str != NULL)) {
328+
if (at_least_one_device_found == 0) {
329+
printf(" hardware output devices:\n");
330+
at_least_one_device_found = 1;
331+
}
332+
}
333+
if (hdmi_str != NULL) {
334+
simplify_and_printf_mutable_device_name(hdmi_str);
335+
} else if (hw_str != NULL) {
336+
simplify_and_printf_mutable_device_name(hw_str);
337+
}
338+
if (hdmi_str != NULL)
339+
free(hdmi_str);
340+
if (hw_str != NULL)
341+
free(hw_str);
342+
}
343+
snd_card_next(&card_number);
344+
}
345+
if (at_least_one_device_found == 0)
346+
printf(" no hardware output devices found.\n");
293347
}
294348

295349
void set_alsa_out_dev(char *dev) {

0 commit comments

Comments
 (0)