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

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

Issue 1712513002: Replace scoped_ptr with unique_ptr in webrtc/common_audio/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase 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
16 #include "webrtc/base/checks.h" 18 #include "webrtc/base/checks.h"
17 #include "webrtc/base/gtest_prod_util.h" 19 #include "webrtc/base/gtest_prod_util.h"
18 #include "webrtc/base/scoped_ptr.h"
19 #include "webrtc/common_audio/include/audio_util.h" 20 #include "webrtc/common_audio/include/audio_util.h"
20 21
21 namespace webrtc { 22 namespace webrtc {
22 23
23 // Helper to encapsulate a contiguous data buffer, full or split into frequency 24 // Helper to encapsulate a contiguous data buffer, full or split into frequency
24 // bands, with access to a pointer arrays of the deinterleaved channels and 25 // bands, with access to a pointer arrays of the deinterleaved channels and
25 // bands. The buffer is zero initialized at creation. 26 // bands. The buffer is zero initialized at creation.
26 // 27 //
27 // The buffer structure is showed below for a 2 channel and 2 bands case: 28 // The buffer structure is showed below for a 2 channel and 2 bands case:
28 // 29 //
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 size_t num_channels() const { return num_channels_; } 119 size_t num_channels() const { return num_channels_; }
119 size_t num_bands() const { return num_bands_; } 120 size_t num_bands() const { return num_bands_; }
120 size_t size() const {return num_frames_ * num_channels_; } 121 size_t size() const {return num_frames_ * num_channels_; }
121 122
122 void SetDataForTesting(const T* data, size_t size) { 123 void SetDataForTesting(const T* data, size_t size) {
123 RTC_CHECK_EQ(size, this->size()); 124 RTC_CHECK_EQ(size, this->size());
124 memcpy(data_.get(), data, size * sizeof(*data)); 125 memcpy(data_.get(), data, size * sizeof(*data));
125 } 126 }
126 127
127 private: 128 private:
128 rtc::scoped_ptr<T[]> data_; 129 std::unique_ptr<T[]> data_;
129 rtc::scoped_ptr<T* []> channels_; 130 std::unique_ptr<T* []> channels_;
130 rtc::scoped_ptr<T* []> bands_; 131 std::unique_ptr<T* []> bands_;
131 const size_t num_frames_; 132 const size_t num_frames_;
132 const size_t num_frames_per_band_; 133 const size_t num_frames_per_band_;
133 const size_t num_channels_; 134 const size_t num_channels_;
134 const size_t num_bands_; 135 const size_t num_bands_;
135 }; 136 };
136 137
137 // One int16_t and one float ChannelBuffer that are kept in sync. The sync is 138 // One int16_t and one float ChannelBuffer that are kept in sync. The sync is
138 // broken when someone requests write access to either ChannelBuffer, and 139 // broken when someone requests write access to either ChannelBuffer, and
139 // reestablished when someone requests the outdated ChannelBuffer. It is 140 // reestablished when someone requests the outdated ChannelBuffer. It is
140 // therefore safe to use the return value of ibuf_const() and fbuf_const() 141 // therefore safe to use the return value of ibuf_const() and fbuf_const()
(...skipping 19 matching lines...) Expand all
160 161
161 mutable bool ivalid_; 162 mutable bool ivalid_;
162 mutable ChannelBuffer<int16_t> ibuf_; 163 mutable ChannelBuffer<int16_t> ibuf_;
163 mutable bool fvalid_; 164 mutable bool fvalid_;
164 mutable ChannelBuffer<float> fbuf_; 165 mutable ChannelBuffer<float> fbuf_;
165 }; 166 };
166 167
167 } // namespace webrtc 168 } // namespace webrtc
168 169
169 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_CHANNEL_BUFFER_H_ 170 #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