| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_renderer.h" | 5 #include "content/renderer/media/webrtc_audio_renderer.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 // we change the rate to 48000 instead. The consequence is that the native | 231 // we change the rate to 48000 instead. The consequence is that the native |
| 232 // layer will be opened up at 192kHz but WebRTC will provide data at 48kHz | 232 // layer will be opened up at 192kHz but WebRTC will provide data at 48kHz |
| 233 // which will then be resampled by the audio converted on the browser side | 233 // which will then be resampled by the audio converted on the browser side |
| 234 // to match the native audio layer. | 234 // to match the native audio layer. |
| 235 int sample_rate = sink_params_.sample_rate(); | 235 int sample_rate = sink_params_.sample_rate(); |
| 236 DVLOG(1) << "Audio output hardware sample rate: " << sample_rate; | 236 DVLOG(1) << "Audio output hardware sample rate: " << sample_rate; |
| 237 if (sample_rate == 192000) { | 237 if (sample_rate == 192000) { |
| 238 DVLOG(1) << "Resampling from 48000 to 192000 is required"; | 238 DVLOG(1) << "Resampling from 48000 to 192000 is required"; |
| 239 sample_rate = 48000; | 239 sample_rate = 48000; |
| 240 } | 240 } |
| 241 media::AudioSampleRate asr = media::AsAudioSampleRate(sample_rate); | 241 media::AudioSampleRate asr; |
| 242 if (asr != media::kUnexpectedAudioSampleRate) { | 242 if (media::ToAudioSampleRate(sample_rate, &asr)) { |
| 243 UMA_HISTOGRAM_ENUMERATION( | 243 UMA_HISTOGRAM_ENUMERATION( |
| 244 "WebRTC.AudioOutputSampleRate", asr, media::kUnexpectedAudioSampleRate); | 244 "WebRTC.AudioOutputSampleRate", asr, media::kAudioSampleRateMax + 1); |
| 245 } else { | 245 } else { |
| 246 UMA_HISTOGRAM_COUNTS("WebRTC.AudioOutputSampleRateUnexpected", | 246 UMA_HISTOGRAM_COUNTS("WebRTC.AudioOutputSampleRateUnexpected", |
| 247 sample_rate); | 247 sample_rate); |
| 248 } | 248 } |
| 249 | 249 |
| 250 // Verify that the reported output hardware sample rate is supported | 250 // Verify that the reported output hardware sample rate is supported |
| 251 // on the current platform. | 251 // on the current platform. |
| 252 if (std::find(&kValidOutputRates[0], | 252 if (std::find(&kValidOutputRates[0], |
| 253 &kValidOutputRates[0] + arraysize(kValidOutputRates), | 253 &kValidOutputRates[0] + arraysize(kValidOutputRates), |
| 254 sample_rate) == | 254 sample_rate) == |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 DCHECK_GE(session_id_, 0); | 329 DCHECK_GE(session_id_, 0); |
| 330 sink_->InitializeUnifiedStream(sink_params_, this, session_id_); | 330 sink_->InitializeUnifiedStream(sink_params_, this, session_id_); |
| 331 | 331 |
| 332 sink_->Start(); | 332 sink_->Start(); |
| 333 | 333 |
| 334 // User must call Play() before any audio can be heard. | 334 // User must call Play() before any audio can be heard. |
| 335 state_ = PAUSED; | 335 state_ = PAUSED; |
| 336 | 336 |
| 337 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioOutputChannelLayout", | 337 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioOutputChannelLayout", |
| 338 source_params.channel_layout(), | 338 source_params.channel_layout(), |
| 339 media::CHANNEL_LAYOUT_MAX); | 339 media::CHANNEL_LAYOUT_MAX + 1); |
| 340 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioOutputFramesPerBuffer", | 340 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioOutputFramesPerBuffer", |
| 341 source_params.frames_per_buffer(), | 341 source_params.frames_per_buffer(), |
| 342 kUnexpectedAudioBufferSize); | 342 kUnexpectedAudioBufferSize); |
| 343 AddHistogramFramesPerBuffer(source_params.frames_per_buffer()); | 343 AddHistogramFramesPerBuffer(source_params.frames_per_buffer()); |
| 344 | 344 |
| 345 return true; | 345 return true; |
| 346 } | 346 } |
| 347 | 347 |
| 348 scoped_refptr<MediaStreamAudioRenderer> | 348 scoped_refptr<MediaStreamAudioRenderer> |
| 349 WebRtcAudioRenderer::CreateSharedAudioRendererProxy( | 349 WebRtcAudioRenderer::CreateSharedAudioRendererProxy( |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 if (RemovePlayingState(source, state)) | 586 if (RemovePlayingState(source, state)) |
| 587 EnterPauseState(); | 587 EnterPauseState(); |
| 588 } else if (AddPlayingState(source, state)) { | 588 } else if (AddPlayingState(source, state)) { |
| 589 EnterPlayState(); | 589 EnterPlayState(); |
| 590 } | 590 } |
| 591 UpdateSourceVolume(source); | 591 UpdateSourceVolume(source); |
| 592 } | 592 } |
| 593 } | 593 } |
| 594 | 594 |
| 595 } // namespace content | 595 } // namespace content |
| OLD | NEW |