output/alsa: add nullptr check for snd_pcm_name() return value
It is not explicitly documented whether snd_pcm_name() is allowed to
return NULL:
https://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m.html#ga5031edc0422df8db1f70af056a12dd77
But apparently this is legal:
0222f45d11/src/pcm/pcm.c (L2761-L2762)
That's ... surprising!
Closes https://github.com/MusicPlayerDaemon/MPD/issues/1645
This commit is contained in:
parent
ccc3ee663b
commit
76b25a1377
2
NEWS
2
NEWS
@ -5,6 +5,8 @@ ver 0.23.10 (not yet released)
|
|||||||
- ffmpeg: fix libfmt 9 compiler warning
|
- ffmpeg: fix libfmt 9 compiler warning
|
||||||
* encoder
|
* encoder
|
||||||
- flac: fix failure when libFLAC is built without Ogg support
|
- flac: fix failure when libFLAC is built without Ogg support
|
||||||
|
* output
|
||||||
|
- alsa: fix crash bug
|
||||||
* Windows
|
* Windows
|
||||||
- log to stdout by default, don't require "log_file" setting
|
- log to stdout by default, don't require "log_file" setting
|
||||||
|
|
||||||
|
@ -812,8 +812,12 @@ AlsaOutput::Open(AudioFormat &audio_format)
|
|||||||
fmt::format("Failed to open ALSA device \"{}\"",
|
fmt::format("Failed to open ALSA device \"{}\"",
|
||||||
GetDevice()).c_str());
|
GetDevice()).c_str());
|
||||||
|
|
||||||
|
const char *pcm_name = snd_pcm_name(pcm);
|
||||||
|
if (pcm_name == nullptr)
|
||||||
|
pcm_name = "?";
|
||||||
|
|
||||||
FmtDebug(alsa_output_domain, "opened {} type={}",
|
FmtDebug(alsa_output_domain, "opened {} type={}",
|
||||||
snd_pcm_name(pcm),
|
pcm_name,
|
||||||
snd_pcm_type_name(snd_pcm_type(pcm)));
|
snd_pcm_type_name(snd_pcm_type(pcm)));
|
||||||
|
|
||||||
#ifdef ENABLE_DSD
|
#ifdef ENABLE_DSD
|
||||||
|
Loading…
Reference in New Issue
Block a user