diff options
author | dgrogan <dgrogan@chromium.org> | 2015-09-21 17:48:30 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-22 00:49:12 +0000 |
commit | cc04c8e76ea5ab5e2584b223d5cce5b79d2a2247 (patch) | |
tree | 1fa1fdc0afd4198f5cf8aa51c838fc9841e0d4e9 | |
parent | 62a5d5e0c9d1302d19c8d3e624cd19a54012bb8f (diff) | |
download | chromium_src-cc04c8e76ea5ab5e2584b223d5cce5b79d2a2247.zip chromium_src-cc04c8e76ea5ab5e2584b223d5cce5b79d2a2247.tar.gz chromium_src-cc04c8e76ea5ab5e2584b223d5cce5b79d2a2247.tar.bz2 |
Revert "Add localized default audio device names."
This reverts commit 943e1b33dac970c6a970d085b66c5c526d6b9870.
This is a revert of https://codereview.chromium.org/1339183002
NOTREECHECKS=true
NOTRY=true
TBR=ajm
Review URL: https://codereview.chromium.org/1346933006
Cr-Commit-Position: refs/heads/master@{#350073}
34 files changed, 90 insertions, 303 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index b9aa503..c5ab95b 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -15348,24 +15348,6 @@ After you create a new supervised user, you can manage their settings at any tim </message> </if> - <!-- Audio device strings. --> - <message name="IDS_DEFAULT_AUDIO_DEVICE_NAME" desc="System default audio device (microphone or loudspeaker). This is typically presented to users in a drop-down list of device choices."> - Default - </message> - <if expr="is_win"> - <message name="IDS_COMMUNICATIONS_AUDIO_DEVICE_NAME" desc="System default communications audio device (microphone or loudspeaker). This is typically presented to users in a drop-down list of device choices."> - Communications - </message> - </if> - <if expr="chromeos"> - <message name="IDS_BEAMFORMING_ON_DEFAULT_AUDIO_INPUT_DEVICE_NAME" desc="Default audio input device (microphone) with a narrow angle coverage. Only the user in front of the device (i.e. you) will be listened to. This is typically presented to users in a drop-down list of device choices."> - Default (pick up just you) - </message> - <message name="IDS_BEAMFORMING_OFF_DEFAULT_AUDIO_INPUT_DEVICE_NAME" desc="Default audio input device (microphone) with a wide angle coverage. All the sounds in the vicinity will be listend to. This is typically presented to users in a drop-down list of device choices."> - Default (pick up everything) - </message> - </if> - </messages> </release> </grit> diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index 5ed4efd..f23f185 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -100,7 +100,6 @@ #include "chrome/common/crash_keys.h" #include "chrome/common/env_vars.h" #include "chrome/common/logging_chrome.h" -#include "chrome/common/media/media_resource_provider.h" #include "chrome/common/net/net_resource_provider.h" #include "chrome/common/pref_names.h" #include "chrome/common/profiling.h" @@ -140,7 +139,6 @@ #include "content/public/common/main_function_params.h" #include "grit/platform_locale_settings.h" #include "media/audio/audio_manager.h" -#include "media/base/media_resources.h" #include "net/base/net_module.h" #include "net/cookies/cookie_monster.h" #include "net/http/http_network_layer.h" @@ -1527,8 +1525,6 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { // Configure modules that need access to resources. net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); - media::SetLocalizedStringProvider( - chrome_common_media::LocalizedStringProvider); // In unittest mode, this will do nothing. In normal mode, this will create // the global IntranetRedirectDetector instance, which will promptly go to diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi index 931154d..37c315a 100644 --- a/chrome/chrome_common.gypi +++ b/chrome/chrome_common.gypi @@ -71,8 +71,6 @@ 'common/mac/launchd.mm', 'common/mac/objc_zombie.h', 'common/mac/objc_zombie.mm', - 'common/media/media_resource_provider.cc', - 'common/media/media_resource_provider.h', 'common/media/webrtc_logging_message_data.cc', 'common/media/webrtc_logging_message_data.h', 'common/media/webrtc_logging_messages.h', @@ -347,7 +345,6 @@ '<(DEPTH)/components/url_formatter/url_formatter.gyp:url_formatter', '<(DEPTH)/content/content.gyp:content_common', '<(DEPTH)/crypto/crypto.gyp:crypto', - '<(DEPTH)/media/media.gyp:media', '<(DEPTH)/net/net.gyp:net', '<(DEPTH)/skia/skia.gyp:skia', '<(DEPTH)/skia/skia.gyp:skia_library', diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi index f40d1ef..d7fb721 100644 --- a/chrome/chrome_renderer.gypi +++ b/chrome/chrome_renderer.gypi @@ -261,7 +261,6 @@ '../content/app/resources/content_resources.gyp:content_resources', '../content/app/strings/content_strings.gyp:content_strings', '../content/content.gyp:content_renderer', - '../media/media.gyp:media', '../net/net.gyp:net', '../skia/skia.gyp:skia', '../third_party/WebKit/public/blink.gyp:blink', diff --git a/chrome/common/BUILD.gn b/chrome/common/BUILD.gn index adbf895..7a8f7a7 100644 --- a/chrome/common/BUILD.gn +++ b/chrome/common/BUILD.gn @@ -78,7 +78,6 @@ static_library("common") { "//content/public/common", "//crypto", "//extensions/common:common_constants", - "//media", "//net", "//skia", "//third_party/icu", diff --git a/chrome/common/media/media_resource_provider.cc b/chrome/common/media/media_resource_provider.cc deleted file mode 100644 index cc00bf5..0000000 --- a/chrome/common/media/media_resource_provider.cc +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/logging.h" -#include "chrome/common/media/media_resource_provider.h" -#include "chrome/grit/generated_resources.h" -#include "ui/base/l10n/l10n_util.h" - -namespace chrome_common_media { - -int MediaMessageIdToGrdId(media::MessageId message_id) { - switch (message_id) { - case media::DEFAULT_AUDIO_DEVICE_NAME: - return IDS_DEFAULT_AUDIO_DEVICE_NAME; -#if defined(OS_WIN) - case media::COMMUNICATIONS_AUDIO_DEVICE_NAME: - return IDS_COMMUNICATIONS_AUDIO_DEVICE_NAME; -#endif -#if defined(OS_CHROMEOS) - case media::BEAMFORMING_ON_DEFAULT_AUDIO_INPUT_DEVICE_NAME: - return IDS_BEAMFORMING_ON_DEFAULT_AUDIO_INPUT_DEVICE_NAME; - case media::BEAMFORMING_OFF_DEFAULT_AUDIO_INPUT_DEVICE_NAME: - return IDS_BEAMFORMING_OFF_DEFAULT_AUDIO_INPUT_DEVICE_NAME; -#endif - default: - NOTREACHED(); - return 0; - } -} - -base::string16 LocalizedStringProvider(media::MessageId message_id) { - return l10n_util::GetStringUTF16(MediaMessageIdToGrdId(message_id)); -} - -} // namespace chrome_common_media diff --git a/chrome/common/media/media_resource_provider.h b/chrome/common/media/media_resource_provider.h deleted file mode 100644 index b1b5e76..0000000 --- a/chrome/common/media/media_resource_provider.h +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_COMMON_MEDIA_MEDIA_RESOURCE_PROVIDER_H_ -#define CHROME_COMMON_MEDIA_MEDIA_RESOURCE_PROVIDER_H_ - -#include "base/strings/string16.h" -#include "media/base/media_resources.h" - -namespace chrome_common_media { - -// This is called indirectly by the media layer to access resources. -base::string16 LocalizedStringProvider(media::MessageId media_message_id); - -} // namespace chrome_common_media - -#endif // CHROME_COMMON_MEDIA_MEDIA_RESOURCE_PROVIDER_H_ diff --git a/chrome/renderer/BUILD.gn b/chrome/renderer/BUILD.gn index a5921ce..a930338 100644 --- a/chrome/renderer/BUILD.gn +++ b/chrome/renderer/BUILD.gn @@ -57,7 +57,6 @@ static_library("renderer") { "//content/app/resources", "//content/app/strings", "//content/public/renderer", - "//media", "//net", "//skia", "//storage/common", diff --git a/chrome/renderer/DEPS b/chrome/renderer/DEPS index 5cf6cbf..1170c43 100644 --- a/chrome/renderer/DEPS +++ b/chrome/renderer/DEPS @@ -34,7 +34,6 @@ include_rules = [ "+content/public/renderer", "+extensions/common", "+extensions/renderer", - "+media/base", "+gin", "+grit", # For generated headers. TODO(thestig): Remove. "+ppapi/c", diff --git a/chrome/renderer/chrome_render_process_observer.cc b/chrome/renderer/chrome_render_process_observer.cc index 3a9d958..fc8de3c 100644 --- a/chrome/renderer/chrome_render_process_observer.cc +++ b/chrome/renderer/chrome_render_process_observer.cc @@ -24,7 +24,6 @@ #include "chrome/common/child_process_logging.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/media/media_resource_provider.h" #include "chrome/common/net/net_resource_provider.h" #include "chrome/common/render_messages.h" #include "chrome/common/resource_usage_reporter.mojom.h" @@ -39,7 +38,6 @@ #include "content/public/renderer/render_view.h" #include "content/public/renderer/render_view_visitor.h" #include "crypto/nss_util.h" -#include "media/base/media_resources.h" #include "net/base/net_errors.h" #include "net/base/net_module.h" #include "third_party/WebKit/public/web/WebCache.h" @@ -253,8 +251,6 @@ ChromeRenderProcessObserver::ChromeRenderProcessObserver() // Configure modules that need access to resources. net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); - media::SetLocalizedStringProvider( - chrome_common_media::LocalizedStringProvider); #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(USE_OPENSSL) // On platforms where we use system NSS shared libraries, diff --git a/content/browser/renderer_host/media/audio_output_device_enumerator.cc b/content/browser/renderer_host/media/audio_output_device_enumerator.cc index 13f875f..516cde0 100644 --- a/content/browser/renderer_host/media/audio_output_device_enumerator.cc +++ b/content/browser/renderer_host/media/audio_output_device_enumerator.cc @@ -26,7 +26,7 @@ AudioOutputDeviceEnumeration EnumerateDevicesOnDeviceThread( // If no devices in enumeration, return a list with a default device if (device_names.empty()) { snapshot.push_back({media::AudioManagerBase::kDefaultDeviceId, - media::AudioManager::GetDefaultDeviceName(), + media::AudioManagerBase::kDefaultDeviceName, audio_manager->GetDefaultOutputStreamParameters()}); return snapshot; } diff --git a/media/BUILD.gn b/media/BUILD.gn index 5154e4c..68c1e5f 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -531,7 +531,6 @@ component("media") { "//skia", "//third_party/libyuv", "//third_party/opus", - "//ui/base", "//ui/events:events_base", "//ui/gfx", "//ui/gfx/geometry", diff --git a/media/audio/alsa/audio_manager_alsa.cc b/media/audio/alsa/audio_manager_alsa.cc index 1d658fc..325c372 100644 --- a/media/audio/alsa/audio_manager_alsa.cc +++ b/media/audio/alsa/audio_manager_alsa.cc @@ -163,9 +163,9 @@ void AudioManagerAlsa::GetAlsaDevicesInfo( // still empty. Note, pulse has exclusively opened the default // device, so we must open the device via the "default" moniker. if (device_names->empty()) { - device_names->push_front( - media::AudioDeviceName(AudioManager::GetDefaultDeviceName(), - AudioManagerBase::kDefaultDeviceId)); + device_names->push_front(media::AudioDeviceName( + AudioManagerBase::kDefaultDeviceName, + AudioManagerBase::kDefaultDeviceId)); } // Get the unique device name for the device. diff --git a/media/audio/android/audio_android_unittest.cc b/media/audio/android/audio_android_unittest.cc index a6f9421..38269bc 100644 --- a/media/audio/android/audio_android_unittest.cc +++ b/media/audio/android/audio_android_unittest.cc @@ -35,7 +35,6 @@ using ::testing::NotNull; using ::testing::Return; namespace media { -namespace { ACTION_P3(CheckCountAndPostQuitTask, count, limit, loop) { if (++*count >= limit) { @@ -43,17 +42,17 @@ ACTION_P3(CheckCountAndPostQuitTask, count, limit, loop) { } } -const char kSpeechFile_16b_s_48k[] = "speech_16b_stereo_48kHz.raw"; -const char kSpeechFile_16b_m_48k[] = "speech_16b_mono_48kHz.raw"; -const char kSpeechFile_16b_s_44k[] = "speech_16b_stereo_44kHz.raw"; -const char kSpeechFile_16b_m_44k[] = "speech_16b_mono_44kHz.raw"; +static const char kSpeechFile_16b_s_48k[] = "speech_16b_stereo_48kHz.raw"; +static const char kSpeechFile_16b_m_48k[] = "speech_16b_mono_48kHz.raw"; +static const char kSpeechFile_16b_s_44k[] = "speech_16b_stereo_44kHz.raw"; +static const char kSpeechFile_16b_m_44k[] = "speech_16b_mono_44kHz.raw"; -const float kCallbackTestTimeMs = 2000.0; -const int kBitsPerSample = 16; -const int kBytesPerSample = kBitsPerSample / 8; +static const float kCallbackTestTimeMs = 2000.0; +static const int kBitsPerSample = 16; +static const int kBytesPerSample = kBitsPerSample / 8; // Converts AudioParameters::Format enumerator to readable string. -std::string FormatToString(AudioParameters::Format format) { +static std::string FormatToString(AudioParameters::Format format) { switch (format) { case AudioParameters::AUDIO_PCM_LINEAR: return std::string("AUDIO_PCM_LINEAR"); @@ -68,7 +67,7 @@ std::string FormatToString(AudioParameters::Format format) { // Converts ChannelLayout enumerator to readable string. Does not include // multi-channel cases since these layouts are not supported on Android. -std::string LayoutToString(ChannelLayout channel_layout) { +static std::string LayoutToString(ChannelLayout channel_layout) { switch (channel_layout) { case CHANNEL_LAYOUT_NONE: return std::string("CHANNEL_LAYOUT_NONE"); @@ -82,7 +81,7 @@ std::string LayoutToString(ChannelLayout channel_layout) { } } -double ExpectedTimeBetweenCallbacks(AudioParameters params) { +static double ExpectedTimeBetweenCallbacks(AudioParameters params) { return (base::TimeDelta::FromMicroseconds( params.frames_per_buffer() * base::Time::kMicrosecondsPerSecond / static_cast<double>(params.sample_rate()))).InMillisecondsF(); @@ -90,7 +89,7 @@ double ExpectedTimeBetweenCallbacks(AudioParameters params) { // Helper method which verifies that the device list starts with a valid // default device name followed by non-default device names. -void CheckDeviceNames(const AudioDeviceNames& device_names) { +static void CheckDeviceNames(const AudioDeviceNames& device_names) { DVLOG(2) << "Got " << device_names.size() << " audio devices."; if (device_names.empty()) { // Log a warning so we can see the status on the build bots. No need to @@ -103,7 +102,8 @@ void CheckDeviceNames(const AudioDeviceNames& device_names) { AudioDeviceNames::const_iterator it = device_names.begin(); // The first device in the list should always be the default device. - EXPECT_EQ(AudioManager::GetDefaultDeviceName(), it->device_name); + EXPECT_EQ(std::string(AudioManagerBase::kDefaultDeviceName), + it->device_name); EXPECT_EQ(std::string(AudioManagerBase::kDefaultDeviceId), it->unique_id); ++it; @@ -114,20 +114,20 @@ void CheckDeviceNames(const AudioDeviceNames& device_names) { EXPECT_FALSE(it->unique_id.empty()); DVLOG(2) << "Device ID(" << it->unique_id << "), label: " << it->device_name; - EXPECT_NE(AudioManager::GetDefaultDeviceName(), it->device_name); - EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceId), it->unique_id); + EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceName), + it->device_name); + EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceId), + it->unique_id); ++it; } } // We clear the data bus to ensure that the test does not cause noise. -int RealOnMoreData(AudioBus* dest, uint32 total_bytes_delay) { +static int RealOnMoreData(AudioBus* dest, uint32 total_bytes_delay) { dest->Zero(); return dest->frames(); } -} // namespace - std::ostream& operator<<(std::ostream& os, const AudioParameters& params) { using namespace std; os << endl << "format: " << FormatToString(params.format()) << endl diff --git a/media/audio/android/audio_manager_android.cc b/media/audio/android/audio_manager_android.cc index 01379b8..e231cd1 100644 --- a/media/audio/android/audio_manager_android.cc +++ b/media/audio/android/audio_manager_android.cc @@ -28,21 +28,19 @@ using base::android::ConvertUTF8ToJavaString; using base::android::ScopedJavaLocalRef; namespace media { -namespace { -void AddDefaultDevice(AudioDeviceNames* device_names) { +static void AddDefaultDevice(AudioDeviceNames* device_names) { DCHECK(device_names->empty()); - device_names->push_front(AudioDeviceName(AudioManager::GetDefaultDeviceName(), - AudioManagerBase::kDefaultDeviceId)); + device_names->push_front( + AudioDeviceName(AudioManagerBase::kDefaultDeviceName, + AudioManagerBase::kDefaultDeviceId)); } // Maximum number of output streams that can be open simultaneously. -const int kMaxOutputStreams = 10; +static const int kMaxOutputStreams = 10; -const int kDefaultInputBufferSize = 1024; -const int kDefaultOutputBufferSize = 2048; - -} // namespace +static const int kDefaultInputBufferSize = 1024; +static const int kDefaultOutputBufferSize = 2048; AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { return new AudioManagerAndroid(audio_log_factory); diff --git a/media/audio/audio_manager.cc b/media/audio/audio_manager.cc index ebdfc4e..f39b82b 100644 --- a/media/audio/audio_manager.cc +++ b/media/audio/audio_manager.cc @@ -15,7 +15,6 @@ #include "build/build_config.h" #include "media/audio/audio_manager_factory.h" #include "media/audio/fake_audio_log_factory.h" -#include "media/base/media_resources.h" #include "media/base/media_switches.h" #if defined(OS_WIN) @@ -284,19 +283,4 @@ AudioManager* AudioManager::Get() { return g_last_created; } -// static -std::string AudioManager::GetDefaultDeviceName() { - return GetLocalizedStringUTF8(DEFAULT_AUDIO_DEVICE_NAME); -} - -// static -std::string AudioManager::GetCommunicationsDeviceName() { -#if defined(OS_WIN) - return GetLocalizedStringUTF8(COMMUNICATIONS_AUDIO_DEVICE_NAME); -#else - NOTREACHED(); - return ""; -#endif -} - } // namespace media diff --git a/media/audio/audio_manager.h b/media/audio/audio_manager.h index 4da250d..3739973 100644 --- a/media/audio/audio_manager.h +++ b/media/audio/audio_manager.h @@ -79,13 +79,6 @@ class MEDIA_EXPORT AudioManager { // like src/chrome. static AudioManager* Get(); - // Returns the localized name of the generic "default" device. - static std::string GetDefaultDeviceName(); - - // Returns the localized name of the generic default communications device. - // This device is not supported on all platforms. - static std::string GetCommunicationsDeviceName(); - // Returns true if the OS reports existence of audio devices. This does not // guarantee that the existing devices support all formats and sample rates. virtual bool HasAudioOutputDevices() = 0; diff --git a/media/audio/audio_manager_base.cc b/media/audio/audio_manager_base.cc index 8c1dda2..43568cf 100644 --- a/media/audio/audio_manager_base.cc +++ b/media/audio/audio_manager_base.cc @@ -19,24 +19,23 @@ #include "media/base/media_switches.h" namespace media { -namespace { -const int kStreamCloseDelaySeconds = 5; +static const int kStreamCloseDelaySeconds = 5; // Default maximum number of output streams that can be open simultaneously // for all platforms. -const int kDefaultMaxOutputStreams = 16; +static const int kDefaultMaxOutputStreams = 16; // Default maximum number of input streams that can be open simultaneously // for all platforms. -const int kDefaultMaxInputStreams = 16; +static const int kDefaultMaxInputStreams = 16; -const int kMaxInputChannels = 3; - -} // namespace +static const int kMaxInputChannels = 3; +const char AudioManagerBase::kDefaultDeviceName[] = "Default"; const char AudioManagerBase::kDefaultDeviceId[] = "default"; const char AudioManagerBase::kCommunicationsDeviceId[] = "communications"; +const char AudioManagerBase::kCommunicationsDeviceName[] = "Communications"; const char AudioManagerBase::kLoopbackInputDeviceId[] = "loopback"; struct AudioManagerBase::DispatcherParams { diff --git a/media/audio/audio_manager_base.h b/media/audio/audio_manager_base.h index cd94713..346fe47 100644 --- a/media/audio/audio_manager_base.h +++ b/media/audio/audio_manager_base.h @@ -28,14 +28,17 @@ class AudioOutputDispatcher; // AudioManagerBase provides AudioManager functions common for all platforms. class MEDIA_EXPORT AudioManagerBase : public AudioManager { public: - // TODO(ajm): Move these strings to AudioManager. - // Unique Id of the generic "default" device. Associated with the localized - // name returned from GetDefaultDeviceName(). - static const char kDefaultDeviceId[]; + // TODO(sergeyu): The constants below belong to AudioManager interface, not + // to the base implementation. - // Unique Id of the generic default communications device. Associated with - // the localized name returned from GetCommunicationsDeviceName(). + // Name of the generic "default" device. + static const char kDefaultDeviceName[]; + // Unique Id of the generic "default" device. + static const char kDefaultDeviceId[]; + // Unique Id of the generic default communications device (where supported). static const char kCommunicationsDeviceId[]; + // Name of the generic default communications device (where supported). + static const char kCommunicationsDeviceName[]; // Input device ID used to capture the default system playback stream. When // this device ID is passed to MakeAudioInputStream() the returned diff --git a/media/audio/audio_manager_unittest.cc b/media/audio/audio_manager_unittest.cc index 9fb0182..48bb51c 100644 --- a/media/audio/audio_manager_unittest.cc +++ b/media/audio/audio_manager_unittest.cc @@ -81,7 +81,8 @@ class AudioManagerTest : public ::testing::Test { AudioDeviceNames::const_iterator it = device_names.begin(); // The first device in the list should always be the default device. - EXPECT_EQ(AudioManager::GetDefaultDeviceName(), it->device_name); + EXPECT_EQ(std::string(AudioManagerBase::kDefaultDeviceName), + it->device_name); EXPECT_EQ(std::string(AudioManagerBase::kDefaultDeviceId), it->unique_id); ++it; @@ -92,7 +93,8 @@ class AudioManagerTest : public ::testing::Test { EXPECT_FALSE(it->unique_id.empty()); DVLOG(2) << "Device ID(" << it->unique_id << "), label: " << it->device_name; - EXPECT_NE(AudioManager::GetDefaultDeviceName(), it->device_name); + EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceName), + it->device_name); EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceId), it->unique_id); ++it; diff --git a/media/audio/audio_output_controller_unittest.cc b/media/audio/audio_output_controller_unittest.cc index dd7cb80..3e9229d 100644 --- a/media/audio/audio_output_controller_unittest.cc +++ b/media/audio/audio_output_controller_unittest.cc @@ -217,7 +217,7 @@ class AudioOutputControllerTest : public testing::Test { .WillOnce(SignalEvent(&play_event_)); } - controller_->SwitchOutputDevice(AudioManager::GetDefaultDeviceName(), + controller_->SwitchOutputDevice(AudioManagerBase::kDefaultDeviceName, base::Bind(&base::DoNothing)); } diff --git a/media/audio/cras/audio_manager_cras.cc b/media/audio/cras/audio_manager_cras.cc index fc58004..2b47de4 100644 --- a/media/audio/cras/audio_manager_cras.cc +++ b/media/audio/cras/audio_manager_cras.cc @@ -16,7 +16,6 @@ #include "media/audio/cras/cras_input.h" #include "media/audio/cras/cras_unified.h" #include "media/base/channel_layout.h" -#include "media/base/media_resources.h" // cras_util.h headers pull in min/max macros... // TODO(dgreid): Fix headers such that these aren't imported. @@ -39,27 +38,32 @@ const int kMaximumOutputBufferSize = 8192; // Default input buffer size. const int kDefaultInputBufferSize = 1024; -const char kBeamformingOnUniqueId[] = "beamforming-on"; -const char kBeamformingOffUniqueId[] = "beamforming-off"; - void AddDefaultDevice(AudioDeviceNames* device_names) { - DCHECK(device_names->empty()); - // Cras will route audio from a proper physical device automatically. - device_names->push_back(AudioDeviceName(AudioManager::GetDefaultDeviceName(), - AudioManagerBase::kDefaultDeviceId)); + device_names->push_back( + AudioDeviceName(AudioManagerBase::kDefaultDeviceName, + AudioManagerBase::kDefaultDeviceId)); } -// Adds the beamforming on and off devices to |device_names|. -void AddBeamformingDevices(AudioDeviceNames* device_names) { - DCHECK(device_names->empty()); +// Returns the AudioDeviceName of the virtual device with beamforming on. +AudioDeviceName BeamformingOnDeviceName() { + // TODO(ajm): Replace these strings with properly localized ones. + // (crbug.com/497001) + static const char kBeamformingOnNameSuffix[] = " (pick up just one person)"; + static const char kBeamformingOnIdSuffix[] = "-beamforming"; - device_names->push_back(AudioDeviceName( - GetLocalizedStringUTF8(BEAMFORMING_ON_DEFAULT_AUDIO_INPUT_DEVICE_NAME), - kBeamformingOnUniqueId)); - device_names->push_back(AudioDeviceName( - GetLocalizedStringUTF8(BEAMFORMING_OFF_DEFAULT_AUDIO_INPUT_DEVICE_NAME), - kBeamformingOffUniqueId)); + return AudioDeviceName( + std::string(AudioManagerBase::kDefaultDeviceName) + + kBeamformingOnNameSuffix, + std::string(AudioManagerBase::kDefaultDeviceId) + kBeamformingOnIdSuffix); +} + +// Returns the AudioDeviceName of the virtual device with beamforming off. +AudioDeviceName BeamformingOffDeviceName() { + static const char kBeamformingOffNameSuffix[] = " (pick up everything)"; + return AudioDeviceName(std::string(AudioManagerBase::kDefaultDeviceName) + + kBeamformingOffNameSuffix, + AudioManagerBase::kDefaultDeviceId); } // Returns a mic positions string if the machine has a beamforming capable @@ -95,7 +99,10 @@ bool AudioManagerCras::HasAudioInputDevices() { } AudioManagerCras::AudioManagerCras(AudioLogFactory* audio_log_factory) - : AudioManagerBase(audio_log_factory), has_keyboard_mic_(false) { + : AudioManagerBase(audio_log_factory), + has_keyboard_mic_(false), + beamforming_on_device_name_(BeamformingOnDeviceName()), + beamforming_off_device_name_(BeamformingOffDeviceName()) { SetMaxOutputStreamsAllowed(kMaxOutputStreams); } @@ -115,14 +122,18 @@ void AudioManagerCras::GetAudioInputDeviceNames( // At least two mic positions indicates we have a beamforming capable mic // array. Add the virtual beamforming device to the list. When this device is // queried through GetInputStreamParameters, provide the cached mic positions. - if (mic_positions_.size() > 1) - AddBeamformingDevices(device_names); - else + if (mic_positions_.size() > 1) { + device_names->push_back(beamforming_on_device_name_); + device_names->push_back(beamforming_off_device_name_); + } else { AddDefaultDevice(device_names); + } } void AudioManagerCras::GetAudioOutputDeviceNames( AudioDeviceNames* device_names) { + DCHECK(device_names->empty()); + AddDefaultDevice(device_names); } @@ -141,7 +152,7 @@ AudioParameters AudioManagerCras::GetInputStreamParameters( buffer_size); if (has_keyboard_mic_) params.set_effects(AudioParameters::KEYBOARD_MIC); - if (device_id == kBeamformingOnUniqueId) + if (device_id == beamforming_on_device_name_.unique_id) params.set_mic_positions(mic_positions_); return params; } diff --git a/media/audio/cras/audio_manager_cras.h b/media/audio/cras/audio_manager_cras.h index 275f5c2..d55756d 100644 --- a/media/audio/cras/audio_manager_cras.h +++ b/media/audio/cras/audio_manager_cras.h @@ -61,6 +61,10 @@ class MEDIA_EXPORT AudioManagerCras : public AudioManagerBase { bool has_keyboard_mic_; + // Holds the name and ID of the virtual beamforming devices. + const AudioDeviceName beamforming_on_device_name_; + const AudioDeviceName beamforming_off_device_name_; + // Stores the mic positions field from the device. std::vector<Point> mic_positions_; diff --git a/media/audio/mac/audio_manager_mac.cc b/media/audio/mac/audio_manager_mac.cc index f2f73da..33dbfdf 100644 --- a/media/audio/mac/audio_manager_mac.cc +++ b/media/audio/mac/audio_manager_mac.cc @@ -152,7 +152,7 @@ static void GetAudioDeviceInfo(bool is_input, // on the top of the list for all platforms. There is no duplicate // counting here since the default device has been abstracted out before. media::AudioDeviceName name; - name.device_name = AudioManager::GetDefaultDeviceName(); + name.device_name = AudioManagerBase::kDefaultDeviceName; name.unique_id = AudioManagerBase::kDefaultDeviceId; device_names->push_front(name); } diff --git a/media/audio/pulse/audio_manager_pulse.cc b/media/audio/pulse/audio_manager_pulse.cc index 50a322f..f3d8832 100644 --- a/media/audio/pulse/audio_manager_pulse.cc +++ b/media/audio/pulse/audio_manager_pulse.cc @@ -113,7 +113,7 @@ void AudioManagerPulse::GetAudioDeviceNames( // Prepend the default device if the list is not empty. if (!device_names->empty()) { device_names->push_front( - AudioDeviceName(AudioManager::GetDefaultDeviceName(), + AudioDeviceName(AudioManagerBase::kDefaultDeviceName, AudioManagerBase::kDefaultDeviceId)); } } diff --git a/media/audio/win/audio_manager_win.cc b/media/audio/win/audio_manager_win.cc index 70e6c1b..7ef9a84 100644 --- a/media/audio/win/audio_manager_win.cc +++ b/media/audio/win/audio_manager_win.cc @@ -286,12 +286,12 @@ void AudioManagerWin::GetAudioDeviceNamesImpl( if (!device_names->empty()) { AudioDeviceName name; if (enumeration_type() == kMMDeviceEnumeration) { - name.device_name = AudioManager::GetCommunicationsDeviceName(); + name.device_name = AudioManagerBase::kCommunicationsDeviceName; name.unique_id = AudioManagerBase::kCommunicationsDeviceId; device_names->push_front(name); } // Always add default device parameters as first element. - name.device_name = AudioManager::GetDefaultDeviceName(); + name.device_name = AudioManagerBase::kDefaultDeviceName; name.unique_id = AudioManagerBase::kDefaultDeviceId; device_names->push_front(name); } diff --git a/media/base/BUILD.gn b/media/base/BUILD.gn index 3565553..40641c4 100644 --- a/media/base/BUILD.gn +++ b/media/base/BUILD.gn @@ -118,8 +118,6 @@ source_set("base") { "media_log_event.h", "media_permission.cc", "media_permission.h", - "media_resources.cc", - "media_resources.h", "media_switches.cc", "media_switches.h", "mime_util.cc", @@ -338,8 +336,6 @@ source_set("test_support") { "fake_audio_renderer_sink.h", "fake_demuxer_stream.cc", "fake_demuxer_stream.h", - "fake_media_resources.cc", - "fake_media_resources.h", "fake_output_device.cc", "fake_output_device.h", "fake_text_track_stream.cc", diff --git a/media/base/fake_media_resources.cc b/media/base/fake_media_resources.cc deleted file mode 100644 index 5e3a9bb9..0000000 --- a/media/base/fake_media_resources.cc +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/strings/utf_string_conversions.h" -#include "media/base/media_resources.h" - -namespace media { - -base::string16 FakeLocalizedStringProvider(MessageId message_id) { - return base::ASCIIToUTF16("FakeString"); -} - -void SetUpFakeMediaResources() { - SetLocalizedStringProvider(FakeLocalizedStringProvider); -} - -} // namespace media diff --git a/media/base/fake_media_resources.h b/media/base/fake_media_resources.h deleted file mode 100644 index 9a374bf..0000000 --- a/media/base/fake_media_resources.h +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef MEDIA_BASE_FAKE_MEDIA_RESOURCES_H_ -#define MEDIA_BASE_FAKE_MEDIA_RESOURCES_H_ - -namespace media { - -// Call if tests require non-empty resource strings. -void SetUpFakeMediaResources(); - -} // namespace media - -#endif // MEDIA_BASE_FAKE_MEDIA_RESOURCES_H_ diff --git a/media/base/media_resources.cc b/media/base/media_resources.cc deleted file mode 100644 index b4ff3c8..0000000 --- a/media/base/media_resources.cc +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "media/base/media_resources.h" - -#include "base/logging.h" -#include "base/strings/utf_string_conversions.h" - -namespace media { - -static LocalizedStringProvider g_localized_string_provider = nullptr; - -void SetLocalizedStringProvider(LocalizedStringProvider func) { - g_localized_string_provider = func; -} - -std::string GetLocalizedStringUTF8(MessageId message_id) { - return base::UTF16ToUTF8(GetLocalizedStringUTF16(message_id)); -} - -base::string16 GetLocalizedStringUTF16(MessageId message_id) { - return g_localized_string_provider ? g_localized_string_provider(message_id) - : base::string16(); -} - -} // namespace media diff --git a/media/base/media_resources.h b/media/base/media_resources.h deleted file mode 100644 index 53b638d..0000000 --- a/media/base/media_resources.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef MEDIA_BASE_MEDIA_RESOURCES_H_ -#define MEDIA_BASE_MEDIA_RESOURCES_H_ - -#include <string> - -#include "base/strings/string16.h" -#include "media/base/media_export.h" - -namespace media { - -// The media layer can't access Chrome's resource bundle directly. This facility -// allows clients to provide indirect access. - -// IDs that will get mapped to corresponding entries with IDS_ prefixes in -// chrome/app/generated_resources.grd. -enum MessageId { - DEFAULT_AUDIO_DEVICE_NAME, -#if defined(OS_WIN) - COMMUNICATIONS_AUDIO_DEVICE_NAME, -#endif -#if defined(OS_CHROMEOS) - BEAMFORMING_ON_DEFAULT_AUDIO_INPUT_DEVICE_NAME, - BEAMFORMING_OFF_DEFAULT_AUDIO_INPUT_DEVICE_NAME, -#endif -}; - -// Implementations are expected to convert MessageIds to generated_resources.grd -// IDs and extract the matching string from Chrome's resource bundle (e.g. -// through l10n_util::GetStringUTF16). -using LocalizedStringProvider = base::string16 (*)(MessageId message_id); - -// Initializes the global LocalizedStringProvider function. -MEDIA_EXPORT void SetLocalizedStringProvider(LocalizedStringProvider func); - -// Returns a resource string corresponding to |message_id|. See l10n_util.h. -// Returns an empty string if the LocalizedStringProvider has not been -// initialized or if the ID is unrecognized. -std::string GetLocalizedStringUTF8(MessageId message_id); -base::string16 GetLocalizedStringUTF16(MessageId message_id); - -} // namespace media - -#endif // MEDIA_BASE_MEDIA_RESOURCES_H_ diff --git a/media/base/run_all_unittests.cc b/media/base/run_all_unittests.cc index 97e799b..dfde2b5 100644 --- a/media/base/run_all_unittests.cc +++ b/media/base/run_all_unittests.cc @@ -8,7 +8,6 @@ #include "base/test/test_discardable_memory_allocator.h" #include "base/test/test_suite.h" #include "build/build_config.h" -#include "media/base/fake_media_resources.h" #include "media/base/media.h" #include "media/base/media_switches.h" @@ -48,7 +47,6 @@ void TestSuiteNoAtExit::Initialize() { // Run this here instead of main() to ensure an AtExitManager is already // present. media::InitializeMediaLibrary(); - media::SetUpFakeMediaResources(); base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_); } diff --git a/media/cast/cast_testing.gypi b/media/cast/cast_testing.gypi index d45bd82..9e439e0 100644 --- a/media/cast/cast_testing.gypi +++ b/media/cast/cast_testing.gypi @@ -68,7 +68,6 @@ # the tools compile correctly. 'cast_tools', '<(DEPTH)/base/base.gyp:test_support_base', - '<(DEPTH)/media/media.gyp:media_test_support', '<(DEPTH)/net/net.gyp:net', '<(DEPTH)/testing/gmock.gyp:gmock', '<(DEPTH)/testing/gtest.gyp:gtest', diff --git a/media/media.gyp b/media/media.gyp index 4817e428..804024c 100644 --- a/media/media.gyp +++ b/media/media.gyp @@ -60,7 +60,6 @@ '../skia/skia.gyp:skia', '../third_party/libyuv/libyuv.gyp:libyuv', '../third_party/opus/opus.gyp:opus', - '../ui/base/ui_base.gyp:ui_base', '../ui/events/events.gyp:events_base', '../ui/gfx/gfx.gyp:gfx', '../ui/gfx/gfx.gyp:gfx_geometry', @@ -325,8 +324,6 @@ 'base/media_log_event.h', 'base/media_permission.cc', 'base/media_permission.h', - 'base/media_resources.cc', - 'base/media_resources.h', 'base/media_switches.cc', 'base/media_switches.h', 'base/mime_util.cc', @@ -1616,8 +1613,6 @@ 'base/fake_audio_renderer_sink.h', 'base/fake_demuxer_stream.cc', 'base/fake_demuxer_stream.h', - 'base/fake_media_resources.cc', - 'base/fake_media_resources.h', 'base/fake_output_device.cc', 'base/fake_output_device.h', 'base/fake_text_track_stream.cc', |