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

Unified Diff: webrtc/test/fake_audio_device.h

Issue 2652803002: Refactor FakeAudioDevice to have separate methods for starting recording and playout. (Closed)
Patch Set: Made some methods private. Readded init. Created 3 years, 11 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
Index: webrtc/test/fake_audio_device.h
diff --git a/webrtc/test/fake_audio_device.h b/webrtc/test/fake_audio_device.h
index 77a74bac8f6d1bc962cf8b8aceea9313f9c50bec..bc77790a5aad945e5f775f1b4ce705d46cf4da69 100644
--- a/webrtc/test/fake_audio_device.h
+++ b/webrtc/test/fake_audio_device.h
@@ -23,17 +23,22 @@ namespace webrtc {
class Clock;
class EventTimerWrapper;
-class FileWrapper;
-class ModuleFileUtility;
namespace test {
class FakeAudioDevice : public FakeAudioDeviceModule {
public:
- FakeAudioDevice(Clock* clock, const std::string& filename, float speed);
-
+ FakeAudioDevice(Clock* clock, float speed);
the sun 2017/01/24 08:58:12 What's "speed"?
perkj_webrtc 2017/01/24 09:57:03 Added a comment. Note that this is nothing I want
virtual ~FakeAudioDevice();
the sun 2017/01/24 08:58:12 override
perkj_webrtc 2017/01/24 09:57:03 Done.
+ int32_t StartPlayout() override;
+ int32_t StopPlayout() override;
+
+ // Generates a sine tone with |frequency_in_hz| and |peak_to_peak|.
+ void StartRecordingSine(int frequency_in_hz, uint16_t peak_to_peak);
+ int32_t StopRecording() override;
+
+ private:
int32_t Init() override;
int32_t RegisterAudioCallback(AudioTransport* callback) override;
@@ -41,29 +46,31 @@ class FakeAudioDevice : public FakeAudioDeviceModule {
int32_t PlayoutDelay(uint16_t* delay_ms) const override;
bool Recording() const override;
- void Start();
- void Stop();
-
- private:
static bool Run(void* obj);
- void CaptureAudio();
+ void ProcessAudio();
static const uint32_t kFrequencyHz = 16000;
static const size_t kBufferSizeBytes = 2 * kFrequencyHz;
- AudioTransport* audio_callback_;
- bool capturing_;
+ rtc::CriticalSection lock_;
+ AudioTransport* audio_callback_ GUARDED_BY(lock_);
+ bool recording_ GUARDED_BY(lock_);
+ bool playing_ GUARDED_BY(lock_);
+
+ // Used for recording.
+ double normalized_frequency_ GUARDED_BY(lock_);
the sun 2017/01/24 08:58:12 float
perkj_webrtc 2017/01/24 09:57:03 Done.
+ uint16_t peak_to_peak_ GUARDED_BY(lock_);
the sun 2017/01/24 08:58:12 float
perkj_webrtc 2017/01/24 09:57:03 Done.
+ double n_;
the sun 2017/01/24 08:58:12 float
perkj_webrtc 2017/01/24 09:57:03 Done.
int8_t captured_audio_[kBufferSizeBytes];
+
+ // Used for playout.
int8_t playout_buffer_[kBufferSizeBytes];
const float speed_;
int64_t last_playout_ms_;
DriftingClock clock_;
std::unique_ptr<EventTimerWrapper> tick_;
- rtc::CriticalSection lock_;
rtc::PlatformThread thread_;
- std::unique_ptr<ModuleFileUtility> file_utility_;
the sun 2017/01/24 08:58:12 Are there any build file deps you can remove now?
perkj_webrtc 2017/01/24 09:57:03 Done.
- std::unique_ptr<FileWrapper> input_stream_;
};
} // namespace test
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698