summaryrefslogtreecommitdiffstats
path: root/media/audio/android
diff options
context:
space:
mode:
authorajm <ajm@chromium.org>2015-09-21 17:04:08 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-22 00:04:52 +0000
commit943e1b33dac970c6a970d085b66c5c526d6b9870 (patch)
tree67423d0ed60e3ba1de207be3a3734dbdb74f9639 /media/audio/android
parent9b954862a514954eee708cb8e172905002324a0b (diff)
downloadchromium_src-943e1b33dac970c6a970d085b66c5c526d6b9870.zip
chromium_src-943e1b33dac970c6a970d085b66c5c526d6b9870.tar.gz
chromium_src-943e1b33dac970c6a970d085b66c5c526d6b9870.tar.bz2
Add localized default audio device names.
Add localized strings for the default audio device, the communications device on Windows and the beamforming virtual input devices on ChromeOS. Since the media layer can't access Chrome's resource bundle directly, this adds an indirect mechanism modeled on net/base/net_module.h. BUG=497001 TEST=The correct "Default" name appears on Linux in Chrome settings. On a Swanky (which has beamforming support), the correct virtual device names appear in both Chrome settings and the Hangouts settings dialog. Review URL: https://codereview.chromium.org/1339183002 Cr-Commit-Position: refs/heads/master@{#350070}
Diffstat (limited to 'media/audio/android')
-rw-r--r--media/audio/android/audio_android_unittest.cc36
-rw-r--r--media/audio/android/audio_manager_android.cc16
2 files changed, 27 insertions, 25 deletions
diff --git a/media/audio/android/audio_android_unittest.cc b/media/audio/android/audio_android_unittest.cc
index 38269bc..a6f9421 100644
--- a/media/audio/android/audio_android_unittest.cc
+++ b/media/audio/android/audio_android_unittest.cc
@@ -35,6 +35,7 @@ using ::testing::NotNull;
using ::testing::Return;
namespace media {
+namespace {
ACTION_P3(CheckCountAndPostQuitTask, count, limit, loop) {
if (++*count >= limit) {
@@ -42,17 +43,17 @@ ACTION_P3(CheckCountAndPostQuitTask, count, limit, loop) {
}
}
-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 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 float kCallbackTestTimeMs = 2000.0;
-static const int kBitsPerSample = 16;
-static const int kBytesPerSample = kBitsPerSample / 8;
+const float kCallbackTestTimeMs = 2000.0;
+const int kBitsPerSample = 16;
+const int kBytesPerSample = kBitsPerSample / 8;
// Converts AudioParameters::Format enumerator to readable string.
-static std::string FormatToString(AudioParameters::Format format) {
+std::string FormatToString(AudioParameters::Format format) {
switch (format) {
case AudioParameters::AUDIO_PCM_LINEAR:
return std::string("AUDIO_PCM_LINEAR");
@@ -67,7 +68,7 @@ static 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.
-static std::string LayoutToString(ChannelLayout channel_layout) {
+std::string LayoutToString(ChannelLayout channel_layout) {
switch (channel_layout) {
case CHANNEL_LAYOUT_NONE:
return std::string("CHANNEL_LAYOUT_NONE");
@@ -81,7 +82,7 @@ static std::string LayoutToString(ChannelLayout channel_layout) {
}
}
-static double ExpectedTimeBetweenCallbacks(AudioParameters params) {
+double ExpectedTimeBetweenCallbacks(AudioParameters params) {
return (base::TimeDelta::FromMicroseconds(
params.frames_per_buffer() * base::Time::kMicrosecondsPerSecond /
static_cast<double>(params.sample_rate()))).InMillisecondsF();
@@ -89,7 +90,7 @@ static 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.
-static void CheckDeviceNames(const AudioDeviceNames& device_names) {
+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
@@ -102,8 +103,7 @@ static 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(std::string(AudioManagerBase::kDefaultDeviceName),
- it->device_name);
+ EXPECT_EQ(AudioManager::GetDefaultDeviceName(), it->device_name);
EXPECT_EQ(std::string(AudioManagerBase::kDefaultDeviceId), it->unique_id);
++it;
@@ -114,20 +114,20 @@ static 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(std::string(AudioManagerBase::kDefaultDeviceName),
- it->device_name);
- EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceId),
- it->unique_id);
+ EXPECT_NE(AudioManager::GetDefaultDeviceName(), 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.
-static int RealOnMoreData(AudioBus* dest, uint32 total_bytes_delay) {
+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 e231cd1..01379b8 100644
--- a/media/audio/android/audio_manager_android.cc
+++ b/media/audio/android/audio_manager_android.cc
@@ -28,19 +28,21 @@ using base::android::ConvertUTF8ToJavaString;
using base::android::ScopedJavaLocalRef;
namespace media {
+namespace {
-static void AddDefaultDevice(AudioDeviceNames* device_names) {
+void AddDefaultDevice(AudioDeviceNames* device_names) {
DCHECK(device_names->empty());
- device_names->push_front(
- AudioDeviceName(AudioManagerBase::kDefaultDeviceName,
- AudioManagerBase::kDefaultDeviceId));
+ device_names->push_front(AudioDeviceName(AudioManager::GetDefaultDeviceName(),
+ AudioManagerBase::kDefaultDeviceId));
}
// Maximum number of output streams that can be open simultaneously.
-static const int kMaxOutputStreams = 10;
+const int kMaxOutputStreams = 10;
-static const int kDefaultInputBufferSize = 1024;
-static const int kDefaultOutputBufferSize = 2048;
+const int kDefaultInputBufferSize = 1024;
+const int kDefaultOutputBufferSize = 2048;
+
+} // namespace
AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) {
return new AudioManagerAndroid(audio_log_factory);