OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/webrtc_audio_device_impl.h" | 5 #include "content/renderer/media/webrtc_audio_device_impl.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "media/audio/audio_util.h" | 8 #include "media/audio/audio_util.h" |
9 | 9 |
10 // TODO(henrika): come up with suitable value(s) for all platforms. | 10 // TODO(henrika): come up with suitable value(s) for all platforms. |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 if (!audio_transport_callback_) { | 382 if (!audio_transport_callback_) { |
383 LOG(ERROR) << "Audio transport is missing"; | 383 LOG(ERROR) << "Audio transport is missing"; |
384 return -1; | 384 return -1; |
385 } | 385 } |
386 if (recording_) { | 386 if (recording_) { |
387 // webrtc::VoiceEngine assumes that it is OK to call Start() twice and | 387 // webrtc::VoiceEngine assumes that it is OK to call Start() twice and |
388 // that the call is ignored the second time. | 388 // that the call is ignored the second time. |
389 LOG(WARNING) << "Recording is already active"; | 389 LOG(WARNING) << "Recording is already active"; |
390 return 0; | 390 return 0; |
391 } | 391 } |
392 recording_ = audio_input_device_->Start(); | 392 audio_input_device_->Start(); |
393 return (recording_ ? 0 : -1); | 393 recording_ = true; |
| 394 return 0; |
394 } | 395 } |
395 | 396 |
396 int32_t WebRtcAudioDeviceImpl::StopRecording() { | 397 int32_t WebRtcAudioDeviceImpl::StopRecording() { |
397 VLOG(1) << "StopRecording()"; | 398 VLOG(1) << "StopRecording()"; |
398 DCHECK(audio_input_device_); | 399 DCHECK(audio_input_device_); |
399 if (!recording_) { | 400 if (!recording_) { |
400 // webrtc::VoiceEngine assumes that it is OK to call Stop() just in case. | 401 // webrtc::VoiceEngine assumes that it is OK to call Stop() just in case. |
401 LOG(WARNING) << "Recording was already stopped"; | 402 LOG(WARNING) << "Recording was already stopped"; |
402 return 0; | 403 return 0; |
403 } | 404 } |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 size_t buffer_size, float sample_rate) const { | 724 size_t buffer_size, float sample_rate) const { |
724 const int samples_per_sec = static_cast<int>(sample_rate); | 725 const int samples_per_sec = static_cast<int>(sample_rate); |
725 const int samples_per_10_msec = (samples_per_sec / 100); | 726 const int samples_per_10_msec = (samples_per_sec / 100); |
726 bool size_is_valid = (((buffer_size % samples_per_10_msec) == 0) && | 727 bool size_is_valid = (((buffer_size % samples_per_10_msec) == 0) && |
727 (buffer_size <= kMaxBufferSize)); | 728 (buffer_size <= kMaxBufferSize)); |
728 DLOG_IF(WARNING, !size_is_valid) << "Size of buffer must be and even " | 729 DLOG_IF(WARNING, !size_is_valid) << "Size of buffer must be and even " |
729 << "multiple of 10 ms and less than " | 730 << "multiple of 10 ms and less than " |
730 << kMaxBufferSize; | 731 << kMaxBufferSize; |
731 return size_is_valid; | 732 return size_is_valid; |
732 } | 733 } |
OLD | NEW |