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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/media/audio/platform/linux/alsa_output.h
diff --git a/services/media/audio/platform/linux/alsa_output.h b/services/media/audio/platform/linux/alsa_output.h
new file mode 100644
index 0000000000000000000000000000000000000000..1da2ca27de2c16d856ec3a1ea4fc94183e524462
--- /dev/null
+++ b/services/media/audio/platform/linux/alsa_output.h
@@ -0,0 +1,65 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SERVICES_MEDIA_AUDIO_PLATFORM_LINUX_ALSA_OUTPUT_H_
+#define SERVICES_MEDIA_AUDIO_PLATFORM_LINUX_ALSA_OUTPUT_H_
+
+#include <alsa/asoundlib.h>
+#include <memory>
+
+#include "mojo/services/media/common/cpp/linear_transform.h"
+#include "mojo/services/media/common/interfaces/media_types.mojom.h"
+#include "services/media/audio/audio_output.h"
+#include "services/media/audio/platform/generic/standard_output_base.h"
+
+namespace mojo {
+namespace media {
+namespace audio {
+
+class AlsaOutput : public StandardOutputBase {
+ public:
+ static AudioOutputPtr New(AudioOutputManager* manager);
+ ~AlsaOutput() override;
+
+ MediaResult Configure(LpcmMediaTypeDetailsPtr config);
+
+ protected:
+ explicit AlsaOutput(AudioOutputManager* manager);
+
+ // AudioOutput implementation
+ MediaResult Init() override;
+ void Cleanup() override;
+
+ // StandardOutputBase implementation
+ bool StartMixJob(MixJob* job, const LocalTime& process_start) override;
+ bool FinishMixJob(const MixJob& job) override;
+
+ private:
+ void FillMixBufWithSilence(uint32_t frames);
+ void HandleAlsaError(snd_pcm_sframes_t code);
+ void HandleAsError(snd_pcm_sframes_t code);
+ void HandleAsUnderflow();
+
+ snd_pcm_t* alsa_device_ = nullptr;
+ snd_pcm_format_t alsa_format_;
+
+ LinearTransform::Ratio frames_per_tick_;
+ uint8_t silence_byte_;
+
+ std::unique_ptr<uint8_t> mix_buf_;
+ uint32_t mix_buf_frames_;
+
+ bool primed_ = false;
+ bool local_to_output_known_ = false;
+ LinearTransform local_to_output_;
+ uint32_t local_to_output_gen_ = MixJob::INVALID_GENERATION + 1;
+ int64_t frames_sent_;
+};
+
+} // namespace audio
+} // namespace media
+} // namespace mojo
+
+#endif // SERVICES_MEDIA_AUDIO_PLATFORM_LINUX_ALSA_OUTPUT_H_
+
« 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