From 132704d7ed66d674a714c4f66bb49b97c76f5b4d Mon Sep 17 00:00:00 2001 From: badaix Date: Sun, 1 May 2016 19:20:10 +0200 Subject: [PATCH] 32 bit as fallback for 24 bit --- client/player/alsaPlayer.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/client/player/alsaPlayer.cpp b/client/player/alsaPlayer.cpp index 647cbb48..61639bca 100644 --- a/client/player/alsaPlayer.cpp +++ b/client/player/alsaPlayer.cpp @@ -26,7 +26,8 @@ using namespace std; -AlsaPlayer::AlsaPlayer(const PcmDevice& pcmDevice, Stream* stream) : Player(pcmDevice, stream), handle_(NULL), buff_(NULL) +AlsaPlayer::AlsaPlayer(const PcmDevice& pcmDevice, Stream* stream) : + Player(pcmDevice, stream), handle_(NULL), buff_(NULL) { } @@ -73,8 +74,17 @@ void AlsaPlayer::initAlsa() else throw SnapException("Unsupported sample format: " + cpt::to_string(format.bits)); - if ((pcm = snd_pcm_hw_params_set_format(handle_, params, snd_pcm_format)) < 0) + pcm = snd_pcm_hw_params_set_format(handle_, params, snd_pcm_format); + if ((pcm == -EINVAL) && (snd_pcm_format == SND_PCM_FORMAT_S24_LE)) { + snd_pcm_format = SND_PCM_FORMAT_S32_LE; + volCorrection_ = 256; + } + + pcm = snd_pcm_hw_params_set_format(handle_, params, snd_pcm_format); + if (pcm < 0) + { + cerr << "error: " << pcm << "\n"; stringstream ss; ss << "Can't set format: " << string(snd_strerror(pcm)) << ", supported: "; for (int format = 0; format <= (int)SND_PCM_FORMAT_LAST; format++)