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

Unified Diff: services/media/audio/audio_track_impl.h

Issue 1424933002: Add an initial revision of an audio server. (Closed) Base URL: https://github.com/domokit/mojo.git@change4
Patch Set: refactor MixerKernel into a class to prepare for the addition of a linear interpolation sampler 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
Index: services/media/audio/audio_track_impl.h
diff --git a/services/media/audio/audio_track_impl.h b/services/media/audio/audio_track_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..28859aa1309ce7e587b63d19aa5a6eefc33d5523
--- /dev/null
+++ b/services/media/audio/audio_track_impl.h
@@ -0,0 +1,83 @@
+// 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_AUDIO_TRACK_IMPL_H_
+#define SERVICES_MEDIA_AUDIO_AUDIO_TRACK_IMPL_H_
+
+#include <deque>
+#include <set>
+
+#include "base/synchronization/lock.h"
+#include "mojo/public/cpp/bindings/binding.h"
+#include "mojo/public/cpp/bindings/callback.h"
+#include "mojo/services/media/audio/interfaces/audio_track.mojom.h"
+#include "mojo/services/media/common/cpp/linear_transform.h"
+#include "services/media/audio/audio_pipe.h"
+#include "services/media/audio/fwd_decls.h"
+#include "services/media/common/rate_control_base.h"
+
+namespace mojo {
+namespace media {
+namespace audio {
+
+class AudioTrackImpl : public AudioTrack {
+ public:
+ // TODO(johngro): Find a better place for this constant. It affects the
+ // behavior of more than just the Audio Track implementation.
+ static constexpr size_t PTS_FRACTIONAL_BITS = 12;
jeffbrown 2015/11/04 23:43:33 Maybe make a new fixed point datatype instead.
johngro 2015/11/06 02:20:26 perhaps, but I would rather not at the moment. I
+
+ ~AudioTrackImpl() override;
+ static AudioTrackImplPtr Create(InterfaceRequest<AudioTrack> iface,
+ AudioServerImpl* owner);
+
+ // Implementation of AudioTrack interface.
+ void Describe(const DescribeCallback& cbk) override;
jeffbrown 2015/11/04 23:43:33 These should be private.
johngro 2015/11/06 02:20:26 Done.
+ void Configure(AudioTrackConfigurationPtr configuration,
+ InterfaceRequest<MediaPipe> req,
+ const ConfigureCallback& cbk) override;
+ void GetRateControl(InterfaceRequest<RateControl> req,
+ const GetRateControlCallback& cbk) override;
+
+ // Methods used by the output manager to link this track to different outputs.
+ void AddOutput(AudioTrackToOutputLinkPtr link);
+ void RemoveOutput(AudioTrackToOutputLinkPtr link);
+
+ // Accessors used by AudioOutputs during mixing to access parameters which are
+ // important for the mixing process.
+ void SnapshotRateTrans(LinearTransform* out, uint32_t* generation = nullptr) {
+ rate_control_.SnapshotCurrentTransform(out, generation);
+ }
+
+ const LinearTransform::Ratio& FractionalFrameToMediaTimeRatio() const {
+ return frame_to_media_ratio_;
+ }
+
+ uint32_t BytesPerFrame() const { return bytes_per_frame_; }
+ const LpcmMediaTypeDetailsPtr& Format() const { return format_; }
+
+ private:
+ friend class AudioPipe;
+
+ AudioTrackImpl(InterfaceRequest<AudioTrack> track,
+ AudioServerImpl* owner);
+
+ void OnPacketReceived(AudioPipe::AudioPacketRefPtr packet);
+ void OnFlushRequested(const MediaPipe::FlushCallback& cbk);
+
+ AudioTrackImplWeakPtr weak_this_;
jeffbrown 2015/11/04 23:43:33 Using lots of typedefs makes it harder to understa
johngro 2015/11/06 02:20:26 I'm not sure of exactly what you are concerned abo
+ AudioServerImpl* owner_;
+ Binding<AudioTrack> binding_;
jeffbrown 2015/11/04 23:43:33 alignment is a little wonky here More importantly
johngro 2015/11/06 02:20:26 yeah, this happened because of the global rename f
+ AudioPipe pipe_;
+ RateControlBase rate_control_;
+ LinearTransform::Ratio frame_to_media_ratio_;
+ uint32_t bytes_per_frame_ = 1;
+ LpcmMediaTypeDetailsPtr format_;
+ AudioTrackToOutputLinkSet outputs_;
+};
+
+} // namespace audio
+} // namespace media
+} // namespace mojo
+
+#endif // SERVICES_MEDIA_AUDIO_AUDIO_TRACK_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698