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

Side by Side Diff: talk/app/webrtc/test/fakeaudiocapturemodule_unittest.cc

Issue 1172163004: Reformat existing code. There should be no functional effects. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Resync Created 5 years, 6 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 * libjingle 2 * libjingle
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 49
50 virtual void SetUp() { 50 virtual void SetUp() {
51 fake_audio_capture_module_ = FakeAudioCaptureModule::Create( 51 fake_audio_capture_module_ = FakeAudioCaptureModule::Create(
52 rtc::Thread::Current()); 52 rtc::Thread::Current());
53 EXPECT_TRUE(fake_audio_capture_module_.get() != NULL); 53 EXPECT_TRUE(fake_audio_capture_module_.get() != NULL);
54 } 54 }
55 55
56 // Callbacks inherited from webrtc::AudioTransport. 56 // Callbacks inherited from webrtc::AudioTransport.
57 // ADM is pushing data. 57 // ADM is pushing data.
58 virtual int32_t RecordedDataIsAvailable(const void* audioSamples, 58 int32_t RecordedDataIsAvailable(const void* audioSamples,
59 const uint32_t nSamples, 59 const uint32_t nSamples,
60 const uint8_t nBytesPerSample, 60 const uint8_t nBytesPerSample,
61 const uint8_t nChannels, 61 const uint8_t nChannels,
62 const uint32_t samplesPerSec, 62 const uint32_t samplesPerSec,
63 const uint32_t totalDelayMS, 63 const uint32_t totalDelayMS,
64 const int32_t clockDrift, 64 const int32_t clockDrift,
65 const uint32_t currentMicLevel, 65 const uint32_t currentMicLevel,
66 const bool keyPressed, 66 const bool keyPressed,
67 uint32_t& newMicLevel) { 67 uint32_t& newMicLevel) override {
68 rec_buffer_bytes_ = nSamples * nBytesPerSample; 68 rec_buffer_bytes_ = nSamples * nBytesPerSample;
69 if ((rec_buffer_bytes_ == 0) || 69 if ((rec_buffer_bytes_ == 0) ||
70 (rec_buffer_bytes_ > FakeAudioCaptureModule::kNumberSamples * 70 (rec_buffer_bytes_ > FakeAudioCaptureModule::kNumberSamples *
71 FakeAudioCaptureModule::kNumberBytesPerSample)) { 71 FakeAudioCaptureModule::kNumberBytesPerSample)) {
72 ADD_FAILURE(); 72 ADD_FAILURE();
73 return -1; 73 return -1;
74 } 74 }
75 memcpy(rec_buffer_, audioSamples, rec_buffer_bytes_); 75 memcpy(rec_buffer_, audioSamples, rec_buffer_bytes_);
76 ++push_iterations_; 76 ++push_iterations_;
77 newMicLevel = currentMicLevel; 77 newMicLevel = currentMicLevel;
78 return 0; 78 return 0;
79 } 79 }
80 80
81 // ADM is pulling data. 81 // ADM is pulling data.
82 virtual int32_t NeedMorePlayData(const uint32_t nSamples, 82 int32_t NeedMorePlayData(const uint32_t nSamples,
83 const uint8_t nBytesPerSample, 83 const uint8_t nBytesPerSample,
84 const uint8_t nChannels, 84 const uint8_t nChannels,
85 const uint32_t samplesPerSec, 85 const uint32_t samplesPerSec,
86 void* audioSamples, 86 void* audioSamples,
87 uint32_t& nSamplesOut, 87 uint32_t& nSamplesOut,
88 int64_t* elapsed_time_ms, 88 int64_t* elapsed_time_ms,
89 int64_t* ntp_time_ms) { 89 int64_t* ntp_time_ms) override {
90 ++pull_iterations_; 90 ++pull_iterations_;
91 const uint32_t audio_buffer_size = nSamples * nBytesPerSample; 91 const uint32_t audio_buffer_size = nSamples * nBytesPerSample;
92 const uint32_t bytes_out = RecordedDataReceived() ? 92 const uint32_t bytes_out = RecordedDataReceived() ?
93 CopyFromRecBuffer(audioSamples, audio_buffer_size): 93 CopyFromRecBuffer(audioSamples, audio_buffer_size):
94 GenerateZeroBuffer(audioSamples, audio_buffer_size); 94 GenerateZeroBuffer(audioSamples, audio_buffer_size);
95 nSamplesOut = bytes_out / nBytesPerSample; 95 nSamplesOut = bytes_out / nBytesPerSample;
96 *elapsed_time_ms = 0; 96 *elapsed_time_ms = 0;
97 *ntp_time_ms = 0; 97 *ntp_time_ms = 0;
98 return 0; 98 return 0;
99 } 99 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 EXPECT_EQ(0, fake_audio_capture_module_->InitRecording()); 198 EXPECT_EQ(0, fake_audio_capture_module_->InitRecording());
199 EXPECT_EQ(0, fake_audio_capture_module_->StartRecording()); 199 EXPECT_EQ(0, fake_audio_capture_module_->StartRecording());
200 200
201 EXPECT_TRUE_WAIT(push_iterations() > 0, kMsInSecond); 201 EXPECT_TRUE_WAIT(push_iterations() > 0, kMsInSecond);
202 EXPECT_TRUE_WAIT(pull_iterations() > 0, kMsInSecond); 202 EXPECT_TRUE_WAIT(pull_iterations() > 0, kMsInSecond);
203 203
204 EXPECT_EQ(0, fake_audio_capture_module_->StopPlayout()); 204 EXPECT_EQ(0, fake_audio_capture_module_->StopPlayout());
205 EXPECT_EQ(0, fake_audio_capture_module_->StopRecording()); 205 EXPECT_EQ(0, fake_audio_capture_module_->StopRecording());
206 } 206 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698