2013-07-10 00:45:36 +00:00
|
|
|
/*
|
|
|
|
|
* libjingle
|
2015-01-20 21:36:13 +00:00
|
|
|
* Copyright 2012 Google Inc.
|
2013-07-10 00:45:36 +00:00
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
|
*
|
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
|
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
|
|
|
|
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
|
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
|
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-02-10 10:53:12 +01:00
|
|
|
#include "webrtc/api/test/fakeaudiocapturemodule.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
2015-08-13 14:27:18 -07:00
|
|
|
#include "webrtc/base/criticalsection.h"
|
2014-07-29 17:36:52 +00:00
|
|
|
#include "webrtc/base/gunit.h"
|
|
|
|
|
#include "webrtc/base/scoped_ref_ptr.h"
|
|
|
|
|
#include "webrtc/base/thread.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
using std::min;
|
|
|
|
|
|
|
|
|
|
class FakeAdmTest : public testing::Test,
|
|
|
|
|
public webrtc::AudioTransport {
|
|
|
|
|
protected:
|
|
|
|
|
static const int kMsInSecond = 1000;
|
|
|
|
|
|
|
|
|
|
FakeAdmTest()
|
|
|
|
|
: push_iterations_(0),
|
|
|
|
|
pull_iterations_(0),
|
|
|
|
|
rec_buffer_bytes_(0) {
|
|
|
|
|
memset(rec_buffer_, 0, sizeof(rec_buffer_));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void SetUp() {
|
2015-08-13 14:27:18 -07:00
|
|
|
fake_audio_capture_module_ = FakeAudioCaptureModule::Create();
|
2013-07-10 00:45:36 +00:00
|
|
|
EXPECT_TRUE(fake_audio_capture_module_.get() != NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Callbacks inherited from webrtc::AudioTransport.
|
|
|
|
|
// ADM is pushing data.
|
Reformat existing code. There should be no functional effects.
This includes changes like:
* Attempt to break lines at better positions
* Use "override" in more places, don't use "virtual" with it
* Use {} where the body is more than one line
* Make declaration and definition arg names match
* Eliminate unused code
* EXPECT_EQ(expected, actual) (but use (actual, expected) for e.g. _GT)
* Correct #include order
* Use anonymous namespaces in preference to "static" for file-scoping
* Eliminate unnecessary casts
* Update reference code in comments of ARM assembly sources to match actual current C code
* Fix indenting to be more style-guide compliant
* Use arraysize() in more places
* Use bool instead of int for "boolean" values (0/1)
* Shorten and simplify code
* Spaces around operators
* 80 column limit
* Use const more consistently
* Space goes after '*' in type name, not before
* Remove unnecessary return values
* Use "(var == const)", not "(const == var)"
* Spelling
* Prefer true, typed constants to "enum hack" constants
* Avoid "virtual" on non-overridden functions
* ASSERT(x == y) -> ASSERT_EQ(y, x)
BUG=none
R=andrew@webrtc.org, asapersson@webrtc.org, henrika@webrtc.org, juberti@webrtc.org, kjellander@webrtc.org, kwiberg@webrtc.org
Review URL: https://codereview.webrtc.org/1172163004
Cr-Commit-Position: refs/heads/master@{#9420}
2015-06-11 14:31:38 -07:00
|
|
|
int32_t RecordedDataIsAvailable(const void* audioSamples,
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
const size_t nSamples,
|
|
|
|
|
const size_t nBytesPerSample,
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
const size_t nChannels,
|
Reformat existing code. There should be no functional effects.
This includes changes like:
* Attempt to break lines at better positions
* Use "override" in more places, don't use "virtual" with it
* Use {} where the body is more than one line
* Make declaration and definition arg names match
* Eliminate unused code
* EXPECT_EQ(expected, actual) (but use (actual, expected) for e.g. _GT)
* Correct #include order
* Use anonymous namespaces in preference to "static" for file-scoping
* Eliminate unnecessary casts
* Update reference code in comments of ARM assembly sources to match actual current C code
* Fix indenting to be more style-guide compliant
* Use arraysize() in more places
* Use bool instead of int for "boolean" values (0/1)
* Shorten and simplify code
* Spaces around operators
* 80 column limit
* Use const more consistently
* Space goes after '*' in type name, not before
* Remove unnecessary return values
* Use "(var == const)", not "(const == var)"
* Spelling
* Prefer true, typed constants to "enum hack" constants
* Avoid "virtual" on non-overridden functions
* ASSERT(x == y) -> ASSERT_EQ(y, x)
BUG=none
R=andrew@webrtc.org, asapersson@webrtc.org, henrika@webrtc.org, juberti@webrtc.org, kjellander@webrtc.org, kwiberg@webrtc.org
Review URL: https://codereview.webrtc.org/1172163004
Cr-Commit-Position: refs/heads/master@{#9420}
2015-06-11 14:31:38 -07:00
|
|
|
const uint32_t samplesPerSec,
|
|
|
|
|
const uint32_t totalDelayMS,
|
|
|
|
|
const int32_t clockDrift,
|
|
|
|
|
const uint32_t currentMicLevel,
|
|
|
|
|
const bool keyPressed,
|
|
|
|
|
uint32_t& newMicLevel) override {
|
2015-08-13 14:27:18 -07:00
|
|
|
rtc::CritScope cs(&crit_);
|
2013-07-10 00:45:36 +00:00
|
|
|
rec_buffer_bytes_ = nSamples * nBytesPerSample;
|
Match existing type usage better.
This makes a variety of small changes to synchronize bits of code using different types, remove useless code or casts, and add explicit casts in some places previously doing implicit ones. For example:
* Change a few type declarations to better match how the majority of code uses those objects.
* Eliminate "< 0" check for unsigned values.
* Replace "(float)sin(x)", where |x| is also a float, with "sinf(x)", and similar.
* Add casts to uint32_t in many places timestamps were used and the existing code stored signed values into the unsigned objects.
* Remove downcasts when the results would be passed to a larger type, e.g. calling "foo((int16_t)x)" with an int |x| when foo() takes an int instead of an int16_t.
* Similarly, add casts when passing a larger type to a function taking a smaller one.
* Add casts to int16_t when doing something like "int16_t = int16_t + int16_t" as the "+" operation would implicitly upconvert to int, and similar.
* Use "false" instead of "0" for setting a bool.
* Shift a few temp types when doing a multi-stage calculation involving typecasts, so as to put the most logical/semantically correct type possible into the temps. For example, when doing "int foo = int + int; size_t bar = (size_t)foo + size_t;", we might change |foo| to a size_t and move the cast if it makes more sense for |foo| to be represented as a size_t.
BUG=none
R=andrew@webrtc.org, asapersson@webrtc.org, henrika@webrtc.org, juberti@webrtc.org, kwiberg@webrtc.org
TBR=andrew, asapersson, henrika
Review URL: https://codereview.webrtc.org/1168753002
Cr-Commit-Position: refs/heads/master@{#9419}
2015-06-11 12:55:50 -07:00
|
|
|
if ((rec_buffer_bytes_ == 0) ||
|
2013-07-10 00:45:36 +00:00
|
|
|
(rec_buffer_bytes_ > FakeAudioCaptureModule::kNumberSamples *
|
|
|
|
|
FakeAudioCaptureModule::kNumberBytesPerSample)) {
|
|
|
|
|
ADD_FAILURE();
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
memcpy(rec_buffer_, audioSamples, rec_buffer_bytes_);
|
|
|
|
|
++push_iterations_;
|
|
|
|
|
newMicLevel = currentMicLevel;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ADM is pulling data.
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
int32_t NeedMorePlayData(const size_t nSamples,
|
|
|
|
|
const size_t nBytesPerSample,
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
const size_t nChannels,
|
Reformat existing code. There should be no functional effects.
This includes changes like:
* Attempt to break lines at better positions
* Use "override" in more places, don't use "virtual" with it
* Use {} where the body is more than one line
* Make declaration and definition arg names match
* Eliminate unused code
* EXPECT_EQ(expected, actual) (but use (actual, expected) for e.g. _GT)
* Correct #include order
* Use anonymous namespaces in preference to "static" for file-scoping
* Eliminate unnecessary casts
* Update reference code in comments of ARM assembly sources to match actual current C code
* Fix indenting to be more style-guide compliant
* Use arraysize() in more places
* Use bool instead of int for "boolean" values (0/1)
* Shorten and simplify code
* Spaces around operators
* 80 column limit
* Use const more consistently
* Space goes after '*' in type name, not before
* Remove unnecessary return values
* Use "(var == const)", not "(const == var)"
* Spelling
* Prefer true, typed constants to "enum hack" constants
* Avoid "virtual" on non-overridden functions
* ASSERT(x == y) -> ASSERT_EQ(y, x)
BUG=none
R=andrew@webrtc.org, asapersson@webrtc.org, henrika@webrtc.org, juberti@webrtc.org, kjellander@webrtc.org, kwiberg@webrtc.org
Review URL: https://codereview.webrtc.org/1172163004
Cr-Commit-Position: refs/heads/master@{#9420}
2015-06-11 14:31:38 -07:00
|
|
|
const uint32_t samplesPerSec,
|
|
|
|
|
void* audioSamples,
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t& nSamplesOut,
|
Reformat existing code. There should be no functional effects.
This includes changes like:
* Attempt to break lines at better positions
* Use "override" in more places, don't use "virtual" with it
* Use {} where the body is more than one line
* Make declaration and definition arg names match
* Eliminate unused code
* EXPECT_EQ(expected, actual) (but use (actual, expected) for e.g. _GT)
* Correct #include order
* Use anonymous namespaces in preference to "static" for file-scoping
* Eliminate unnecessary casts
* Update reference code in comments of ARM assembly sources to match actual current C code
* Fix indenting to be more style-guide compliant
* Use arraysize() in more places
* Use bool instead of int for "boolean" values (0/1)
* Shorten and simplify code
* Spaces around operators
* 80 column limit
* Use const more consistently
* Space goes after '*' in type name, not before
* Remove unnecessary return values
* Use "(var == const)", not "(const == var)"
* Spelling
* Prefer true, typed constants to "enum hack" constants
* Avoid "virtual" on non-overridden functions
* ASSERT(x == y) -> ASSERT_EQ(y, x)
BUG=none
R=andrew@webrtc.org, asapersson@webrtc.org, henrika@webrtc.org, juberti@webrtc.org, kjellander@webrtc.org, kwiberg@webrtc.org
Review URL: https://codereview.webrtc.org/1172163004
Cr-Commit-Position: refs/heads/master@{#9420}
2015-06-11 14:31:38 -07:00
|
|
|
int64_t* elapsed_time_ms,
|
|
|
|
|
int64_t* ntp_time_ms) override {
|
2015-08-13 14:27:18 -07:00
|
|
|
rtc::CritScope cs(&crit_);
|
2013-07-10 00:45:36 +00:00
|
|
|
++pull_iterations_;
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
const size_t audio_buffer_size = nSamples * nBytesPerSample;
|
|
|
|
|
const size_t bytes_out = RecordedDataReceived() ?
|
2013-07-10 00:45:36 +00:00
|
|
|
CopyFromRecBuffer(audioSamples, audio_buffer_size):
|
|
|
|
|
GenerateZeroBuffer(audioSamples, audio_buffer_size);
|
|
|
|
|
nSamplesOut = bytes_out / nBytesPerSample;
|
2014-06-05 20:34:08 +00:00
|
|
|
*elapsed_time_ms = 0;
|
2014-07-14 20:05:09 +00:00
|
|
|
*ntp_time_ms = 0;
|
2013-07-10 00:45:36 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-13 14:27:18 -07:00
|
|
|
int push_iterations() const {
|
|
|
|
|
rtc::CritScope cs(&crit_);
|
|
|
|
|
return push_iterations_;
|
|
|
|
|
}
|
|
|
|
|
int pull_iterations() const {
|
|
|
|
|
rtc::CritScope cs(&crit_);
|
|
|
|
|
return pull_iterations_;
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
bool RecordedDataReceived() const {
|
|
|
|
|
return rec_buffer_bytes_ != 0;
|
|
|
|
|
}
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t GenerateZeroBuffer(void* audio_buffer, size_t audio_buffer_size) {
|
2013-07-10 00:45:36 +00:00
|
|
|
memset(audio_buffer, 0, audio_buffer_size);
|
|
|
|
|
return audio_buffer_size;
|
|
|
|
|
}
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t CopyFromRecBuffer(void* audio_buffer, size_t audio_buffer_size) {
|
2013-07-10 00:45:36 +00:00
|
|
|
EXPECT_EQ(audio_buffer_size, rec_buffer_bytes_);
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
const size_t min_buffer_size = min(audio_buffer_size, rec_buffer_bytes_);
|
2013-07-10 00:45:36 +00:00
|
|
|
memcpy(audio_buffer, rec_buffer_, min_buffer_size);
|
|
|
|
|
return min_buffer_size;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-25 03:52:44 -08:00
|
|
|
rtc::CriticalSection crit_;
|
2015-08-13 14:27:18 -07:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
int push_iterations_;
|
|
|
|
|
int pull_iterations_;
|
|
|
|
|
|
|
|
|
|
char rec_buffer_[FakeAudioCaptureModule::kNumberSamples *
|
|
|
|
|
FakeAudioCaptureModule::kNumberBytesPerSample];
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t rec_buffer_bytes_;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TEST_F(FakeAdmTest, TestProccess) {
|
|
|
|
|
// Next process call must be some time in the future (or now).
|
|
|
|
|
EXPECT_LE(0, fake_audio_capture_module_->TimeUntilNextProcess());
|
|
|
|
|
// Process call updates TimeUntilNextProcess() but there are no guarantees on
|
|
|
|
|
// timing so just check that Process can ba called successfully.
|
|
|
|
|
EXPECT_LE(0, fake_audio_capture_module_->Process());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(FakeAdmTest, PlayoutTest) {
|
|
|
|
|
EXPECT_EQ(0, fake_audio_capture_module_->RegisterAudioCallback(this));
|
|
|
|
|
|
|
|
|
|
bool stereo_available = false;
|
|
|
|
|
EXPECT_EQ(0,
|
|
|
|
|
fake_audio_capture_module_->StereoPlayoutIsAvailable(
|
|
|
|
|
&stereo_available));
|
|
|
|
|
EXPECT_TRUE(stereo_available);
|
|
|
|
|
|
|
|
|
|
EXPECT_NE(0, fake_audio_capture_module_->StartPlayout());
|
|
|
|
|
EXPECT_FALSE(fake_audio_capture_module_->PlayoutIsInitialized());
|
|
|
|
|
EXPECT_FALSE(fake_audio_capture_module_->Playing());
|
|
|
|
|
EXPECT_EQ(0, fake_audio_capture_module_->StopPlayout());
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(0, fake_audio_capture_module_->InitPlayout());
|
|
|
|
|
EXPECT_TRUE(fake_audio_capture_module_->PlayoutIsInitialized());
|
|
|
|
|
EXPECT_FALSE(fake_audio_capture_module_->Playing());
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(0, fake_audio_capture_module_->StartPlayout());
|
|
|
|
|
EXPECT_TRUE(fake_audio_capture_module_->Playing());
|
|
|
|
|
|
|
|
|
|
uint16_t delay_ms = 10;
|
|
|
|
|
EXPECT_EQ(0, fake_audio_capture_module_->PlayoutDelay(&delay_ms));
|
|
|
|
|
EXPECT_EQ(0, delay_ms);
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE_WAIT(pull_iterations() > 0, kMsInSecond);
|
|
|
|
|
EXPECT_GE(0, push_iterations());
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(0, fake_audio_capture_module_->StopPlayout());
|
|
|
|
|
EXPECT_FALSE(fake_audio_capture_module_->Playing());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(FakeAdmTest, RecordTest) {
|
|
|
|
|
EXPECT_EQ(0, fake_audio_capture_module_->RegisterAudioCallback(this));
|
|
|
|
|
|
|
|
|
|
bool stereo_available = false;
|
|
|
|
|
EXPECT_EQ(0, fake_audio_capture_module_->StereoRecordingIsAvailable(
|
|
|
|
|
&stereo_available));
|
|
|
|
|
EXPECT_FALSE(stereo_available);
|
|
|
|
|
|
|
|
|
|
EXPECT_NE(0, fake_audio_capture_module_->StartRecording());
|
|
|
|
|
EXPECT_FALSE(fake_audio_capture_module_->Recording());
|
|
|
|
|
EXPECT_EQ(0, fake_audio_capture_module_->StopRecording());
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(0, fake_audio_capture_module_->InitRecording());
|
|
|
|
|
EXPECT_EQ(0, fake_audio_capture_module_->StartRecording());
|
|
|
|
|
EXPECT_TRUE(fake_audio_capture_module_->Recording());
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE_WAIT(push_iterations() > 0, kMsInSecond);
|
|
|
|
|
EXPECT_GE(0, pull_iterations());
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(0, fake_audio_capture_module_->StopRecording());
|
|
|
|
|
EXPECT_FALSE(fake_audio_capture_module_->Recording());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(FakeAdmTest, DuplexTest) {
|
|
|
|
|
EXPECT_EQ(0, fake_audio_capture_module_->RegisterAudioCallback(this));
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(0, fake_audio_capture_module_->InitPlayout());
|
|
|
|
|
EXPECT_EQ(0, fake_audio_capture_module_->StartPlayout());
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(0, fake_audio_capture_module_->InitRecording());
|
|
|
|
|
EXPECT_EQ(0, fake_audio_capture_module_->StartRecording());
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE_WAIT(push_iterations() > 0, kMsInSecond);
|
|
|
|
|
EXPECT_TRUE_WAIT(pull_iterations() > 0, kMsInSecond);
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(0, fake_audio_capture_module_->StopPlayout());
|
|
|
|
|
EXPECT_EQ(0, fake_audio_capture_module_->StopRecording());
|
|
|
|
|
}
|