| 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 <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "mojo/services/media/common/cpp/linear_transform.h" | 10 #include "mojo/services/media/common/cpp/linear_transform.h" |
| 11 #include "mojo/services/media/common/interfaces/media_types.mojom.h" | 11 #include "mojo/services/media/common/interfaces/media_types.mojom.h" |
| 12 #include "services/media/audio/audio_output.h" | 12 #include "services/media/audio/audio_output.h" |
| 13 #include "services/media/audio/platform/generic/standard_output_base.h" | 13 #include "services/media/audio/platform/generic/standard_output_base.h" |
| 14 | 14 |
| 15 namespace mojo { | 15 namespace mojo { |
| 16 namespace media { | 16 namespace media { |
| 17 namespace audio { | 17 namespace audio { |
| 18 | 18 |
| 19 class AlsaOutput : public StandardOutputBase { | 19 class AlsaOutput : public StandardOutputBase { |
| 20 public: | 20 public: |
| 21 static AudioOutputPtr New(AudioOutputManager* manager); | 21 static AudioOutputPtr New(AudioOutputManager* manager); |
| 22 ~AlsaOutput() override; | 22 ~AlsaOutput() override; |
| 23 | 23 |
| 24 MediaResult Configure(LpcmMediaTypeDetailsPtr config); | 24 MediaResult Configure(AudioMediaTypeDetailsPtr config); |
| 25 | 25 |
| 26 protected: | 26 protected: |
| 27 explicit AlsaOutput(AudioOutputManager* manager); | 27 explicit AlsaOutput(AudioOutputManager* manager); |
| 28 | 28 |
| 29 // AudioOutput implementation | 29 // AudioOutput implementation |
| 30 MediaResult Init() override; | 30 MediaResult Init() override; |
| 31 void Cleanup() override; | 31 void Cleanup() override; |
| 32 | 32 |
| 33 // StandardOutputBase implementation | 33 // StandardOutputBase implementation |
| 34 bool StartMixJob(MixJob* job, const LocalTime& process_start) override; | 34 bool StartMixJob(MixJob* job, const LocalTime& process_start) override; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 45 | 45 |
| 46 void HandleAlsaError(int code); | 46 void HandleAlsaError(int code); |
| 47 void HandleAsError(int code); | 47 void HandleAsError(int code); |
| 48 void HandleAsUnderflow(); | 48 void HandleAsUnderflow(); |
| 49 | 49 |
| 50 // libtinyalsa vs. libasound abstraction. Methods are implemented either in | 50 // libtinyalsa vs. libasound abstraction. Methods are implemented either in |
| 51 // alsa_output_tinyalsa.cc or alsa_output_desktop.cc depending on the target | 51 // alsa_output_tinyalsa.cc or alsa_output_desktop.cc depending on the target |
| 52 // we are building for. | 52 // we are building for. |
| 53 MediaResult AlsaOpen(); | 53 MediaResult AlsaOpen(); |
| 54 void AlsaClose(); | 54 void AlsaClose(); |
| 55 MediaResult AlsaSelectFormat(const LpcmMediaTypeDetailsPtr& config); | 55 MediaResult AlsaSelectFormat(const AudioMediaTypeDetailsPtr& config); |
| 56 int AlsaWrite(const void* data, uint32_t frames); | 56 int AlsaWrite(const void* data, uint32_t frames); |
| 57 int AlsaGetAvailDelay(uint32_t* avail, uint32_t* delay = nullptr); | 57 int AlsaGetAvailDelay(uint32_t* avail, uint32_t* delay = nullptr); |
| 58 int AlsaRecover(int err_code); | 58 int AlsaRecover(int err_code); |
| 59 | 59 |
| 60 void* alsa_device_ = nullptr; | 60 void* alsa_device_ = nullptr; |
| 61 int32_t alsa_format_ = -1; | 61 int32_t alsa_format_ = -1; |
| 62 | 62 |
| 63 LinearTransform::Ratio frames_per_tick_; | 63 LinearTransform::Ratio frames_per_tick_; |
| 64 | 64 |
| 65 std::unique_ptr<uint8_t> mix_buf_; | 65 std::unique_ptr<uint8_t> mix_buf_; |
| 66 uint32_t mix_buf_frames_ = 0; | 66 uint32_t mix_buf_frames_ = 0; |
| 67 | 67 |
| 68 bool primed_ = false; | 68 bool primed_ = false; |
| 69 bool local_to_output_known_ = false; | 69 bool local_to_output_known_ = false; |
| 70 LinearTransform local_to_output_; | 70 LinearTransform local_to_output_; |
| 71 uint32_t local_to_output_gen_ = MixJob::INVALID_GENERATION + 1; | 71 uint32_t local_to_output_gen_ = MixJob::INVALID_GENERATION + 1; |
| 72 int64_t frames_sent_; | 72 int64_t frames_sent_; |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 } // namespace audio | 75 } // namespace audio |
| 76 } // namespace media | 76 } // namespace media |
| 77 } // namespace mojo | 77 } // namespace mojo |
| 78 | 78 |
| 79 #endif // SERVICES_MEDIA_AUDIO_PLATFORM_LINUX_ALSA_OUTPUT_H_ | 79 #endif // SERVICES_MEDIA_AUDIO_PLATFORM_LINUX_ALSA_OUTPUT_H_ |
| 80 | |
| OLD | NEW |