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

Side by Side Diff: services/media/audio/platform/generic/mixer.h

Issue 1424933002: Add an initial revision of an audio server. (Closed) Base URL: https://github.com/domokit/mojo.git@change4
Patch Set: fix issues discovered with initial preflight 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
« no previous file with comments | « services/media/audio/fwd_decls.h ('k') | services/media/audio/platform/generic/mixer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_GENERIC_MIXER_H_
6 #define SERVICES_MEDIA_AUDIO_PLATFORM_GENERIC_MIXER_H_
7
8 #include <memory>
9
10 #include "mojo/services/media/common/interfaces/media_types.mojom.h"
11
12 namespace mojo {
13 namespace media {
14 namespace audio {
15
16 class Mixer;
17 using MixerPtr = std::unique_ptr<Mixer>;
18
19 class Mixer {
20 public:
21 virtual ~Mixer();
22
23 // Select
24 //
25 // Select an appropriate instance of a mixer based on the properties of the
26 // source and destination formats.
27 //
28 // TODO(johngro): Come back here and add a way to indicate user preference
29 // where appropriate. For example, where we might chose a linear
30 // interpolation sampler, the user may actually prefer cubic interpolation, or
31 // perhaps just a point sampler.
32 static MixerPtr Select(const LpcmMediaTypeDetailsPtr& src_format,
33 const LpcmMediaTypeDetailsPtr& dst_format);
34
35 // Mix
36 //
37 // Perform a mixing operation from the source buffer into the destination
38 // buffer.
39 //
40 // @param dst
41 // The pointer to the destination buffer into which frames will be mixed.
42 //
43 // @param dst_frames
44 // The total number of frames of audio which comprise the destination buffer.
45 //
46 // @param dst_offset
47 // The pointer to the offset (in destination frames) at which we should start
48 // to mix destination frames. When Mix has finished, dst_offset will be
49 // updated to indicate the offset into the destination buffer of the next
50 // frame to be mixed.
51 //
52 // @param src
53 // The pointer the the source buffer containing the frames to be mixed into
54 // the destination buffer.
55 //
56 // @param frac_src_frames
57 // The total number of fractional track frames contained by the source buffer.
58 //
59 // @param frac_src_offset
60 // A pointer to the offset (expressed in fractional track frames) at which the
61 // first frame to be mixed with the destination buffer should be sampled.
62 // When Mix has finished, frac_src_offset will be updated to indicate the
63 // offset of the sampling position of the next frame to be mixed with the
64 // output buffer.
65 //
66 // @param frac_step_size
67 // How much to increment the fractional sampling position for each output
68 // frame produced.
69 //
70 // TODO(johngro): Right now, this number may have some amount of rounding
71 // error which will accumulate as sampling position error as we produce more
72 // output samples for a single call to Mix. This error will reset when we
73 // swtich to the next source buffer, but could (in theory) be the source of
74 // distortion. If this becomes a problem, we should consider switching to
75 // some form of (N,M) stepping system where we count by frac_step_size for N
76 // output samples, then frac_step_size+1 for M samples, etc...
77 //
78 // @param accumulate
79 // When true, the mixer will accumulate into the destination buffer (read,
80 // sum, clip, write-back). When false, the mixer will simply replace the
81 // destination buffer with its output.
82 //
83 // @return True if the mixer is finished with this source data and will not
84 // need it in the future. False if the mixer has not consumed the entire
85 // source buffer and will need more of it in the future.
86 virtual bool Mix(void* dst,
87 uint32_t dst_frames,
88 uint32_t* dst_offset,
89 const void* src,
90 uint32_t frac_src_frames,
91 uint32_t* frac_src_offset,
92 uint32_t frac_step_size,
93 bool accumulate) = 0;
94
95 // Reset
96 //
97 // Reset the internal state of the mixer. Will be called every time there is
98 // a discontinuity in the source stream. Mixer implementations should reset
99 // anything related to their internal filter state.
100 virtual void Reset() {}
101
102 protected:
103 Mixer();
104 };
105
106 } // namespace audio
107 } // namespace media
108 } // namespace mojo
109
110 #endif // SERVICES_MEDIA_AUDIO_PLATFORM_GENERIC_MIXER_H_
OLDNEW
« no previous file with comments | « services/media/audio/fwd_decls.h ('k') | services/media/audio/platform/generic/mixer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698