OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef SERVICES_MEDIA_AUDIO_PLATFORM_LINUX_ALSA_OUTPUT_H_ | |
6 #define SERVICES_MEDIA_AUDIO_PLATFORM_LINUX_ALSA_OUTPUT_H_ | |
7 | |
8 #include <alsa/asoundlib.h> | |
9 #include <memory> | |
10 | |
11 #include "mojo/services/media/common/cpp/linear_transform.h" | |
12 #include "mojo/services/media/common/interfaces/media_types.mojom.h" | |
13 #include "services/media/audio/audio_output.h" | |
14 #include "services/media/audio/platform/generic/standard_output_base.h" | |
15 | |
16 namespace mojo { | |
17 namespace media { | |
18 namespace audio { | |
19 | |
20 class AlsaOutput : public StandardOutputBase { | |
21 public: | |
22 static AudioOutputPtr New(AudioOutputManager* manager); | |
23 ~AlsaOutput() override; | |
24 | |
25 MediaResult Configure(LpcmMediaTypeDetailsPtr config); | |
jeffbrown
2015/11/04 20:33:43
I wonder whether these Mojo objects should be flow
johngro
2015/11/06 20:22:07
I think that this is proper. LpcmMediaTypeDetails
| |
26 | |
27 protected: | |
28 explicit AlsaOutput(AudioOutputManager* manager); | |
29 | |
30 // AudioOutput implementation | |
31 MediaResult Init() override; | |
32 void Cleanup() override; | |
33 | |
34 // StandardOutputBase implementation | |
35 bool StartMixJob(MixJob* job, const LocalTime& process_start) override; | |
36 bool FinishMixJob(const MixJob& job) override; | |
37 | |
38 private: | |
39 void HandleAlsaError(snd_pcm_sframes_t code); | |
40 void HandleAsError(snd_pcm_sframes_t code); | |
41 void HandleAsUnderflow(); | |
42 | |
43 snd_pcm_t* alsa_device_ = nullptr; | |
44 snd_pcm_format_t alsa_format_; | |
45 | |
46 LinearTransform::Ratio frames_per_tick_; | |
47 uint8_t silence_byte_; | |
48 | |
49 std::unique_ptr<uint8_t> mix_buf_; | |
50 uint32_t mix_buf_bytes_; | |
51 uint32_t mix_buf_frames_; | |
52 | |
53 bool primed_ = false; | |
54 bool local_to_output_known_ = false; | |
55 LinearTransform local_to_output_; | |
56 uint32_t local_to_output_gen_ = MixJob::INVALID_GENERATION + 1; | |
57 int64_t frames_sent_; | |
58 }; | |
59 | |
60 } // namespace audio | |
61 } // namespace media | |
62 } // namespace mojo | |
63 | |
64 #endif // SERVICES_MEDIA_AUDIO_PLATFORM_LINUX_ALSA_OUTPUT_H_ | |
65 | |
OLD | NEW |