| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <alsa/asoundlib.h> | 5 #include <alsa/asoundlib.h> |
| 6 | 6 |
| 7 #include "services/media/audio/platform/linux/alsa_output.h" | 7 #include "services/media/audio/platform/linux/alsa_output.h" |
| 8 | 8 |
| 9 namespace mojo { | 9 namespace mojo { |
| 10 namespace media { | 10 namespace media { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 void AlsaOutput::AlsaClose() { | 63 void AlsaOutput::AlsaClose() { |
| 64 snd_pcm_t* alsa_device = static_cast<snd_pcm_t*>(alsa_device_); | 64 snd_pcm_t* alsa_device = static_cast<snd_pcm_t*>(alsa_device_); |
| 65 | 65 |
| 66 if (alsa_device) { | 66 if (alsa_device) { |
| 67 snd_pcm_close(alsa_device); | 67 snd_pcm_close(alsa_device); |
| 68 alsa_device_ = nullptr; | 68 alsa_device_ = nullptr; |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 MediaResult AlsaOutput::AlsaSelectFormat( | 72 MediaResult AlsaOutput::AlsaSelectFormat( |
| 73 const LpcmMediaTypeDetailsPtr& config) { | 73 const AudioMediaTypeDetailsPtr& config) { |
| 74 switch (config->sample_format) { | 74 switch (config->sample_format) { |
| 75 case LpcmSampleFormat::UNSIGNED_8: | 75 case AudioSampleFormat::UNSIGNED_8: |
| 76 alsa_format_ = SND_PCM_FORMAT_U8; | 76 alsa_format_ = SND_PCM_FORMAT_U8; |
| 77 break; | 77 break; |
| 78 | 78 |
| 79 case LpcmSampleFormat::SIGNED_16: | 79 case AudioSampleFormat::SIGNED_16: |
| 80 alsa_format_ = SND_PCM_FORMAT_S16; | 80 alsa_format_ = SND_PCM_FORMAT_S16; |
| 81 break; | 81 break; |
| 82 | 82 |
| 83 case LpcmSampleFormat::SIGNED_24_IN_32: | 83 case AudioSampleFormat::SIGNED_24_IN_32: |
| 84 default: | 84 default: |
| 85 return MediaResult::UNSUPPORTED_CONFIG; | 85 return MediaResult::UNSUPPORTED_CONFIG; |
| 86 } | 86 } |
| 87 | 87 |
| 88 return MediaResult::OK; | 88 return MediaResult::OK; |
| 89 } | 89 } |
| 90 | 90 |
| 91 int AlsaOutput::AlsaWrite(const void* data, uint32_t frames) { | 91 int AlsaOutput::AlsaWrite(const void* data, uint32_t frames) { |
| 92 DCHECK(alsa_device_); | 92 DCHECK(alsa_device_); |
| 93 snd_pcm_t* alsa_device = static_cast<snd_pcm_t*>(alsa_device_); | 93 snd_pcm_t* alsa_device = static_cast<snd_pcm_t*>(alsa_device_); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 123 | 123 |
| 124 int AlsaOutput::AlsaRecover(int err_code) { | 124 int AlsaOutput::AlsaRecover(int err_code) { |
| 125 DCHECK(alsa_device_); | 125 DCHECK(alsa_device_); |
| 126 snd_pcm_t* alsa_device = static_cast<snd_pcm_t*>(alsa_device_); | 126 snd_pcm_t* alsa_device = static_cast<snd_pcm_t*>(alsa_device_); |
| 127 return snd_pcm_recover(alsa_device, err_code, true); | 127 return snd_pcm_recover(alsa_device, err_code, true); |
| 128 } | 128 } |
| 129 | 129 |
| 130 } // namespace audio | 130 } // namespace audio |
| 131 } // namespace media | 131 } // namespace media |
| 132 } // namespace mojo | 132 } // namespace mojo |
| OLD | NEW |