From 1d5038de2f0ffc0849be3583f2984f8d8fc91bd5 Mon Sep 17 00:00:00 2001 From: badaix Date: Sun, 1 May 2016 13:16:55 +0200 Subject: [PATCH] exception prints supported sample formats --- client/player/alsaPlayer.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/client/player/alsaPlayer.cpp b/client/player/alsaPlayer.cpp index f71c91c7..647cbb48 100644 --- a/client/player/alsaPlayer.cpp +++ b/client/player/alsaPlayer.cpp @@ -74,7 +74,17 @@ void AlsaPlayer::initAlsa() throw SnapException("Unsupported sample format: " + cpt::to_string(format.bits)); if ((pcm = snd_pcm_hw_params_set_format(handle_, params, snd_pcm_format)) < 0) - throw SnapException("Can't set format: " + string(snd_strerror(pcm))); + { + stringstream ss; + ss << "Can't set format: " << string(snd_strerror(pcm)) << ", supported: "; + for (int format = 0; format <= (int)SND_PCM_FORMAT_LAST; format++) + { + snd_pcm_format_t snd_pcm_format = static_cast(format); + if (snd_pcm_hw_params_test_format(handle_, params, snd_pcm_format) == 0) + ss << snd_pcm_format_name(snd_pcm_format) << " "; + } + throw SnapException(ss.str()); + } if ((pcm = snd_pcm_hw_params_set_channels(handle_, params, channels)) < 0) throw SnapException("Can't set channels number: " + string(snd_strerror(pcm)));