| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef SERVICES_MEDIA_AUDIO_PLATFORM_LINUX_ALSA_OUTPUT_H_ | 5 #ifndef SERVICES_MEDIA_AUDIO_PLATFORM_LINUX_ALSA_OUTPUT_H_ |
| 6 #define SERVICES_MEDIA_AUDIO_PLATFORM_LINUX_ALSA_OUTPUT_H_ | 6 #define SERVICES_MEDIA_AUDIO_PLATFORM_LINUX_ALSA_OUTPUT_H_ |
| 7 | 7 |
| 8 #include <alsa/asoundlib.h> | 8 #include <alsa/asoundlib.h> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 // AudioOutput implementation | 30 // AudioOutput implementation |
| 31 MediaResult Init() override; | 31 MediaResult Init() override; |
| 32 void Cleanup() override; | 32 void Cleanup() override; |
| 33 | 33 |
| 34 // StandardOutputBase implementation | 34 // StandardOutputBase implementation |
| 35 bool StartMixJob(MixJob* job, const LocalTime& process_start) override; | 35 bool StartMixJob(MixJob* job, const LocalTime& process_start) override; |
| 36 bool FinishMixJob(const MixJob& job) override; | 36 bool FinishMixJob(const MixJob& job) override; |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 void FillMixBufWithSilence(uint32_t frames); | |
| 40 void HandleAlsaError(snd_pcm_sframes_t code); | 39 void HandleAlsaError(snd_pcm_sframes_t code); |
| 41 void HandleAsError(snd_pcm_sframes_t code); | 40 void HandleAsError(snd_pcm_sframes_t code); |
| 42 void HandleAsUnderflow(); | 41 void HandleAsUnderflow(); |
| 43 | 42 |
| 44 snd_pcm_t* alsa_device_ = nullptr; | 43 snd_pcm_t* alsa_device_ = nullptr; |
| 45 snd_pcm_format_t alsa_format_; | 44 snd_pcm_format_t alsa_format_; |
| 46 | 45 |
| 47 LinearTransform::Ratio frames_per_tick_; | 46 LinearTransform::Ratio frames_per_tick_; |
| 48 uint8_t silence_byte_; | |
| 49 | 47 |
| 50 std::unique_ptr<uint8_t> mix_buf_; | 48 std::unique_ptr<uint8_t> mix_buf_; |
| 51 uint32_t mix_buf_frames_; | 49 uint32_t mix_buf_frames_; |
| 52 | 50 |
| 53 bool primed_ = false; | 51 bool primed_ = false; |
| 54 bool local_to_output_known_ = false; | 52 bool local_to_output_known_ = false; |
| 55 LinearTransform local_to_output_; | 53 LinearTransform local_to_output_; |
| 56 uint32_t local_to_output_gen_ = MixJob::INVALID_GENERATION + 1; | 54 uint32_t local_to_output_gen_ = MixJob::INVALID_GENERATION + 1; |
| 57 int64_t frames_sent_; | 55 int64_t frames_sent_; |
| 58 }; | 56 }; |
| 59 | 57 |
| 60 } // namespace audio | 58 } // namespace audio |
| 61 } // namespace media | 59 } // namespace media |
| 62 } // namespace mojo | 60 } // namespace mojo |
| 63 | 61 |
| 64 #endif // SERVICES_MEDIA_AUDIO_PLATFORM_LINUX_ALSA_OUTPUT_H_ | 62 #endif // SERVICES_MEDIA_AUDIO_PLATFORM_LINUX_ALSA_OUTPUT_H_ |
| 65 | 63 |
| OLD | NEW |