Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: content/renderer/media/webrtc_audio_device_unittest.cc

Issue 12049070: Avoids irregular OnMoreData callbacks on Windows using Core Audio (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Non trivial rebase Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/environment.h" 5 #include "base/environment.h"
6 #include "base/test/test_timeouts.h" 6 #include "base/test/test_timeouts.h"
7 #include "content/renderer/media/webrtc_audio_capturer.h" 7 #include "content/renderer/media/webrtc_audio_capturer.h"
8 #include "content/renderer/media/webrtc_audio_device_impl.h" 8 #include "content/renderer/media/webrtc_audio_device_impl.h"
9 #include "content/renderer/media/webrtc_audio_renderer.h" 9 #include "content/renderer/media/webrtc_audio_renderer.h"
10 #include "content/renderer/render_thread_impl.h" 10 #include "content/renderer/render_thread_impl.h"
(...skipping 23 matching lines...) Expand all
34 scoped_ptr<media::AudioHardwareConfig> CreateRealHardwareConfig() { 34 scoped_ptr<media::AudioHardwareConfig> CreateRealHardwareConfig() {
35 return make_scoped_ptr(new media::AudioHardwareConfig( 35 return make_scoped_ptr(new media::AudioHardwareConfig(
36 media::GetAudioHardwareBufferSize(), media::GetAudioHardwareSampleRate(), 36 media::GetAudioHardwareBufferSize(), media::GetAudioHardwareSampleRate(),
37 media::GetAudioInputHardwareSampleRate( 37 media::GetAudioInputHardwareSampleRate(
38 media::AudioManagerBase::kDefaultDeviceId), 38 media::AudioManagerBase::kDefaultDeviceId),
39 media::GetAudioInputHardwareChannelLayout( 39 media::GetAudioInputHardwareChannelLayout(
40 media::AudioManagerBase::kDefaultDeviceId))); 40 media::AudioManagerBase::kDefaultDeviceId)));
41 } 41 }
42 42
43 // Return true if at least one element in the array matches |value|. 43 // Return true if at least one element in the array matches |value|.
44 bool FindElementInArray(int* array, int size, int value) { 44 bool FindElementInArray(const int* array, int size, int value) {
45 return (std::find(&array[0], &array[0] + size, value) != &array[size]); 45 return (std::find(&array[0], &array[0] + size, value) != &array[size]);
46 } 46 }
47 47
48 // This method returns false if a non-supported rate is detected on the 48 // This method returns false if a non-supported rate is detected on the
49 // input or output side. 49 // input or output side.
50 // TODO(henrika): add support for automatic fallback to Windows Wave audio 50 // TODO(henrika): add support for automatic fallback to Windows Wave audio
51 // if a non-supported rate is detected. It is probably better to detect 51 // if a non-supported rate is detected. It is probably better to detect
52 // invalid audio settings by actually trying to open the audio streams instead 52 // invalid audio settings by actually trying to open the audio streams instead
53 // of relying on hard coded conditions. 53 // of relying on hard coded conditions.
54 bool HardwareSampleRatesAreValid() { 54 bool HardwareSampleRatesAreValid() {
55 // These are the currently supported hardware sample rates in both directions. 55 // These are the currently supported hardware sample rates in both directions.
56 // The actual WebRTC client can limit these ranges further depending on 56 // The actual WebRTC client can limit these ranges further depending on
57 // platform but this is the maximum range we support today. 57 // platform but this is the maximum range we support today.
58 int valid_input_rates[] = {16000, 32000, 44100, 48000, 96000}; 58 int valid_input_rates[] = {16000, 32000, 44100, 48000, 96000};
59 int valid_output_rates[] = {44100, 48000, 96000}; 59 int valid_output_rates[] = {16000, 32000, 44100, 48000, 96000};
60 60
61 media::AudioHardwareConfig* hardware_config = 61 media::AudioHardwareConfig* hardware_config =
62 RenderThreadImpl::current()->GetAudioHardwareConfig(); 62 RenderThreadImpl::current()->GetAudioHardwareConfig();
63 63
64 // Verify the input sample rate. 64 // Verify the input sample rate.
65 int input_sample_rate = hardware_config->GetInputSampleRate(); 65 int input_sample_rate = hardware_config->GetInputSampleRate();
66 66
67 if (!FindElementInArray(valid_input_rates, arraysize(valid_input_rates), 67 if (!FindElementInArray(valid_input_rates, arraysize(valid_input_rates),
68 input_sample_rate)) { 68 input_sample_rate)) {
69 LOG(WARNING) << "Non-supported input sample rate detected."; 69 LOG(WARNING) << "Non-supported input sample rate detected.";
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 531
532 renderer->Stop(); 532 renderer->Stop();
533 EXPECT_EQ(0, base->StopSend(ch)); 533 EXPECT_EQ(0, base->StopSend(ch));
534 EXPECT_EQ(0, base->StopPlayout(ch)); 534 EXPECT_EQ(0, base->StopPlayout(ch));
535 535
536 EXPECT_EQ(0, base->DeleteChannel(ch)); 536 EXPECT_EQ(0, base->DeleteChannel(ch));
537 EXPECT_EQ(0, base->Terminate()); 537 EXPECT_EQ(0, base->Terminate());
538 } 538 }
539 539
540 } // namespace content 540 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/webrtc_audio_renderer.h » ('j') | content/renderer/media/webrtc_audio_renderer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698