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 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 // remote side unless a packet containing a sample of that magnitude has been | 616 // remote side unless a packet containing a sample of that magnitude has been |
617 // sent to it. Note that the audio processing pipeline will likely distort the | 617 // sent to it. Note that the audio processing pipeline will likely distort the |
618 // original signal. | 618 // original signal. |
619 SetSendBuffer(kHighSampleValue); | 619 SetSendBuffer(kHighSampleValue); |
620 last_process_time_ms_ = rtc::Time(); | 620 last_process_time_ms_ = rtc::Time(); |
621 return true; | 621 return true; |
622 } | 622 } |
623 | 623 |
624 void FakeAudioCaptureModule::SetSendBuffer(int value) { | 624 void FakeAudioCaptureModule::SetSendBuffer(int value) { |
625 Sample* buffer_ptr = reinterpret_cast<Sample*>(send_buffer_); | 625 Sample* buffer_ptr = reinterpret_cast<Sample*>(send_buffer_); |
626 const int buffer_size_in_samples = | 626 const size_t buffer_size_in_samples = |
627 sizeof(send_buffer_) / kNumberBytesPerSample; | 627 sizeof(send_buffer_) / kNumberBytesPerSample; |
628 for (int i = 0; i < buffer_size_in_samples; ++i) { | 628 for (size_t i = 0; i < buffer_size_in_samples; ++i) { |
629 buffer_ptr[i] = value; | 629 buffer_ptr[i] = value; |
630 } | 630 } |
631 } | 631 } |
632 | 632 |
633 void FakeAudioCaptureModule::ResetRecBuffer() { | 633 void FakeAudioCaptureModule::ResetRecBuffer() { |
634 memset(rec_buffer_, 0, sizeof(rec_buffer_)); | 634 memset(rec_buffer_, 0, sizeof(rec_buffer_)); |
635 } | 635 } |
636 | 636 |
637 bool FakeAudioCaptureModule::CheckRecBuffer(int value) { | 637 bool FakeAudioCaptureModule::CheckRecBuffer(int value) { |
638 const Sample* buffer_ptr = reinterpret_cast<const Sample*>(rec_buffer_); | 638 const Sample* buffer_ptr = reinterpret_cast<const Sample*>(rec_buffer_); |
639 const int buffer_size_in_samples = | 639 const size_t buffer_size_in_samples = |
640 sizeof(rec_buffer_) / kNumberBytesPerSample; | 640 sizeof(rec_buffer_) / kNumberBytesPerSample; |
641 for (int i = 0; i < buffer_size_in_samples; ++i) { | 641 for (size_t i = 0; i < buffer_size_in_samples; ++i) { |
642 if (buffer_ptr[i] >= value) return true; | 642 if (buffer_ptr[i] >= value) return true; |
643 } | 643 } |
644 return false; | 644 return false; |
645 } | 645 } |
646 | 646 |
647 bool FakeAudioCaptureModule::ShouldStartProcessing() { | 647 bool FakeAudioCaptureModule::ShouldStartProcessing() { |
648 return recording_ || playing_; | 648 return recording_ || playing_; |
649 } | 649 } |
650 | 650 |
651 void FakeAudioCaptureModule::UpdateProcessing(bool start) { | 651 void FakeAudioCaptureModule::UpdateProcessing(bool start) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 } | 696 } |
697 | 697 |
698 void FakeAudioCaptureModule::ReceiveFrameP() { | 698 void FakeAudioCaptureModule::ReceiveFrameP() { |
699 ASSERT(rtc::Thread::Current() == process_thread_); | 699 ASSERT(rtc::Thread::Current() == process_thread_); |
700 { | 700 { |
701 rtc::CritScope cs(&crit_callback_); | 701 rtc::CritScope cs(&crit_callback_); |
702 if (!audio_callback_) { | 702 if (!audio_callback_) { |
703 return; | 703 return; |
704 } | 704 } |
705 ResetRecBuffer(); | 705 ResetRecBuffer(); |
706 uint32_t nSamplesOut = 0; | 706 size_t nSamplesOut = 0; |
707 int64_t elapsed_time_ms = 0; | 707 int64_t elapsed_time_ms = 0; |
708 int64_t ntp_time_ms = 0; | 708 int64_t ntp_time_ms = 0; |
709 if (audio_callback_->NeedMorePlayData(kNumberSamples, kNumberBytesPerSample, | 709 if (audio_callback_->NeedMorePlayData(kNumberSamples, kNumberBytesPerSample, |
710 kNumberOfChannels, kSamplesPerSecond, | 710 kNumberOfChannels, kSamplesPerSecond, |
711 rec_buffer_, nSamplesOut, | 711 rec_buffer_, nSamplesOut, |
712 &elapsed_time_ms, &ntp_time_ms) != 0) { | 712 &elapsed_time_ms, &ntp_time_ms) != 0) { |
713 ASSERT(false); | 713 ASSERT(false); |
714 } | 714 } |
715 ASSERT(nSamplesOut == kNumberSamples); | 715 ASSERT(nSamplesOut == kNumberSamples); |
716 } | 716 } |
(...skipping 28 matching lines...) Expand all Loading... |
745 ASSERT(false); | 745 ASSERT(false); |
746 } | 746 } |
747 SetMicrophoneVolume(current_mic_level); | 747 SetMicrophoneVolume(current_mic_level); |
748 } | 748 } |
749 | 749 |
750 void FakeAudioCaptureModule::StopProcessP() { | 750 void FakeAudioCaptureModule::StopProcessP() { |
751 ASSERT(rtc::Thread::Current() == process_thread_); | 751 ASSERT(rtc::Thread::Current() == process_thread_); |
752 started_ = false; | 752 started_ = false; |
753 process_thread_->Clear(this); | 753 process_thread_->Clear(this); |
754 } | 754 } |
OLD | NEW |