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

Unified Diff: webrtc/modules/include/module_common_types.h

Issue 2795103002: Trivial data() and mutable_data() implementations (Closed)
Patch Set: Merge latest Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/include/module_common_types.h
diff --git a/webrtc/modules/include/module_common_types.h b/webrtc/modules/include/module_common_types.h
index 98f7a38af204fe32a17e7c5f84b9d205c203dc2a..a16c9392a2ec62a3d46ae42a47223c092c141745 100644
--- a/webrtc/modules/include/module_common_types.h
+++ b/webrtc/modules/include/module_common_types.h
@@ -279,9 +279,16 @@ class CallStatsObserver {
*/
class AudioFrame {
public:
- // Stereo, 32 kHz, 60 ms (2 * 32 * 60)
+ // Using constexpr here causes linker errors unless the variable also has an
+ // out-of-class definition, which is impractical in this header-only class.
+ // (This makes no sense because it compiles as an enum value, which we most
+ // certainly cannot take the address of, just fine.) C++17 introduces inline
+ // variables which should allow us to switch to constexpr and keep this a
+ // header-only class.
enum : size_t {
- kMaxDataSizeSamples = 3840
+ // Stereo, 32 kHz, 60 ms (2 * 32 * 60)
+ kMaxDataSizeSamples = 3840,
+ kMaxDataSizeBytes = kMaxDataSizeSamples * sizeof(int16_t),
};
enum VADActivity {
@@ -310,6 +317,11 @@ class AudioFrame {
void CopyFrom(const AudioFrame& src);
+ // TODO(yujo): upcoming API update. Currently, both of these just return
+ // data_.
+ const int16_t* data() const;
+ int16_t* mutable_data();
+
// These methods are deprecated. Use the functions in
// webrtc/audio/utility instead. These methods will exists for a
// short period of time until webrtc clients have updated. See
@@ -401,6 +413,14 @@ inline void AudioFrame::CopyFrom(const AudioFrame& src) {
memcpy(data_, src.data_, sizeof(int16_t) * length);
}
+inline const int16_t* AudioFrame::data() const {
+ return data_;
+}
+
+inline int16_t* AudioFrame::mutable_data() {
+ return data_;
+}
+
inline void AudioFrame::Mute() {
memset(data_, 0, samples_per_channel_ * num_channels_ * sizeof(int16_t));
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698