summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2016-11-04 10:35:03 +0100
committerMax Kellermann <max@musicpd.org>2016-11-04 11:31:23 +0100
commit93a14a93f9bd6056d375550cea8064361787ee14 (patch)
treefab8295380c3ecab462a0b0c13f52180de67615b
parentd6559e2ac996103085bf32697eda4a3ff89fb186 (diff)
output/alsa: use Error::FormatPrefix()
-rw-r--r--src/output/plugins/AlsaOutputPlugin.cxx33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/output/plugins/AlsaOutputPlugin.cxx b/src/output/plugins/AlsaOutputPlugin.cxx
index 849e5ac6c..d48a9ca4f 100644
--- a/src/output/plugins/AlsaOutputPlugin.cxx
+++ b/src/output/plugins/AlsaOutputPlugin.cxx
@@ -501,8 +501,7 @@ configure_hw:
err = AlsaSetupFormat(ad->pcm, hwparams, audio_format, params);
if (err < 0) {
error.Format(alsa_output_domain, err,
- "ALSA device \"%s\" does not support format %s: %s",
- ad->GetDevice(),
+ "Failed to configure format %s: %s",
sample_format_to_string(audio_format.format),
snd_strerror(-err));
return false;
@@ -518,8 +517,8 @@ configure_hw:
&channels);
if (err < 0) {
error.Format(alsa_output_domain, err,
- "ALSA device \"%s\" does not support %i channels: %s",
- ad->GetDevice(), (int)audio_format.channels,
+ "Failed to configure %i channels: %s",
+ (int)audio_format.channels,
snd_strerror(-err));
return false;
}
@@ -527,12 +526,21 @@ configure_hw:
err = snd_pcm_hw_params_set_rate_near(ad->pcm, hwparams,
&sample_rate, nullptr);
- if (err < 0 || sample_rate == 0) {
+ if (err < 0) {
error.Format(alsa_output_domain, err,
- "ALSA device \"%s\" does not support %u Hz audio",
- ad->GetDevice(), audio_format.sample_rate);
+ "Failed to configure sample rate %u Hz: %s",
+ audio_format.sample_rate,
+ snd_strerror(-err));
return false;
}
+
+ if (sample_rate == 0) {
+ error.Format(alsa_output_domain, err,
+ "Failed to configure sample rate %u Hz",
+ audio_format.sample_rate);
+ return false;
+ }
+
audio_format.sample_rate = sample_rate;
snd_pcm_uframes_t buffer_size_min, buffer_size_max;
@@ -660,8 +668,8 @@ configure_hw:
error:
error.Format(alsa_output_domain, err,
- "Error opening ALSA device \"%s\" (%s): %s",
- ad->GetDevice(), cmd, snd_strerror(-err));
+ "%s failed: %s",
+ cmd, snd_strerror(-err));
return false;
}
@@ -698,9 +706,8 @@ AlsaOutput::SetupDop(const AudioFormat audio_format,
if (dop_format != check) {
/* no bit-perfect playback, which is required
for DSD over USB */
- error.Format(alsa_output_domain,
- "Failed to configure DSD-over-PCM on ALSA device \"%s\"",
- GetDevice());
+ error.Set(alsa_output_domain,
+ "Failed to configure DSD-over-PCM");
delete[] silence;
return false;
}
@@ -757,6 +764,8 @@ AlsaOutput::Open(AudioFormat &audio_format, Error &error)
if (!SetupOrDop(audio_format, params, error)) {
snd_pcm_close(pcm);
+ error.FormatPrefix("Error opening ALSA device \"%s\": ",
+ GetDevice());
return false;
}