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

Side by Side Diff: webrtc/common_audio/channel_buffer.h

Issue 1726043002: Revert of Replace scoped_ptr with unique_ptr in webrtc/common_audio/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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
« no previous file with comments | « webrtc/common_audio/blocker_unittest.cc ('k') | webrtc/common_audio/channel_buffer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_CHANNEL_BUFFER_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_CHANNEL_BUFFER_H_
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_CHANNEL_BUFFER_H_ 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_CHANNEL_BUFFER_H_
13 13
14 #include <string.h> 14 #include <string.h>
15 15
16 #include <memory>
17
18 #include "webrtc/base/checks.h" 16 #include "webrtc/base/checks.h"
19 #include "webrtc/base/gtest_prod_util.h" 17 #include "webrtc/base/gtest_prod_util.h"
18 #include "webrtc/base/scoped_ptr.h"
20 #include "webrtc/common_audio/include/audio_util.h" 19 #include "webrtc/common_audio/include/audio_util.h"
21 20
22 namespace webrtc { 21 namespace webrtc {
23 22
24 // Helper to encapsulate a contiguous data buffer, full or split into frequency 23 // Helper to encapsulate a contiguous data buffer, full or split into frequency
25 // bands, with access to a pointer arrays of the deinterleaved channels and 24 // bands, with access to a pointer arrays of the deinterleaved channels and
26 // bands. The buffer is zero initialized at creation. 25 // bands. The buffer is zero initialized at creation.
27 // 26 //
28 // The buffer structure is showed below for a 2 channel and 2 bands case: 27 // The buffer structure is showed below for a 2 channel and 2 bands case:
29 // 28 //
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 size_t num_channels() const { return num_channels_; } 118 size_t num_channels() const { return num_channels_; }
120 size_t num_bands() const { return num_bands_; } 119 size_t num_bands() const { return num_bands_; }
121 size_t size() const {return num_frames_ * num_channels_; } 120 size_t size() const {return num_frames_ * num_channels_; }
122 121
123 void SetDataForTesting(const T* data, size_t size) { 122 void SetDataForTesting(const T* data, size_t size) {
124 RTC_CHECK_EQ(size, this->size()); 123 RTC_CHECK_EQ(size, this->size());
125 memcpy(data_.get(), data, size * sizeof(*data)); 124 memcpy(data_.get(), data, size * sizeof(*data));
126 } 125 }
127 126
128 private: 127 private:
129 std::unique_ptr<T[]> data_; 128 rtc::scoped_ptr<T[]> data_;
130 std::unique_ptr<T* []> channels_; 129 rtc::scoped_ptr<T* []> channels_;
131 std::unique_ptr<T* []> bands_; 130 rtc::scoped_ptr<T* []> bands_;
132 const size_t num_frames_; 131 const size_t num_frames_;
133 const size_t num_frames_per_band_; 132 const size_t num_frames_per_band_;
134 const size_t num_channels_; 133 const size_t num_channels_;
135 const size_t num_bands_; 134 const size_t num_bands_;
136 }; 135 };
137 136
138 // One int16_t and one float ChannelBuffer that are kept in sync. The sync is 137 // One int16_t and one float ChannelBuffer that are kept in sync. The sync is
139 // broken when someone requests write access to either ChannelBuffer, and 138 // broken when someone requests write access to either ChannelBuffer, and
140 // reestablished when someone requests the outdated ChannelBuffer. It is 139 // reestablished when someone requests the outdated ChannelBuffer. It is
141 // therefore safe to use the return value of ibuf_const() and fbuf_const() 140 // therefore safe to use the return value of ibuf_const() and fbuf_const()
(...skipping 19 matching lines...) Expand all
161 160
162 mutable bool ivalid_; 161 mutable bool ivalid_;
163 mutable ChannelBuffer<int16_t> ibuf_; 162 mutable ChannelBuffer<int16_t> ibuf_;
164 mutable bool fvalid_; 163 mutable bool fvalid_;
165 mutable ChannelBuffer<float> fbuf_; 164 mutable ChannelBuffer<float> fbuf_;
166 }; 165 };
167 166
168 } // namespace webrtc 167 } // namespace webrtc
169 168
170 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_CHANNEL_BUFFER_H_ 169 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_CHANNEL_BUFFER_H_
OLDNEW
« no previous file with comments | « webrtc/common_audio/blocker_unittest.cc ('k') | webrtc/common_audio/channel_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698