OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/media/media_stream_audio_processor.h" | 5 #include "content/renderer/media/media_stream_audio_processor.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 // render thread and used in the audio thread, for example, the | 63 // render thread and used in the audio thread, for example, the |
64 // |MediaStreamAudioProcessor::capture_converter_|. | 64 // |MediaStreamAudioProcessor::capture_converter_|. |
65 thread_checker_.DetachFromThread(); | 65 thread_checker_.DetachFromThread(); |
66 audio_converter_.AddInput(this); | 66 audio_converter_.AddInput(this); |
67 // Create and initialize audio fifo and audio bus wrapper. | 67 // Create and initialize audio fifo and audio bus wrapper. |
68 // The size of the FIFO should be at least twice of the source buffer size | 68 // The size of the FIFO should be at least twice of the source buffer size |
69 // or twice of the sink buffer size. | 69 // or twice of the sink buffer size. |
70 int buffer_size = std::max( | 70 int buffer_size = std::max( |
71 kMaxNumberOfBuffersInFifo * source_params_.frames_per_buffer(), | 71 kMaxNumberOfBuffersInFifo * source_params_.frames_per_buffer(), |
72 kMaxNumberOfBuffersInFifo * sink_params_.frames_per_buffer()); | 72 kMaxNumberOfBuffersInFifo * sink_params_.frames_per_buffer()); |
73 | |
74 // Also, FIFO needs to have enough space to store pre-processed data | |
henrika (OOO until Aug 14)
2014/06/02 08:23:41
Is it possible to set the buffer size once only an
no longer working on chromium
2014/06/02 09:15:08
Yes, I added a max_frame_size as a temp variable t
| |
75 // before passing the data to webrtc::AudioProcessing, which requires 10ms | |
76 // as packet size. | |
77 buffer_size = std::max( | |
78 buffer_size, | |
79 kMaxNumberOfBuffersInFifo * source_params_.sample_rate() / 100); | |
73 fifo_.reset(new media::AudioFifo(source_params_.channels(), buffer_size)); | 80 fifo_.reset(new media::AudioFifo(source_params_.channels(), buffer_size)); |
74 // TODO(xians): Use CreateWrapper to save one memcpy. | 81 // TODO(xians): Use CreateWrapper to save one memcpy. |
75 audio_wrapper_ = media::AudioBus::Create(sink_params_.channels(), | 82 audio_wrapper_ = media::AudioBus::Create(sink_params_.channels(), |
76 sink_params_.frames_per_buffer()); | 83 sink_params_.frames_per_buffer()); |
77 } | 84 } |
78 | 85 |
79 virtual ~MediaStreamAudioConverter() { | 86 virtual ~MediaStreamAudioConverter() { |
80 audio_converter_.RemoveInput(this); | 87 audio_converter_.RemoveInput(this); |
81 } | 88 } |
82 | 89 |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
491 | 498 |
492 StopAecDump(); | 499 StopAecDump(); |
493 | 500 |
494 if (playout_data_source_) | 501 if (playout_data_source_) |
495 playout_data_source_->RemovePlayoutSink(this); | 502 playout_data_source_->RemovePlayoutSink(this); |
496 | 503 |
497 audio_processing_.reset(); | 504 audio_processing_.reset(); |
498 } | 505 } |
499 | 506 |
500 } // namespace content | 507 } // namespace content |
OLD | NEW |