OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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_COMMON_AUDIO_RESAMPLER_PUSH_SINC_RESAMPLER_H_ | 11 #ifndef WEBRTC_COMMON_AUDIO_RESAMPLER_PUSH_SINC_RESAMPLER_H_ |
12 #define WEBRTC_COMMON_AUDIO_RESAMPLER_PUSH_SINC_RESAMPLER_H_ | 12 #define WEBRTC_COMMON_AUDIO_RESAMPLER_PUSH_SINC_RESAMPLER_H_ |
13 | 13 |
14 #include <memory> | |
15 | |
16 #include "webrtc/base/constructormagic.h" | 14 #include "webrtc/base/constructormagic.h" |
| 15 #include "webrtc/base/scoped_ptr.h" |
17 #include "webrtc/common_audio/resampler/sinc_resampler.h" | 16 #include "webrtc/common_audio/resampler/sinc_resampler.h" |
18 #include "webrtc/typedefs.h" | 17 #include "webrtc/typedefs.h" |
19 | 18 |
20 namespace webrtc { | 19 namespace webrtc { |
21 | 20 |
22 // A thin wrapper over SincResampler to provide a push-based interface as | 21 // A thin wrapper over SincResampler to provide a push-based interface as |
23 // required by WebRTC. SincResampler uses a pull-based interface, and will | 22 // required by WebRTC. SincResampler uses a pull-based interface, and will |
24 // use SincResamplerCallback::Run() to request data upon a call to Resample(). | 23 // use SincResamplerCallback::Run() to request data upon a call to Resample(). |
25 // These Run() calls will happen on the same thread Resample() is called on. | 24 // These Run() calls will happen on the same thread Resample() is called on. |
26 class PushSincResampler : public SincResamplerCallback { | 25 class PushSincResampler : public SincResamplerCallback { |
(...skipping 23 matching lines...) Expand all Loading... |
50 } | 49 } |
51 | 50 |
52 protected: | 51 protected: |
53 // Implements SincResamplerCallback. | 52 // Implements SincResamplerCallback. |
54 void Run(size_t frames, float* destination) override; | 53 void Run(size_t frames, float* destination) override; |
55 | 54 |
56 private: | 55 private: |
57 friend class PushSincResamplerTest; | 56 friend class PushSincResamplerTest; |
58 SincResampler* get_resampler_for_testing() { return resampler_.get(); } | 57 SincResampler* get_resampler_for_testing() { return resampler_.get(); } |
59 | 58 |
60 std::unique_ptr<SincResampler> resampler_; | 59 rtc::scoped_ptr<SincResampler> resampler_; |
61 std::unique_ptr<float[]> float_buffer_; | 60 rtc::scoped_ptr<float[]> float_buffer_; |
62 const float* source_ptr_; | 61 const float* source_ptr_; |
63 const int16_t* source_ptr_int_; | 62 const int16_t* source_ptr_int_; |
64 const size_t destination_frames_; | 63 const size_t destination_frames_; |
65 | 64 |
66 // True on the first call to Resample(), to prime the SincResampler buffer. | 65 // True on the first call to Resample(), to prime the SincResampler buffer. |
67 bool first_pass_; | 66 bool first_pass_; |
68 | 67 |
69 // Used to assert we are only requested for as much data as is available. | 68 // Used to assert we are only requested for as much data as is available. |
70 size_t source_available_; | 69 size_t source_available_; |
71 | 70 |
72 RTC_DISALLOW_COPY_AND_ASSIGN(PushSincResampler); | 71 RTC_DISALLOW_COPY_AND_ASSIGN(PushSincResampler); |
73 }; | 72 }; |
74 | 73 |
75 } // namespace webrtc | 74 } // namespace webrtc |
76 | 75 |
77 #endif // WEBRTC_COMMON_AUDIO_RESAMPLER_PUSH_SINC_RESAMPLER_H_ | 76 #endif // WEBRTC_COMMON_AUDIO_RESAMPLER_PUSH_SINC_RESAMPLER_H_ |
OLD | NEW |