Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: services/media/audio/platform/linux/alsa_output.h

Issue 1419593007: Add an ALSA output to the motown audio server. (Closed) Base URL: https://github.com/domokit/mojo.git@change5
Patch Set: fixing android build Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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);
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 FillMixBufWithSilence(uint32_t frames);
40 void HandleAlsaError(snd_pcm_sframes_t code);
41 void HandleAsError(snd_pcm_sframes_t code);
42 void HandleAsUnderflow();
43
44 snd_pcm_t* alsa_device_ = nullptr;
45 snd_pcm_format_t alsa_format_;
46
47 LinearTransform::Ratio frames_per_tick_;
48 uint8_t silence_byte_;
49
50 std::unique_ptr<uint8_t> mix_buf_;
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
OLDNEW
« no previous file with comments | « services/media/audio/audio_output_manager.cc ('k') | services/media/audio/platform/linux/alsa_output.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698