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

Side by Side Diff: webrtc/modules/audio_processing/test/audio_file_processor.cc

Issue 1694423002: Replace scoped_ptr with unique_ptr in webrtc/modules/audio_processing/test/ (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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 #include "webrtc/modules/audio_processing/test/audio_file_processor.h" 11 #include "webrtc/modules/audio_processing/test/audio_file_processor.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <utility> 14 #include <utility>
15 15
16 #include "webrtc/base/checks.h" 16 #include "webrtc/base/checks.h"
17 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" 17 #include "webrtc/modules/audio_processing/test/protobuf_utils.h"
18 18
19 using rtc::scoped_ptr;
20 using rtc::CheckedDivExact; 19 using rtc::CheckedDivExact;
21 using std::vector; 20 using std::vector;
22 using webrtc::audioproc::Event; 21 using webrtc::audioproc::Event;
23 using webrtc::audioproc::Init; 22 using webrtc::audioproc::Init;
24 using webrtc::audioproc::ReverseStream; 23 using webrtc::audioproc::ReverseStream;
25 using webrtc::audioproc::Stream; 24 using webrtc::audioproc::Stream;
26 25
27 namespace webrtc { 26 namespace webrtc {
28 namespace { 27 namespace {
29 28
30 // Returns a StreamConfig corresponding to file. 29 // Returns a StreamConfig corresponding to file.
31 StreamConfig GetStreamConfig(const WavFile& file) { 30 StreamConfig GetStreamConfig(const WavFile& file) {
32 return StreamConfig(file.sample_rate(), file.num_channels()); 31 return StreamConfig(file.sample_rate(), file.num_channels());
33 } 32 }
34 33
35 // Returns a ChannelBuffer corresponding to file. 34 // Returns a ChannelBuffer corresponding to file.
36 ChannelBuffer<float> GetChannelBuffer(const WavFile& file) { 35 ChannelBuffer<float> GetChannelBuffer(const WavFile& file) {
37 return ChannelBuffer<float>( 36 return ChannelBuffer<float>(
38 CheckedDivExact(file.sample_rate(), AudioFileProcessor::kChunksPerSecond), 37 CheckedDivExact(file.sample_rate(), AudioFileProcessor::kChunksPerSecond),
39 file.num_channels()); 38 file.num_channels());
40 } 39 }
41 40
42 } // namespace 41 } // namespace
43 42
44 WavFileProcessor::WavFileProcessor(scoped_ptr<AudioProcessing> ap, 43 WavFileProcessor::WavFileProcessor(std::unique_ptr<AudioProcessing> ap,
45 scoped_ptr<WavReader> in_file, 44 std::unique_ptr<WavReader> in_file,
46 scoped_ptr<WavWriter> out_file) 45 std::unique_ptr<WavWriter> out_file)
47 : ap_(std::move(ap)), 46 : ap_(std::move(ap)),
48 in_buf_(GetChannelBuffer(*in_file)), 47 in_buf_(GetChannelBuffer(*in_file)),
49 out_buf_(GetChannelBuffer(*out_file)), 48 out_buf_(GetChannelBuffer(*out_file)),
50 input_config_(GetStreamConfig(*in_file)), 49 input_config_(GetStreamConfig(*in_file)),
51 output_config_(GetStreamConfig(*out_file)), 50 output_config_(GetStreamConfig(*out_file)),
52 buffer_reader_(std::move(in_file)), 51 buffer_reader_(std::move(in_file)),
53 buffer_writer_(std::move(out_file)) {} 52 buffer_writer_(std::move(out_file)) {}
54 53
55 bool WavFileProcessor::ProcessChunk() { 54 bool WavFileProcessor::ProcessChunk() {
56 if (!buffer_reader_.Read(&in_buf_)) { 55 if (!buffer_reader_.Read(&in_buf_)) {
57 return false; 56 return false;
58 } 57 }
59 { 58 {
60 const auto st = ScopedTimer(mutable_proc_time()); 59 const auto st = ScopedTimer(mutable_proc_time());
61 RTC_CHECK_EQ(kNoErr, 60 RTC_CHECK_EQ(kNoErr,
62 ap_->ProcessStream(in_buf_.channels(), input_config_, 61 ap_->ProcessStream(in_buf_.channels(), input_config_,
63 output_config_, out_buf_.channels())); 62 output_config_, out_buf_.channels()));
64 } 63 }
65 buffer_writer_.Write(out_buf_); 64 buffer_writer_.Write(out_buf_);
66 return true; 65 return true;
67 } 66 }
68 67
69 AecDumpFileProcessor::AecDumpFileProcessor(scoped_ptr<AudioProcessing> ap, 68 AecDumpFileProcessor::AecDumpFileProcessor(std::unique_ptr<AudioProcessing> ap,
70 FILE* dump_file, 69 FILE* dump_file,
71 scoped_ptr<WavWriter> out_file) 70 std::unique_ptr<WavWriter> out_file)
72 : ap_(std::move(ap)), 71 : ap_(std::move(ap)),
73 dump_file_(dump_file), 72 dump_file_(dump_file),
74 out_buf_(GetChannelBuffer(*out_file)), 73 out_buf_(GetChannelBuffer(*out_file)),
75 output_config_(GetStreamConfig(*out_file)), 74 output_config_(GetStreamConfig(*out_file)),
76 buffer_writer_(std::move(out_file)) { 75 buffer_writer_(std::move(out_file)) {
77 RTC_CHECK(dump_file_) << "Could not open dump file for reading."; 76 RTC_CHECK(dump_file_) << "Could not open dump file for reading.";
78 } 77 }
79 78
80 AecDumpFileProcessor::~AecDumpFileProcessor() { 79 AecDumpFileProcessor::~AecDumpFileProcessor() {
81 fclose(dump_file_); 80 fclose(dump_file_);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 const auto st = ScopedTimer(mutable_proc_time()); 170 const auto st = ScopedTimer(mutable_proc_time());
172 // TODO(ajm): This currently discards the processed output, which is needed 171 // TODO(ajm): This currently discards the processed output, which is needed
173 // for e.g. intelligibility enhancement. 172 // for e.g. intelligibility enhancement.
174 RTC_CHECK_EQ(kNoErr, ap_->ProcessReverseStream( 173 RTC_CHECK_EQ(kNoErr, ap_->ProcessReverseStream(
175 reverse_buf_->channels(), reverse_config_, 174 reverse_buf_->channels(), reverse_config_,
176 reverse_config_, reverse_buf_->channels())); 175 reverse_config_, reverse_buf_->channels()));
177 } 176 }
178 } 177 }
179 178
180 } // namespace webrtc 179 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698