| OLD | NEW |
| 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 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 // remote side unless a packet containing a sample of that magnitude has been | 608 // remote side unless a packet containing a sample of that magnitude has been |
| 609 // sent to it. Note that the audio processing pipeline will likely distort the | 609 // sent to it. Note that the audio processing pipeline will likely distort the |
| 610 // original signal. | 610 // original signal. |
| 611 SetSendBuffer(kHighSampleValue); | 611 SetSendBuffer(kHighSampleValue); |
| 612 last_process_time_ms_ = rtc::Time(); | 612 last_process_time_ms_ = rtc::Time(); |
| 613 return true; | 613 return true; |
| 614 } | 614 } |
| 615 | 615 |
| 616 void FakeAudioCaptureModule::SetSendBuffer(int value) { | 616 void FakeAudioCaptureModule::SetSendBuffer(int value) { |
| 617 Sample* buffer_ptr = reinterpret_cast<Sample*>(send_buffer_); | 617 Sample* buffer_ptr = reinterpret_cast<Sample*>(send_buffer_); |
| 618 const int buffer_size_in_samples = | 618 const size_t buffer_size_in_samples = |
| 619 sizeof(send_buffer_) / kNumberBytesPerSample; | 619 sizeof(send_buffer_) / kNumberBytesPerSample; |
| 620 for (int i = 0; i < buffer_size_in_samples; ++i) { | 620 for (size_t i = 0; i < buffer_size_in_samples; ++i) { |
| 621 buffer_ptr[i] = value; | 621 buffer_ptr[i] = value; |
| 622 } | 622 } |
| 623 } | 623 } |
| 624 | 624 |
| 625 void FakeAudioCaptureModule::ResetRecBuffer() { | 625 void FakeAudioCaptureModule::ResetRecBuffer() { |
| 626 memset(rec_buffer_, 0, sizeof(rec_buffer_)); | 626 memset(rec_buffer_, 0, sizeof(rec_buffer_)); |
| 627 } | 627 } |
| 628 | 628 |
| 629 bool FakeAudioCaptureModule::CheckRecBuffer(int value) { | 629 bool FakeAudioCaptureModule::CheckRecBuffer(int value) { |
| 630 const Sample* buffer_ptr = reinterpret_cast<const Sample*>(rec_buffer_); | 630 const Sample* buffer_ptr = reinterpret_cast<const Sample*>(rec_buffer_); |
| 631 const int buffer_size_in_samples = | 631 const size_t buffer_size_in_samples = |
| 632 sizeof(rec_buffer_) / kNumberBytesPerSample; | 632 sizeof(rec_buffer_) / kNumberBytesPerSample; |
| 633 for (int i = 0; i < buffer_size_in_samples; ++i) { | 633 for (size_t i = 0; i < buffer_size_in_samples; ++i) { |
| 634 if (buffer_ptr[i] >= value) return true; | 634 if (buffer_ptr[i] >= value) return true; |
| 635 } | 635 } |
| 636 return false; | 636 return false; |
| 637 } | 637 } |
| 638 | 638 |
| 639 bool FakeAudioCaptureModule::ShouldStartProcessing() { | 639 bool FakeAudioCaptureModule::ShouldStartProcessing() { |
| 640 return recording_ || playing_; | 640 return recording_ || playing_; |
| 641 } | 641 } |
| 642 | 642 |
| 643 void FakeAudioCaptureModule::UpdateProcessing(bool start) { | 643 void FakeAudioCaptureModule::UpdateProcessing(bool start) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 } | 691 } |
| 692 | 692 |
| 693 void FakeAudioCaptureModule::ReceiveFrameP() { | 693 void FakeAudioCaptureModule::ReceiveFrameP() { |
| 694 ASSERT(process_thread_->IsCurrent()); | 694 ASSERT(process_thread_->IsCurrent()); |
| 695 { | 695 { |
| 696 rtc::CritScope cs(&crit_callback_); | 696 rtc::CritScope cs(&crit_callback_); |
| 697 if (!audio_callback_) { | 697 if (!audio_callback_) { |
| 698 return; | 698 return; |
| 699 } | 699 } |
| 700 ResetRecBuffer(); | 700 ResetRecBuffer(); |
| 701 uint32_t nSamplesOut = 0; | 701 size_t nSamplesOut = 0; |
| 702 int64_t elapsed_time_ms = 0; | 702 int64_t elapsed_time_ms = 0; |
| 703 int64_t ntp_time_ms = 0; | 703 int64_t ntp_time_ms = 0; |
| 704 if (audio_callback_->NeedMorePlayData(kNumberSamples, kNumberBytesPerSample, | 704 if (audio_callback_->NeedMorePlayData(kNumberSamples, kNumberBytesPerSample, |
| 705 kNumberOfChannels, kSamplesPerSecond, | 705 kNumberOfChannels, kSamplesPerSecond, |
| 706 rec_buffer_, nSamplesOut, | 706 rec_buffer_, nSamplesOut, |
| 707 &elapsed_time_ms, &ntp_time_ms) != 0) { | 707 &elapsed_time_ms, &ntp_time_ms) != 0) { |
| 708 ASSERT(false); | 708 ASSERT(false); |
| 709 } | 709 } |
| 710 ASSERT(nSamplesOut == kNumberSamples); | 710 ASSERT(nSamplesOut == kNumberSamples); |
| 711 } | 711 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 735 kNumberOfChannels, | 735 kNumberOfChannels, |
| 736 kSamplesPerSecond, kTotalDelayMs, | 736 kSamplesPerSecond, kTotalDelayMs, |
| 737 kClockDriftMs, current_mic_level, | 737 kClockDriftMs, current_mic_level, |
| 738 key_pressed, | 738 key_pressed, |
| 739 current_mic_level) != 0) { | 739 current_mic_level) != 0) { |
| 740 ASSERT(false); | 740 ASSERT(false); |
| 741 } | 741 } |
| 742 SetMicrophoneVolume(current_mic_level); | 742 SetMicrophoneVolume(current_mic_level); |
| 743 } | 743 } |
| 744 | 744 |
| OLD | NEW |