Replace NULL with nullptr or null in webrtc/audio/ and common_audio/.

BUG=webrtc:7147

Review-Url: https://codereview.webrtc.org/2719733002
Cr-Commit-Position: refs/heads/master@{#16843}
This commit is contained in:
deadbeef 2017-02-26 04:18:12 -08:00 committed by Commit bot
parent e814a0dee0
commit 922246a353
16 changed files with 44 additions and 44 deletions

View File

@ -51,7 +51,7 @@ std::string AudioReceiveStream::Config::ToString() const {
std::stringstream ss;
ss << "{rtp: " << rtp.ToString();
ss << ", rtcp_send_transport: "
<< (rtcp_send_transport ? "(Transport)" : "nullptr");
<< (rtcp_send_transport ? "(Transport)" : "null");
ss << ", voe_channel_id: " << voe_channel_id;
if (!sync_group.empty()) {
ss << ", sync_group: " << sync_group;

View File

@ -225,7 +225,7 @@ TEST(AudioReceiveStreamTest, ConfigToString) {
"{rtp: {remote_ssrc: 1234, local_ssrc: 5678, transport_cc: off, nack: "
"{rtp_history_ms: 0}, extensions: [{uri: "
"urn:ietf:params:rtp-hdrext:ssrc-audio-level, id: 3}]}, "
"rtcp_send_transport: nullptr, voe_channel_id: 2}",
"rtcp_send_transport: null, voe_channel_id: 2}",
config.ToString());
}

View File

@ -276,7 +276,7 @@ TEST(AudioSendStreamTest, ConfigToString) {
EXPECT_EQ(
"{rtp: {ssrc: 1234, extensions: [{uri: "
"urn:ietf:params:rtp-hdrext:ssrc-audio-level, id: 2}], nack: "
"{rtp_history_ms: 0}, c_name: foo_name}, send_transport: nullptr, "
"{rtp_history_ms: 0}, c_name: foo_name}, send_transport: null, "
"voe_channel_id: 1, min_bitrate_bps: 12000, max_bitrate_bps: 34000, "
"send_codec_spec: {nack_enabled: true, transport_cc_enabled: false, "
"enable_codec_fec: true, enable_opus_dtx: false, opus_max_playback_rate: "

View File

@ -40,7 +40,7 @@ AudioSendStream::Config::~Config() = default;
std::string AudioSendStream::Config::ToString() const {
std::stringstream ss;
ss << "{rtp: " << rtp.ToString();
ss << ", send_transport: " << (send_transport ? "(Transport)" : "nullptr");
ss << ", send_transport: " << (send_transport ? "(Transport)" : "null");
ss << ", voe_channel_id: " << voe_channel_id;
ss << ", min_bitrate_bps: " << min_bitrate_bps;
ss << ", max_bitrate_bps: " << max_bitrate_bps;

View File

@ -40,10 +40,10 @@ FIRFilter* FIRFilter::Create(const float* coefficients,
size_t max_input_length) {
if (!coefficients || coefficients_length <= 0 || max_input_length <= 0) {
RTC_NOTREACHED();
return NULL;
return nullptr;
}
FIRFilter* filter = NULL;
FIRFilter* filter = nullptr;
// If we know the minimum architecture at compile time, avoid CPU detection.
#if defined(WEBRTC_ARCH_X86_FAMILY)
#if defined(__SSE2__)

View File

@ -101,37 +101,37 @@ int Resampler::Reset(int inFreq, int outFreq, size_t num_channels)
if (state1_)
{
free(state1_);
state1_ = NULL;
state1_ = nullptr;
}
if (state2_)
{
free(state2_);
state2_ = NULL;
state2_ = nullptr;
}
if (state3_)
{
free(state3_);
state3_ = NULL;
state3_ = nullptr;
}
if (in_buffer_)
{
free(in_buffer_);
in_buffer_ = NULL;
in_buffer_ = nullptr;
}
if (out_buffer_)
{
free(out_buffer_);
out_buffer_ = NULL;
out_buffer_ = nullptr;
}
if (slave_left_)
{
delete slave_left_;
slave_left_ = NULL;
slave_left_ = nullptr;
}
if (slave_right_)
{
delete slave_right_;
slave_right_ = NULL;
slave_right_ = nullptr;
}
in_buffer_size_ = 0;

View File

@ -161,7 +161,7 @@ SincResampler::SincResampler(double io_sample_rate_ratio,
input_buffer_(static_cast<float*>(
AlignedMalloc(sizeof(float) * input_buffer_size_, 16))),
#if defined(WEBRTC_CPU_DETECTION)
convolve_proc_(NULL),
convolve_proc_(nullptr),
#endif
r1_(input_buffer_.get()),
r2_(input_buffer_.get() + kKernelSize / 2) {

View File

@ -31,7 +31,7 @@ typedef struct RingBuffer {
char* data;
} RingBuffer;
// Creates and initializes the buffer. Returns NULL on failure.
// Creates and initializes the buffer. Returns null on failure.
RingBuffer* WebRtc_CreateBuffer(size_t element_count, size_t element_size);
void WebRtc_InitBuffer(RingBuffer* handle);
void WebRtc_FreeBuffer(void* handle);
@ -43,7 +43,7 @@ void WebRtc_FreeBuffer(void* handle);
// user) and |data_ptr| points to the address of |data|. |data_ptr| is only
// guaranteed to be valid until the next call to WebRtc_WriteBuffer().
//
// To force a copying to |data|, pass a NULL |data_ptr|.
// To force a copying to |data|, pass a null |data_ptr|.
//
// Returns number of elements read.
size_t WebRtc_ReadBuffer(RingBuffer* handle,

View File

@ -54,7 +54,7 @@ static void RandomStressTest(int** data_ptr) {
const int kNumOps = 1000;
const int kMaxBufferSize = 1000;
unsigned int seed = time(NULL);
unsigned int seed = time(nullptr);
printf("seed=%u\n", seed);
srand(seed);
for (int i = 0; i < kNumTests; i++) {
@ -62,7 +62,7 @@ static void RandomStressTest(int** data_ptr) {
std::unique_ptr<int[]> write_data(new int[buffer_size]);
std::unique_ptr<int[]> read_data(new int[buffer_size]);
scoped_ring_buffer buffer(WebRtc_CreateBuffer(buffer_size, sizeof(int)));
ASSERT_TRUE(buffer.get() != NULL);
ASSERT_TRUE(buffer.get() != nullptr);
WebRtc_InitBuffer(buffer.get());
int buffer_consumed = 0;
int write_element = 0;
@ -105,12 +105,12 @@ static void RandomStressTest(int** data_ptr) {
}
TEST(RingBufferTest, RandomStressTest) {
int* data_ptr = NULL;
int* data_ptr = nullptr;
RandomStressTest(&data_ptr);
}
TEST(RingBufferTest, RandomStressTestWithNullPtr) {
RandomStressTest(NULL);
RandomStressTest(nullptr);
}
TEST(RingBufferTest, PassingNulltoReadBufferForcesMemcpy) {
@ -120,7 +120,7 @@ TEST(RingBufferTest, PassingNulltoReadBufferForcesMemcpy) {
int* data_ptr;
scoped_ring_buffer buffer(WebRtc_CreateBuffer(kDataSize, sizeof(int)));
ASSERT_TRUE(buffer.get() != NULL);
ASSERT_TRUE(buffer.get() != nullptr);
WebRtc_InitBuffer(buffer.get());
SetIncrementingData(write_data, kDataSize, 0);
@ -133,17 +133,17 @@ TEST(RingBufferTest, PassingNulltoReadBufferForcesMemcpy) {
CheckIncrementingData(read_data, kDataSize, kDataSize);
EXPECT_EQ(kDataSize, WebRtc_WriteBuffer(buffer.get(), write_data, kDataSize));
EXPECT_EQ(kDataSize, WebRtc_ReadBuffer(buffer.get(), NULL, read_data,
kDataSize));
// Passing NULL forces a memcpy, so |read_data| is now updated.
EXPECT_EQ(kDataSize,
WebRtc_ReadBuffer(buffer.get(), nullptr, read_data, kDataSize));
// Passing null forces a memcpy, so |read_data| is now updated.
CheckIncrementingData(read_data, kDataSize, 0);
}
TEST(RingBufferTest, CreateHandlesErrors) {
EXPECT_TRUE(WebRtc_CreateBuffer(0, 1) == NULL);
EXPECT_TRUE(WebRtc_CreateBuffer(1, 0) == NULL);
EXPECT_TRUE(WebRtc_CreateBuffer(0, 1) == nullptr);
EXPECT_TRUE(WebRtc_CreateBuffer(1, 0) == nullptr);
RingBuffer* buffer = WebRtc_CreateBuffer(1, 1);
EXPECT_TRUE(buffer != NULL);
EXPECT_TRUE(buffer != nullptr);
WebRtc_FreeBuffer(buffer);
}

View File

@ -57,7 +57,7 @@ void WebRtcSpl_FreeRealFFT(struct RealFFT* self);
//
// Return Value:
// 0 - FFT calculation is successful.
// -1 - Error with bad arguments (NULL pointers).
// -1 - Error with bad arguments (null pointers).
int WebRtcSpl_RealForwardFFT(struct RealFFT* self,
const int16_t* real_data_in,
int16_t* complex_data_out);
@ -85,7 +85,7 @@ int WebRtcSpl_RealForwardFFT(struct RealFFT* self,
// 0 or a positive number - a value that the elements in the |real_data_out|
// should be shifted left with in order to get
// correct physical values.
// -1 - Error with bad arguments (NULL pointers).
// -1 - Error with bad arguments (null pointers).
int WebRtcSpl_RealInverseFFT(struct RealFFT* self,
const int16_t* complex_data_in,
int16_t* real_data_out);

View File

@ -343,8 +343,8 @@ void WebRtcSpl_ScaleAndAddVectors(const int16_t* in_vector1,
//
// Output:
// - out_vector : Output vector
// Return value : 0 if OK, -1 if (in_vector1 == NULL
// || in_vector2 == NULL || out_vector == NULL
// Return value : 0 if OK, -1 if (in_vector1 == null
// || in_vector2 == null || out_vector == null
// || length <= 0 || right_shift < 0).
typedef int (*ScaleAndAddVectorsWithRound)(const int16_t* in_vector1,
int16_t in_vector1_scale,

View File

@ -42,9 +42,9 @@ class RealFFTTest : public ::testing::Test {
TEST_F(RealFFTTest, CreateFailsOnBadInput) {
RealFFT* fft = WebRtcSpl_CreateRealFFT(11);
EXPECT_TRUE(fft == NULL);
EXPECT_TRUE(fft == nullptr);
fft = WebRtcSpl_CreateRealFFT(-1);
EXPECT_TRUE(fft == NULL);
EXPECT_TRUE(fft == nullptr);
}
TEST_F(RealFFTTest, RealAndComplexMatch) {
@ -64,7 +64,7 @@ TEST_F(RealFFTTest, RealAndComplexMatch) {
// Create and run real forward FFT.
RealFFT* fft = WebRtcSpl_CreateRealFFT(kOrder);
EXPECT_TRUE(fft != NULL);
EXPECT_TRUE(fft != nullptr);
EXPECT_EQ(0, WebRtcSpl_RealForwardFFT(fft, real_fft_time, real_fft_freq));
// Run complex forward FFT.

View File

@ -39,7 +39,7 @@ void WebRtcVad_Free(VadInst* handle);
// - handle [i/o] : Instance that should be initialized.
//
// returns : 0 - (OK),
// -1 - (NULL pointer or Default mode could not be set).
// -1 - (null pointer or Default mode could not be set).
int WebRtcVad_Init(VadInst* handle);
// Sets the VAD operating mode. A more aggressive (higher mode) VAD is more
@ -51,7 +51,7 @@ int WebRtcVad_Init(VadInst* handle);
// - mode [i] : Aggressiveness mode (0, 1, 2, or 3).
//
// returns : 0 - (OK),
// -1 - (NULL pointer, mode could not be set or the VAD instance
// -1 - (null pointer, mode could not be set or the VAD instance
// has not been initialized).
int WebRtcVad_set_mode(VadInst* handle, int mode);

View File

@ -60,7 +60,7 @@ typedef struct VadInstT_
//
// - self [i/o] : Instance that should be initialized
//
// returns : 0 (OK), -1 (NULL pointer in or if the default mode can't be
// returns : 0 (OK), -1 (null pointer in or if the default mode can't be
// set)
int WebRtcVad_InitCore(VadInstT* self);

View File

@ -24,10 +24,10 @@ TEST_F(VadTest, InitCore) {
// Test WebRtcVad_InitCore().
VadInstT* self = reinterpret_cast<VadInstT*>(malloc(sizeof(VadInstT)));
// NULL pointer test.
EXPECT_EQ(-1, WebRtcVad_InitCore(NULL));
// null pointer test.
EXPECT_EQ(-1, WebRtcVad_InitCore(nullptr));
// Verify return = 0 for non-NULL pointer.
// Verify return = 0 for non-null pointer.
EXPECT_EQ(0, WebRtcVad_InitCore(self));
// Verify init_flag is set.
EXPECT_EQ(42, self->init_flag);
@ -38,7 +38,7 @@ TEST_F(VadTest, InitCore) {
TEST_F(VadTest, set_mode_core) {
VadInstT* self = reinterpret_cast<VadInstT*>(malloc(sizeof(VadInstT)));
// TODO(bjornv): Add NULL pointer check if we take care of it in
// TODO(bjornv): Add null pointer check if we take care of it in
// vad_core.c
ASSERT_EQ(0, WebRtcVad_InitCore(self));
@ -58,7 +58,7 @@ TEST_F(VadTest, CalcVad) {
VadInstT* self = reinterpret_cast<VadInstT*>(malloc(sizeof(VadInstT)));
int16_t speech[kMaxFrameLength];
// TODO(bjornv): Add NULL pointer check if we take care of it in
// TODO(bjornv): Add null pointer check if we take care of it in
// vad_core.c
// Test WebRtcVad_CalcVadXXkhz()

View File

@ -107,7 +107,7 @@ size_t WavReader::ReadSamples(size_t num_samples, float* samples) {
void WavReader::Close() {
RTC_CHECK_EQ(0, fclose(file_handle_));
file_handle_ = NULL;
file_handle_ = nullptr;
}
WavWriter::WavWriter(const std::string& filename, int sample_rate,
@ -170,7 +170,7 @@ void WavWriter::Close() {
kBytesPerSample, num_samples_);
RTC_CHECK_EQ(1, fwrite(header, kWavHeaderSize, 1, file_handle_));
RTC_CHECK_EQ(0, fclose(file_handle_));
file_handle_ = NULL;
file_handle_ = nullptr;
}
} // namespace webrtc