diff options
-rw-r--r-- | media/audio/linux/alsa_output.cc | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/media/audio/linux/alsa_output.cc b/media/audio/linux/alsa_output.cc index f53d855..e7dab51 100644 --- a/media/audio/linux/alsa_output.cc +++ b/media/audio/linux/alsa_output.cc @@ -90,15 +90,27 @@ AlsaPCMOutputStream::AlsaPCMOutputStream(const std::string& device_name, packet_size_(0), device_write_suspended_(true), // Start suspended. resources_released_(false) { - CHECK(channels_ == 2) << "Only 2-channel audio is supported right now."; - CHECK(AudioManager::AUDIO_PCM_LINEAR == format) - << "Only linear PCM supported."; - CHECK(bits_per_sample % 8 == 0) << "Only allow byte-aligned samples"; - // Reference self to avoid accidental deletion before the message loop is // done. AddRef(); + // Sanity check input values. + if (channels_ != 2) { + LOG(WARNING) << "Only 2-channel audio is supported right now."; + state_ = STATE_ERROR; + } + + if (AudioManager::AUDIO_PCM_LINEAR != format) { + LOG(WARNING) << "Only linear PCM supported."; + state_ = STATE_ERROR; + } + + if (bits_per_sample % 8 != 0) { + // We do this explicitly just incase someone messes up the switch below. + LOG(WARNING) << "Only allow byte-aligned samples"; + state_ = STATE_ERROR; + } + switch (bits_per_sample) { case 8: pcm_format_ = SND_PCM_FORMAT_S8; |