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

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

Issue 1471813002: Mix to an intermediate buffer. (Closed) Base URL: https://github.com/domokit/mojo.git@change7
Patch Set: Final rebase before landing Created 4 years, 10 months 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_GENERIC_OUTPUT_FORMATTER_H_
6 #define SERVICES_MEDIA_AUDIO_PLATFORM_GENERIC_OUTPUT_FORMATTER_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 OutputFormatter;
17 using OutputFormatterPtr = std::unique_ptr<OutputFormatter>;
18
19 class OutputFormatter {
20 public:
21 static OutputFormatterPtr Select(
22 const LpcmMediaTypeDetailsPtr& output_format);
23
24 ~OutputFormatter();
25
26 /**
27 * Take frames of audio from the source intermediate buffer and convert them
28 * to the proper sample format for the output buffer, clipping the audio as
29 * needed in the process.
30 *
31 * @note It is assumed that the source intermediate mixing buffer has the same
32 * number of channels and channel ordering as the output buffer.
33 *
34 * @param source A pointer to the normalized frames of audio to use as the
35 * source.
36 *
37 * @param dest A pointer to the destination buffer whose frames match the
38 * format described by output_format during the call to Select.
39 *
40 * @param frames The number of frames to produce.
41 */
42 virtual void ProduceOutput(const int32_t* source,
43 void* dest,
44 uint32_t frames) const = 0;
45
46 /**
47 * Fill a destination buffer with silence.
48 *
49 * @param dest A pointer to the destination buffer whose frames match the
50 * format described by output_format during the call to Select.
51 *
52 * @param frames The number of frames to produce.
53 */
54 virtual void FillWithSilence(void* dest, uint32_t frames) const = 0;
55
56 const LpcmMediaTypeDetailsPtr& format() const { return format_; }
57 uint32_t channels() const { return channels_; }
58 uint32_t bytes_per_sample() const { return bytes_per_sample_; }
59 uint32_t bytes_per_frame() const { return bytes_per_frame_; }
60
61 protected:
62 OutputFormatter(const LpcmMediaTypeDetailsPtr& output_format,
63 uint32_t bytes_per_sample,
64 uint32_t channels);
65
66 LpcmMediaTypeDetailsPtr format_;
67 uint32_t channels_ = 0;
68 uint32_t bytes_per_sample_ = 0;
69 uint32_t bytes_per_frame_ = 0;
70 };
71
72 } // namespace audio
73 } // namespace media
74 } // namespace mojo
75
76 #endif // SERVICES_MEDIA_AUDIO_PLATFORM_GENERIC_OUTPUT_FORMATTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698