diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-07 15:26:05 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-07 15:26:05 +0000 |
commit | 2770c95a50db703c322d65d286aa5771e58ac25a (patch) | |
tree | 595b2adf92be75f65eccbbb0760e3969d2d840c3 /media | |
parent | eac3ba4f0f315bb2c68289062cb9f4f5ec632f90 (diff) | |
download | chromium_src-2770c95a50db703c322d65d286aa5771e58ac25a.zip chromium_src-2770c95a50db703c322d65d286aa5771e58ac25a.tar.gz chromium_src-2770c95a50db703c322d65d286aa5771e58ac25a.tar.bz2 |
Cleaning up src/media to be consistent with static versus anonymous namespaces.
We were using a mix of both (and sometimes even static functions *inside* anonymous namespaces!) so we decided to stick to using static.
Also moved static/test code into media namespace and removed media:: prefixes.
BUG=none
TEST=compiles
Review URL: http://codereview.chromium.org/6628020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77135 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
37 files changed, 222 insertions, 377 deletions
diff --git a/media/audio/audio_input_controller.cc b/media/audio/audio_input_controller.cc index 1e23f53..3d58a50 100644 --- a/media/audio/audio_input_controller.cc +++ b/media/audio/audio_input_controller.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -7,14 +7,10 @@ #include "base/threading/thread_restrictions.h" #include "media/base/limits.h" -namespace { - -const int kMaxInputChannels = 2; - -} // namespace - namespace media { +static const int kMaxInputChannels = 2; + // static AudioInputController::Factory* AudioInputController::factory_ = NULL; diff --git a/media/audio/audio_input_controller_unittest.cc b/media/audio/audio_input_controller_unittest.cc index b6efe96..5ebf088 100644 --- a/media/audio/audio_input_controller_unittest.cc +++ b/media/audio/audio_input_controller_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -14,12 +14,12 @@ using ::testing::Exactly; using ::testing::InvokeWithoutArgs; using ::testing::NotNull; -namespace { +namespace media { -const int kSampleRate = AudioParameters::kAudioCDSampleRate; -const int kBitsPerSample = 16; -const int kChannels = 2; -const int kSamplesPerPacket = kSampleRate / 10; +static const int kSampleRate = AudioParameters::kAudioCDSampleRate; +static const int kBitsPerSample = 16; +static const int kChannels = 2; +static const int kSamplesPerPacket = kSampleRate / 10; ACTION_P3(CheckCountAndSignalEvent, count, limit, event) { if (++*count >= limit) { @@ -27,11 +27,6 @@ ACTION_P3(CheckCountAndSignalEvent, count, limit, event) { } } -// Test AudioInputController for create and close without recording audio. -} - -namespace media { - class MockAudioInputControllerEventHandler : public AudioInputController::EventHandler { public: @@ -47,6 +42,7 @@ class MockAudioInputControllerEventHandler DISALLOW_COPY_AND_ASSIGN(MockAudioInputControllerEventHandler); }; +// Test AudioInputController for create and close without recording audio. TEST(AudioInputControllerTest, CreateAndClose) { MockAudioInputControllerEventHandler event_handler; base::WaitableEvent event(false, false); diff --git a/media/audio/audio_input_unittest.cc b/media/audio/audio_input_unittest.cc index 5ab4a62..99aac8d 100644 --- a/media/audio/audio_input_unittest.cc +++ b/media/audio/audio_input_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -11,10 +11,8 @@ #include "media/audio/audio_manager.h" #include "testing/gtest/include/gtest/gtest.h" -namespace { - -const int kSamplingRate = 8000; -const int kSamplesPerPacket = kSamplingRate / 20; +static const int kSamplingRate = 8000; +static const int kSamplesPerPacket = kSamplingRate / 20; // This class allows to find out if the callbacks are occurring as // expected and if any error has been reported. @@ -89,7 +87,7 @@ class TestInputCallbackBlocking : public TestInputCallback { int block_for_ms_; }; -bool CanRunAudioTests() { +static bool CanRunAudioTests() { scoped_ptr<base::Environment> env(base::Environment::Create()); if (env->HasVar("CHROME_HEADLESS")) return false; @@ -101,7 +99,7 @@ bool CanRunAudioTests() { return audio_man->HasAudioInputDevices(); } -AudioInputStream* CreateTestAudioInputStream() { +static AudioInputStream* CreateTestAudioInputStream() { AudioManager* audio_man = AudioManager::GetAudioManager(); AudioInputStream* ais = audio_man->MakeAudioInputStream( AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 2, kSamplingRate, @@ -110,8 +108,6 @@ AudioInputStream* CreateTestAudioInputStream() { return ais; } -} // namespace. - // Test that AudioInputStream rejects out of range parameters. TEST(AudioInputTest, SanityOnMakeParams) { if (!CanRunAudioTests()) diff --git a/media/audio/audio_manager.cc b/media/audio/audio_manager.cc index 5d1b195..4cdcbf3 100644 --- a/media/audio/audio_manager.cc +++ b/media/audio/audio_manager.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -7,12 +7,8 @@ #include "base/at_exit.h" #include "base/logging.h" -namespace { - -bool g_destroy_called = false; -AudioManager* g_audio_manager = NULL; - -} // namespace +static bool g_destroy_called = false; +static AudioManager* g_audio_manager = NULL; // static void AudioManager::Destroy(void* not_used) { diff --git a/media/audio/audio_manager_base.cc b/media/audio/audio_manager_base.cc index 024aff3..6aa67f21 100644 --- a/media/audio/audio_manager_base.cc +++ b/media/audio/audio_manager_base.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -6,9 +6,7 @@ #include "media/audio/audio_output_dispatcher.h" #include "media/audio/audio_output_proxy.h" -namespace { -const int kStreamCloseDelayMs = 5000; -} // namespace +static const int kStreamCloseDelayMs = 5000; AudioManagerBase::AudioManagerBase() : audio_thread_("AudioThread"), diff --git a/media/audio/audio_output_controller.cc b/media/audio/audio_output_controller.cc index 5347c50..10217f8 100644 --- a/media/audio/audio_output_controller.cc +++ b/media/audio/audio_output_controller.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -6,22 +6,11 @@ #include "base/message_loop.h" +namespace media { + // Signal a pause in low-latency mode. static const int kPauseMark = -1; -namespace { -// Return true if the parameters for creating an audio stream is valid. -// Return false otherwise. -static bool CheckParameters(AudioParameters params) { - if (!params.IsValid()) - return false; - return true; -} - -} // namespace - -namespace media { - AudioOutputController::AudioOutputController(EventHandler* handler, uint32 capacity, SyncReader* sync_reader) @@ -45,7 +34,7 @@ scoped_refptr<AudioOutputController> AudioOutputController::Create( AudioParameters params, uint32 buffer_capacity) { - if (!CheckParameters(params)) + if (!params.IsValid()) return NULL; if (!AudioManager::GetAudioManager()) @@ -72,7 +61,7 @@ scoped_refptr<AudioOutputController> AudioOutputController::CreateLowLatency( DCHECK(sync_reader); - if (!CheckParameters(params)) + if (!params.IsValid()) return NULL; if (!AudioManager::GetAudioManager()) diff --git a/media/audio/audio_output_proxy_unittest.cc b/media/audio/audio_output_proxy_unittest.cc index 8ffb70b..be11728 100644 --- a/media/audio/audio_output_proxy_unittest.cc +++ b/media/audio/audio_output_proxy_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -14,12 +14,10 @@ using ::testing::_; using ::testing::Mock; using ::testing::Return; -namespace { -const int kTestCloseDelayMs = 100; +static const int kTestCloseDelayMs = 100; // Used in the test where we don't want a stream to be closed unexpectedly. -const int kTestBigCloseDelayMs = 1000 * 1000; -} // namespace +static const int kTestBigCloseDelayMs = 1000 * 1000; class MockAudioOutputStream : public AudioOutputStream { public: diff --git a/media/audio/audio_util.cc b/media/audio/audio_util.cc index ed84bc1..277bb1a 100644 --- a/media/audio/audio_util.cc +++ b/media/audio/audio_util.cc @@ -14,19 +14,16 @@ namespace media { -namespace { - // TODO(fbarchard): Convert to intrinsics for better efficiency. - template<class Fixed> static int ScaleChannel(int channel, int volume) { return static_cast<int>((static_cast<Fixed>(channel) * volume) >> 16); } template<class Format, class Fixed, int bias> -void AdjustVolume(Format* buf_out, - int sample_count, - int fixed_volume) { +static void AdjustVolume(Format* buf_out, + int sample_count, + int fixed_volume) { for (int i = 0; i < sample_count; ++i) { buf_out[i] = static_cast<Format>(ScaleChannel<Fixed>(buf_out[i] - bias, fixed_volume) + bias); @@ -38,8 +35,7 @@ static const int kChannel_R = 1; static const int kChannel_C = 2; template<class Fixed, int min_value, int max_value> -static int AddChannel(int val, - int adder) { +static int AddChannel(int val, int adder) { Fixed sum = static_cast<Fixed>(val) + static_cast<Fixed>(adder); if (sum > max_value) return max_value; @@ -56,7 +52,6 @@ static int AddChannel(int val, // bits of integer are used. // 8 bit samples are unsigned and 128 represents 0, so a bias is removed before // doing calculations, then readded for the final output. - template<class Format, class Fixed, int min_value, int max_value, int bias> static void FoldChannels(Format* buf_out, int sample_count, @@ -84,7 +79,6 @@ static void FoldChannels(Format* buf_out, buf_in += channels; } } -} // namespace // AdjustVolume() does an in place audio sample change. bool AdjustVolume(void* buf, diff --git a/media/audio/fake_audio_input_stream_unittest.cc b/media/audio/fake_audio_input_stream_unittest.cc index 107115b..ff3b6f5 100644 --- a/media/audio/fake_audio_input_stream_unittest.cc +++ b/media/audio/fake_audio_input_stream_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -14,8 +14,6 @@ using ::testing::AtLeast; using ::testing::Exactly; using ::testing::NotNull; -namespace { - class MockAudioInputCallback : public AudioInputStream::AudioInputCallback { public: MockAudioInputCallback() {} @@ -28,8 +26,6 @@ class MockAudioInputCallback : public AudioInputStream::AudioInputCallback { DISALLOW_COPY_AND_ASSIGN(MockAudioInputCallback); }; -} - // ============================================================================ // Validate that the AudioManager::AUDIO_MOCK callbacks work. // Crashes, http://crbug.com/49497. diff --git a/media/audio/linux/alsa_input.cc b/media/audio/linux/alsa_input.cc index afc37d6..02b6fd3 100644 --- a/media/audio/linux/alsa_input.cc +++ b/media/audio/linux/alsa_input.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -11,17 +11,13 @@ #include "media/audio/linux/alsa_util.h" #include "media/audio/linux/alsa_wrapper.h" -namespace { - -const int kNumPacketsInRingBuffer = 3; +static const int kNumPacketsInRingBuffer = 3; // If a read failed with no audio data, try again after this duration. -const int kNoAudioReadAgainTimeoutMs = 20; - -const char kDefaultDevice1[] = "default"; -const char kDefaultDevice2[] = "plug:default"; +static const int kNoAudioReadAgainTimeoutMs = 20; -} // namespace +static const char kDefaultDevice1[] = "default"; +static const char kDefaultDevice2[] = "plug:default"; const char* AlsaPcmInputStream::kAutoSelectDevice = ""; diff --git a/media/audio/linux/alsa_output.cc b/media/audio/linux/alsa_output.cc index 338ff08..d8e502c 100644 --- a/media/audio/linux/alsa_output.cc +++ b/media/audio/linux/alsa_output.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. // @@ -105,20 +105,9 @@ static const int kPcmRecoverIsSilent = 1; static const int kPcmRecoverIsSilent = 0; #endif -const char AlsaPcmOutputStream::kDefaultDevice[] = "default"; -const char AlsaPcmOutputStream::kAutoSelectDevice[] = ""; -const char AlsaPcmOutputStream::kPlugPrefix[] = "plug:"; - -// Since we expect to only be able to wake up with a resolution of -// kSleepErrorMilliseconds, double that for our minimum required latency. -const uint32 AlsaPcmOutputStream::kMinLatencyMicros = - kSleepErrorMilliseconds * 2 * 1000; - -namespace { - // ALSA is currently limited to 48Khz. // TODO(fbarchard): Resample audio from higher frequency to 48000. -const int kAlsaMaxSampleRate = 48000; +static const int kAlsaMaxSampleRate = 48000; // While the "default" device may support multi-channel audio, in Alsa, only // the device names surround40, surround41, surround50, etc, have a defined @@ -137,7 +126,7 @@ const int kAlsaMaxSampleRate = 48000; // TODO(ajwong): The source data should have enough info to tell us if we want // surround41 versus surround51, etc., instead of needing us to guess base don // channel number. Fix API to pass that data down. -const char* GuessSpecificDeviceName(uint32 channels) { +static const char* GuessSpecificDeviceName(uint32 channels) { switch (channels) { case 8: return "surround71"; @@ -190,10 +179,6 @@ static void Swizzle51Layout(Format* b, uint32 filled) { } } -} // namespace - -// Not in an anonymous namespace so that it can be a friend to -// AlsaPcmOutputStream. std::ostream& operator<<(std::ostream& os, AlsaPcmOutputStream::InternalState state) { switch (state) { @@ -219,6 +204,15 @@ std::ostream& operator<<(std::ostream& os, return os; } +const char AlsaPcmOutputStream::kDefaultDevice[] = "default"; +const char AlsaPcmOutputStream::kAutoSelectDevice[] = ""; +const char AlsaPcmOutputStream::kPlugPrefix[] = "plug:"; + +// Since we expect to only be able to wake up with a resolution of +// kSleepErrorMilliseconds, double that for our minimum required latency. +const uint32 AlsaPcmOutputStream::kMinLatencyMicros = + kSleepErrorMilliseconds * 2 * 1000; + AlsaPcmOutputStream::AlsaPcmOutputStream(const std::string& device_name, AudioParameters params, AlsaWrapper* wrapper, diff --git a/media/audio/linux/alsa_util.cc b/media/audio/linux/alsa_util.cc index 27d0fc9..55aa50e 100644 --- a/media/audio/linux/alsa_util.cc +++ b/media/audio/linux/alsa_util.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -9,15 +9,15 @@ #include "base/logging.h" #include "media/audio/linux/alsa_wrapper.h" -namespace { +namespace alsa_util { -snd_pcm_t* OpenDevice(AlsaWrapper* wrapper, - const char* device_name, - snd_pcm_stream_t type, - int channels, - int sample_rate, - snd_pcm_format_t pcm_format, - int latency_us) { +static snd_pcm_t* OpenDevice(AlsaWrapper* wrapper, + const char* device_name, + snd_pcm_stream_t type, + int channels, + int sample_rate, + snd_pcm_format_t pcm_format, + int latency_us) { snd_pcm_t* handle = NULL; int error = wrapper->PcmOpen(&handle, device_name, type, SND_PCM_NONBLOCK); if (error < 0) { @@ -43,10 +43,6 @@ snd_pcm_t* OpenDevice(AlsaWrapper* wrapper, return handle; } -} // namespace - -namespace alsa_util { - snd_pcm_format_t BitsToFormat(int bits_per_sample) { switch (bits_per_sample) { case 8: diff --git a/media/audio/linux/audio_manager_linux.cc b/media/audio/linux/audio_manager_linux.cc index 09c8625..b1108be 100644 --- a/media/audio/linux/audio_manager_linux.cc +++ b/media/audio/linux/audio_manager_linux.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -18,14 +18,10 @@ #include "media/base/limits.h" #include "media/base/media_switches.h" -namespace { - // Maximum number of output streams that can be open simultaneously. -const size_t kMaxOutputStreams = 50; - -const int kMaxInputChannels = 2; +static const size_t kMaxOutputStreams = 50; -} // namespace +static const int kMaxInputChannels = 2; // Implementation of AudioManager. bool AudioManagerLinux::HasAudioOutputDevices() { diff --git a/media/audio/mac/audio_manager_mac.cc b/media/audio/mac/audio_manager_mac.cc index 71ce811..8b2c918 100644 --- a/media/audio/mac/audio_manager_mac.cc +++ b/media/audio/mac/audio_manager_mac.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -13,23 +13,21 @@ #include "media/audio/mac/audio_output_mac.h" #include "media/base/limits.h" -namespace { - -const int kMaxInputChannels = 2; +static const int kMaxInputChannels = 2; // Maximum number of output streams that can be open simultaneously. -const size_t kMaxOutputStreams = 50; +static const size_t kMaxOutputStreams = 50; // By experiment the maximum number of audio streams allowed in Leopard // is 18. But we put a slightly smaller number just to be safe. -const size_t kMaxOutputStreamsLeopard = 15; +static const size_t kMaxOutputStreamsLeopard = 15; // Initialized to ether |kMaxOutputStreams| or |kMaxOutputStreamsLeopard|. -size_t g_max_output_streams = 0; +static size_t g_max_output_streams = 0; // Returns the number of audio streams allowed. This is a practical limit to // prevent failure caused by too many audio streams opened. -size_t GetMaxAudioOutputStreamsAllowed() { +static size_t GetMaxAudioOutputStreamsAllowed() { if (g_max_output_streams == 0) { // We are hitting a bug in Leopard where too many audio streams will cause // a deadlock in the AudioQueue API when starting the stream. Unfortunately @@ -50,7 +48,7 @@ size_t GetMaxAudioOutputStreamsAllowed() { return g_max_output_streams; } -bool HasAudioHardware(AudioObjectPropertySelector selector) { +static bool HasAudioHardware(AudioObjectPropertySelector selector) { AudioDeviceID output_device_id = kAudioObjectUnknown; const AudioObjectPropertyAddress property_address = { selector, @@ -67,7 +65,6 @@ bool HasAudioHardware(AudioObjectPropertySelector selector) { return err == kAudioHardwareNoError && output_device_id != kAudioObjectUnknown; } -} // namespace AudioManagerMac::AudioManagerMac() : num_output_streams_(0) { diff --git a/media/audio/mac/audio_output_mac.cc b/media/audio/mac/audio_output_mac.cc index 615fa5e..ab96bd6 100644 --- a/media/audio/mac/audio_output_mac.cc +++ b/media/audio/mac/audio_output_mac.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -9,16 +9,12 @@ #include "media/audio/audio_util.h" #include "media/audio/mac/audio_manager_mac.h" -namespace { - // A custom data structure to store information an AudioQueue buffer. struct AudioQueueUserData { AudioQueueUserData() : empty_buffer(false) {} bool empty_buffer; }; -} // namespace - // Overview of operation: // 1) An object of PCMQueueOutAudioOutputStream is created by the AudioManager // factory: audio_man->MakeAudioStream(). This just fills some structure. @@ -178,7 +174,6 @@ void PCMQueueOutAudioOutputStream::GetVolume(double* volume) { // Reorder PCM from AAC layout to Core Audio layout. // TODO(fbarchard): Switch layout when ffmpeg is updated. -namespace { template<class Format> static void SwizzleLayout(Format* b, uint32 filled) { static const int kNumSurroundChannels = 6; @@ -193,7 +188,6 @@ static void SwizzleLayout(Format* b, uint32 filled) { b[5] = aac[4]; // Rs } } -} // namespace // Note to future hackers of this function: Do not add locks here because we // call out to third party source that might do crazy things including adquire diff --git a/media/audio/openbsd/audio_manager_openbsd.cc b/media/audio/openbsd/audio_manager_openbsd.cc index b200309..c8b0568 100644 --- a/media/audio/openbsd/audio_manager_openbsd.cc +++ b/media/audio/openbsd/audio_manager_openbsd.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -6,9 +6,7 @@ #include "base/logging.h" -namespace { -AudioManagerOpenBSD* g_audio_manager = NULL; -} // namespace +static AudioManagerOpenBSD* g_audio_manager = NULL; // Implementation of AudioManager. bool AudioManagerOpenBSD::HasAudioOutputDevices() { diff --git a/media/audio/simple_sources_unittest.cc b/media/audio/simple_sources_unittest.cc index f96ffad..661361e 100644 --- a/media/audio/simple_sources_unittest.cc +++ b/media/audio/simple_sources_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -11,9 +11,7 @@ #include "media/audio/simple_sources.h" #include "testing/gtest/include/gtest/gtest.h" -namespace { - -void GenerateRandomData(char* buffer, uint32 len) { +static void GenerateRandomData(char* buffer, uint32 len) { static bool called = false; if (!called) { called = true; @@ -26,8 +24,6 @@ void GenerateRandomData(char* buffer, uint32 len) { buffer[i] = static_cast<char>(rand()); } -} // namespace - // To test write size smaller than read size. TEST(SimpleSourcesTest, PushSourceSmallerWrite) { const uint32 kDataSize = 40960; diff --git a/media/audio/win/audio_manager_win.cc b/media/audio/win/audio_manager_win.cc index 7b3d6fa..bc736bc 100644 --- a/media/audio/win/audio_manager_win.cc +++ b/media/audio/win/audio_manager_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -37,32 +37,30 @@ DEFINE_GUID(AM_KSCATEGORY_AUDIO, 0x6994ad04, 0x93ef, 0x11d0, 0xa3, 0xcc, 0x00, 0xa0, 0xc9, 0x22, 0x31, 0x96); -namespace { - // Maximum number of output streams that can be open simultaneously. -const size_t kMaxOutputStreams = 50; +static const size_t kMaxOutputStreams = 50; // Up to 8 channels can be passed to the driver. // This should work, given the right drivers, but graceful error handling is // needed. -const int kWinMaxChannels = 8; +static const int kWinMaxChannels = 8; -const int kWinMaxInputChannels = 2; +static const int kWinMaxInputChannels = 2; // We use 3 buffers for recording audio so that if a recording callback takes // some time to return we won't lose audio. More buffers while recording are // ok because they don't introduce any delay in recording, unlike in playback // where you first need to fill in that number of buffers before starting to // play. -const int kNumInputBuffers = 3; +static const int kNumInputBuffers = 3; -int GetVersionPartAsInt(DWORDLONG num) { +static int GetVersionPartAsInt(DWORDLONG num) { return static_cast<int>(num & 0xffff); } // Returns a string containing the given device's description and installed // driver version. -string16 GetDeviceAndDriverInfo(HDEVINFO device_info, - SP_DEVINFO_DATA* device_data) { +static string16 GetDeviceAndDriverInfo(HDEVINFO device_info, + SP_DEVINFO_DATA* device_data) { // Save the old install params setting and set a flag for the // SetupDiBuildDriverInfoList below to return only the installed drivers. SP_DEVINSTALL_PARAMS old_device_install_params; @@ -97,8 +95,6 @@ string16 GetDeviceAndDriverInfo(HDEVINFO device_info, return device_and_driver_info; } -} // namespace - AudioManagerWin::AudioManagerWin() : num_output_streams_(0) { } diff --git a/media/audio/win/audio_output_win_unittest.cc b/media/audio/win/audio_output_win_unittest.cc index 50483b4..35ea300 100644 --- a/media/audio/win/audio_output_win_unittest.cc +++ b/media/audio/win/audio_output_win_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -25,9 +25,7 @@ using ::testing::NiceMock; using ::testing::NotNull; using ::testing::Return; -namespace { - -const wchar_t kAudioFile1_16b_m_16K[] +static const wchar_t kAudioFile1_16b_m_16K[] = L"media\\test\\data\\sweep02_16b_mono_16KHz.raw"; // This class allows to find out if the callbacks are occurring as @@ -69,12 +67,10 @@ class TestSourceBasic : public AudioOutputStream::AudioSourceCallback { int had_error_; }; -bool IsRunningHeadless() { +static bool IsRunningHeadless() { return (0 != ::GetEnvironmentVariableW(L"CHROME_HEADLESS", NULL, 0)); } -} // namespace. - const int kNumBuffers = 3; // Specializes TestSourceBasic to detect that the AudioStream is using // triple buffering correctly. @@ -618,7 +614,6 @@ TEST(WinAudioTest, PCMWaveStreamPendingBytes) { oas->Close(); } -namespace { // Simple source that uses a SyncSocket to retrieve the audio data // from a potentially remote thread. class SyncSocketSource : public AudioOutputStream::AudioSourceCallback { @@ -683,8 +678,6 @@ DWORD __stdcall SyncSocketThread(void* context) { return 0; } -} // namespace - // Test the basic operation of AudioOutputStream used with a SyncSocket. // The emphasis is to test low-latency with buffers less than 100ms. With // the waveout api it seems not possible to go below 50ms. In this test diff --git a/media/audio/win/wavein_input_win.cc b/media/audio/win/wavein_input_win.cc index c02fd52..fdc08b8 100644 --- a/media/audio/win/wavein_input_win.cc +++ b/media/audio/win/wavein_input_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -14,16 +14,12 @@ #include "media/audio/audio_util.h" #include "media/audio/win/audio_manager_win.h" -namespace { - // Our sound buffers are allocated once and kept in a linked list using the // the WAVEHDR::dwUser variable. The last buffer points to the first buffer. -WAVEHDR* GetNextBuffer(WAVEHDR* current) { +static WAVEHDR* GetNextBuffer(WAVEHDR* current) { return reinterpret_cast<WAVEHDR*>(current->dwUser); } -} // namespace - PCMWaveInAudioInputStream::PCMWaveInAudioInputStream( AudioManagerWin* manager, AudioParameters params, int num_buffers, UINT device_id) diff --git a/media/audio/win/waveout_output_win.cc b/media/audio/win/waveout_output_win.cc index 9c99634..5a08635 100644 --- a/media/audio/win/waveout_output_win.cc +++ b/media/audio/win/waveout_output_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -29,24 +29,21 @@ // to make sure we are not executing inside the audio source's OnMoreData() // or that we take locks inside WaveCallback() or QueueNextPacket(). -namespace { // Sixty four MB is the maximum buffer size per AudioOutputStream. -const uint32 kMaxOpenBufferSize = 1024 * 1024 * 64; +static const uint32 kMaxOpenBufferSize = 1024 * 1024 * 64; // Our sound buffers are allocated once and kept in a linked list using the // the WAVEHDR::dwUser variable. The last buffer points to the first buffer. -WAVEHDR* GetNextBuffer(WAVEHDR* current) { +static WAVEHDR* GetNextBuffer(WAVEHDR* current) { return reinterpret_cast<WAVEHDR*>(current->dwUser); } -} // namespace - // See Also // http://www.thx.com/consumer/home-entertainment/home-theater/surround-sound-speaker-set-up/ // http://en.wikipedia.org/wiki/Surround_sound -const int kMaxChannelsToMask = 8; -const unsigned int kChannelsToMask[kMaxChannelsToMask + 1] = { +static const int kMaxChannelsToMask = 8; +static const unsigned int kChannelsToMask[kMaxChannelsToMask + 1] = { 0, // 1 = Mono SPEAKER_FRONT_CENTER, diff --git a/media/base/media_posix.cc b/media/base/media_posix.cc index 438155a..08684e7 100644 --- a/media/base/media_posix.cc +++ b/media/base/media_posix.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -24,8 +24,6 @@ namespace tp_ffmpeg = third_party_ffmpeg; namespace media { -namespace { - // Handy to prevent shooting ourselves in the foot with macro wizardry. #if !defined(LIBAVCODEC_VERSION_MAJOR) || \ !defined(LIBAVFORMAT_VERSION_MAJOR) || \ @@ -39,18 +37,20 @@ namespace { #if defined(OS_MACOSX) #define DSO_NAME(MODULE, VERSION) ("lib" MODULE "." VERSION ".dylib") -const FilePath::CharType sumo_name[] = +static const FilePath::CharType sumo_name[] = FILE_PATH_LITERAL("libffmpegsumo.dylib"); #elif defined(OS_POSIX) #define DSO_NAME(MODULE, VERSION) ("lib" MODULE ".so." VERSION) -const FilePath::CharType sumo_name[] = FILE_PATH_LITERAL("libffmpegsumo.so"); +static const FilePath::CharType sumo_name[] = + FILE_PATH_LITERAL("libffmpegsumo.so"); #else #error "Do not know how to construct DSO name for this OS." #endif -const FilePath::CharType openmax_name[] = FILE_PATH_LITERAL("libOmxCore.so"); +static const FilePath::CharType openmax_name[] = + FILE_PATH_LITERAL("libOmxCore.so"); // Retrieves the DSOName for the given key. -std::string GetDSOName(tp_ffmpeg::StubModules stub_key) { +static std::string GetDSOName(tp_ffmpeg::StubModules stub_key) { // TODO(ajwong): Remove this once mac is migrated. Either that, or have GYP // set a constant that we can switch implementations based off of. switch (stub_key) { @@ -66,8 +66,6 @@ std::string GetDSOName(tp_ffmpeg::StubModules stub_key) { } } -} // namespace - // Attempts to initialize the media library (loading DSOs, etc.). // Returns true if everything was successfully initialized, false otherwise. bool InitializeMediaLibrary(const FilePath& module_dir) { diff --git a/media/base/media_win.cc b/media/base/media_win.cc index 87a9aa3..82f8596 100644 --- a/media/base/media_win.cc +++ b/media/base/media_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -22,16 +22,14 @@ namespace media { -namespace { - enum FFmpegDLLKeys { - FILE_LIBAVCODEC, // full path to libavcodec media decoding library. - FILE_LIBAVFORMAT, // full path to libavformat media parsing library. - FILE_LIBAVUTIL, // full path to libavutil media utility library. + FILE_LIBAVCODEC, // full path to libavcodec media decoding library. + FILE_LIBAVFORMAT, // full path to libavformat media parsing library. + FILE_LIBAVUTIL, // full path to libavutil media utility library. }; // Retrieves the DLLName for the given key. -FilePath::CharType* GetDLLName(FFmpegDLLKeys dll_key) { +static FilePath::CharType* GetDLLName(FFmpegDLLKeys dll_key) { // TODO(ajwong): Do we want to lock to a specific ffmpeg version? switch (dll_key) { case FILE_LIBAVCODEC: @@ -46,8 +44,6 @@ FilePath::CharType* GetDLLName(FFmpegDLLKeys dll_key) { } } -} // namespace - // Attempts to initialize the media library (loading DLLs, DSOs, etc.). // Returns true if everything was successfully initialized, false otherwise. bool InitializeMediaLibrary(const FilePath& base_path) { diff --git a/media/base/pipeline_impl_unittest.cc b/media/base/pipeline_impl_unittest.cc index cc6de37..0762cb35 100644 --- a/media/base/pipeline_impl_unittest.cc +++ b/media/base/pipeline_impl_unittest.cc @@ -24,17 +24,13 @@ using ::testing::Return; using ::testing::ReturnRef; using ::testing::StrictMock; -namespace { +namespace media { // Total bytes of the data source. -const int kTotalBytes = 1024; +static const int kTotalBytes = 1024; // Buffered bytes of the data source. -const int kBufferedBytes = 1024; - -} // namespace - -namespace media { +static const int kBufferedBytes = 1024; // Used for setting expectations on pipeline callbacks. Using a StrictMock // also lets us test for missing callbacks. diff --git a/media/ffmpeg/file_protocol.cc b/media/ffmpeg/file_protocol.cc index f778319..af2c847 100644 --- a/media/ffmpeg/file_protocol.cc +++ b/media/ffmpeg/file_protocol.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -21,14 +21,12 @@ // warning C4996: 'open': The POSIX name for this item is deprecated. MSVC_PUSH_DISABLE_WARNING(4996) -namespace { - -int GetHandle(URLContext *h) { +static int GetHandle(URLContext *h) { return static_cast<int>(reinterpret_cast<intptr_t>(h->priv_data)); } // FFmpeg protocol interface. -int OpenContext(URLContext* h, const char* filename, int flags) { +static int OpenContext(URLContext* h, const char* filename, int flags) { int access = O_RDONLY; if (flags & URL_RDWR) { access = O_CREAT | O_TRUNC | O_RDWR; @@ -46,19 +44,19 @@ int OpenContext(URLContext* h, const char* filename, int flags) { return 0; } -int ReadContext(URLContext* h, unsigned char* buf, int size) { +static int ReadContext(URLContext* h, unsigned char* buf, int size) { return HANDLE_EINTR(read(GetHandle(h), buf, size)); } #if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52, 68, 0) -int WriteContext(URLContext* h, const unsigned char* buf, int size) { +static int WriteContext(URLContext* h, const unsigned char* buf, int size) { #else -int WriteContext(URLContext* h, unsigned char* buf, int size) { +static int WriteContext(URLContext* h, unsigned char* buf, int size) { #endif return HANDLE_EINTR(write(GetHandle(h), buf, size)); } -int64 SeekContext(URLContext* h, int64 offset, int whence) { +static int64 SeekContext(URLContext* h, int64 offset, int whence) { #if defined(OS_WIN) return _lseeki64(GetHandle(h), static_cast<__int64>(offset), whence); #else @@ -67,12 +65,10 @@ int64 SeekContext(URLContext* h, int64 offset, int whence) { #endif } -int CloseContext(URLContext* h) { +static int CloseContext(URLContext* h) { return HANDLE_EINTR(close(GetHandle(h))); } -} // namespace - MSVC_POP_WARNING() URLProtocol kFFmpegFileProtocol = { diff --git a/media/filters/decoder_base_unittest.cc b/media/filters/decoder_base_unittest.cc index 02ef1ec..f0d4117 100644 --- a/media/filters/decoder_base_unittest.cc +++ b/media/filters/decoder_base_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -22,16 +22,12 @@ namespace media { class GTEST_TEST_CLASS_NAME_(DecoderBaseTest, FlowControl); -} // namespace media - -namespace { - -class MockDecoderOutput : public media::StreamSample { +class MockDecoderOutput : public StreamSample { public: MOCK_CONST_METHOD0(IsEndOfStream, bool()); }; -class MockBuffer : public media::Buffer { +class MockBuffer : public Buffer { public: MockBuffer() {} virtual ~MockBuffer() {} @@ -42,7 +38,7 @@ class MockBuffer : public media::Buffer { DISALLOW_COPY_AND_ASSIGN(MockBuffer); }; -class MockDecoder : public media::Filter { +class MockDecoder : public Filter { public: typedef Callback1<scoped_refptr<MockDecoderOutput> >::Type ConsumeAudioSamplesCallback; @@ -61,35 +57,31 @@ class MockDecoderCallback { MOCK_METHOD1(OnReadComplete, void(scoped_refptr<MockDecoderOutput> output)); }; -class MockDecoderImpl : public media::DecoderBase< +class MockDecoderImpl : public DecoderBase< MockDecoder, MockDecoderOutput> { public: explicit MockDecoderImpl(MessageLoop* message_loop) - : media::DecoderBase<MockDecoder, MockDecoderOutput>(message_loop) { - media_format_.SetAsString(media::MediaFormat::kMimeType, "mock"); + : DecoderBase<MockDecoder, MockDecoderOutput>(message_loop) { + media_format_.SetAsString(MediaFormat::kMimeType, "mock"); } virtual ~MockDecoderImpl() {} // DecoderBase Implementations. MOCK_METHOD3(DoInitialize, - void(media::DemuxerStream* demuxer_stream, + void(DemuxerStream* demuxer_stream, bool* success, Task* done_cb)); MOCK_METHOD1(DoStop, void(Task* done_cb)); MOCK_METHOD2(DoSeek, void(base::TimeDelta time, Task* done_cb)); - MOCK_METHOD1(DoDecode, void(media::Buffer* input)); + MOCK_METHOD1(DoDecode, void(Buffer* input)); private: - FRIEND_TEST(media::DecoderBaseTest, FlowControl); + FRIEND_TEST(DecoderBaseTest, FlowControl); DISALLOW_COPY_AND_ASSIGN(MockDecoderImpl); }; -} // namespace - -namespace media { - ACTION(Initialize) { AutoTaskRunner done_runner(arg2); *arg1 = true; diff --git a/media/filters/ffmpeg_glue.cc b/media/filters/ffmpeg_glue.cc index fede662..236b3d6 100644 --- a/media/filters/ffmpeg_glue.cc +++ b/media/filters/ffmpeg_glue.cc @@ -1,22 +1,23 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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/filters/ffmpeg_glue.h" + #include "base/string_util.h" #include "media/base/filters.h" #include "media/ffmpeg/ffmpeg_common.h" -#include "media/filters/ffmpeg_glue.h" -namespace { +namespace media { -media::FFmpegURLProtocol* ToProtocol(void* data) { - return reinterpret_cast<media::FFmpegURLProtocol*>(data); +static FFmpegURLProtocol* ToProtocol(void* data) { + return reinterpret_cast<FFmpegURLProtocol*>(data); } // FFmpeg protocol interface. -int OpenContext(URLContext* h, const char* filename, int flags) { - media::FFmpegURLProtocol* protocol; - media::FFmpegGlue::GetInstance()->GetProtocol(filename, &protocol); +static int OpenContext(URLContext* h, const char* filename, int flags) { + FFmpegURLProtocol* protocol; + FFmpegGlue::GetInstance()->GetProtocol(filename, &protocol); if (!protocol) return AVERROR_IO; @@ -26,8 +27,8 @@ int OpenContext(URLContext* h, const char* filename, int flags) { return 0; } -int ReadContext(URLContext* h, unsigned char* buf, int size) { - media::FFmpegURLProtocol* protocol = ToProtocol(h->priv_data); +static int ReadContext(URLContext* h, unsigned char* buf, int size) { + FFmpegURLProtocol* protocol = ToProtocol(h->priv_data); int result = protocol->Read(size, buf); if (result < 0) result = AVERROR_IO; @@ -35,16 +36,16 @@ int ReadContext(URLContext* h, unsigned char* buf, int size) { } #if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52, 68, 0) -int WriteContext(URLContext* h, const unsigned char* buf, int size) { +static int WriteContext(URLContext* h, const unsigned char* buf, int size) { #else -int WriteContext(URLContext* h, unsigned char* buf, int size) { +static int WriteContext(URLContext* h, unsigned char* buf, int size) { #endif // We don't support writing. return AVERROR_IO; } -int64 SeekContext(URLContext* h, int64 offset, int whence) { - media::FFmpegURLProtocol* protocol = ToProtocol(h->priv_data); +static int64 SeekContext(URLContext* h, int64 offset, int whence) { + FFmpegURLProtocol* protocol = ToProtocol(h->priv_data); int64 new_offset = AVERROR_IO; switch (whence) { case SEEK_SET: @@ -80,12 +81,12 @@ int64 SeekContext(URLContext* h, int64 offset, int whence) { return new_offset; } -int CloseContext(URLContext* h) { +static int CloseContext(URLContext* h) { h->priv_data = NULL; return 0; } -int LockManagerOperation(void** lock, enum AVLockOp op) { +static int LockManagerOperation(void** lock, enum AVLockOp op) { switch (op) { case AV_LOCK_CREATE: *lock = new base::Lock(); @@ -109,12 +110,6 @@ int LockManagerOperation(void** lock, enum AVLockOp op) { return 1; } -} // namespace - -//------------------------------------------------------------------------------ - -namespace media { - // Use the HTTP protocol to avoid any file path separator issues. static const char kProtocol[] = "http"; diff --git a/media/filters/file_data_source_unittest.cc b/media/filters/file_data_source_unittest.cc index 8e867be..1770ac4 100644 --- a/media/filters/file_data_source_unittest.cc +++ b/media/filters/file_data_source_unittest.cc @@ -16,7 +16,7 @@ using ::testing::NiceMock; using ::testing::StrictMock; -namespace { +namespace media { class ReadCallbackHandler { public: @@ -28,10 +28,6 @@ class ReadCallbackHandler { DISALLOW_COPY_AND_ASSIGN(ReadCallbackHandler); }; -} // namespace - -namespace media { - // Returns a path to the test file which contains the string "0123456789" // without the quotes or any trailing space or null termination. The file lives // under the media/test/data directory. Under Windows, strings for the diff --git a/media/omx/omx_codec_unittest.cc b/media/omx/omx_codec_unittest.cc index 5dbde65..06fa31e 100644 --- a/media/omx/omx_codec_unittest.cc +++ b/media/omx/omx_codec_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -30,15 +30,12 @@ using ::testing::SetArgumentPointee; using ::testing::StrEq; using ::testing::StrictMock; -namespace { - -const int kBufferCount = 3; -const int kBufferSize = 4096; -const char* kComponentName = "OMX.google.video_decoder.avc"; +namespace media { -} // namespace +static const int kBufferCount = 3; +static const int kBufferSize = 4096; +static const char* kComponentName = "OMX.google.video_decoder.avc"; -namespace media { ACTION(ReturnComponentName) { strcpy(((char**)arg2)[0], kComponentName); } diff --git a/media/omx/omx_configurator.cc b/media/omx/omx_configurator.cc index 6f9c2ad..821cd2d 100644 --- a/media/omx/omx_configurator.cc +++ b/media/omx/omx_configurator.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this +// Copyright (c) 2011 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. @@ -6,17 +6,17 @@ #include "base/logging.h" -namespace { +namespace media { -std::string GetCodecName(media::OmxConfigurator::Codec codec) { +static std::string GetCodecName(OmxConfigurator::Codec codec) { switch (codec) { - case media::OmxConfigurator::kCodecH264: + case OmxConfigurator::kCodecH264: return "avc"; - case media::OmxConfigurator::kCodecH263: + case OmxConfigurator::kCodecH263: return "h263"; - case media::OmxConfigurator::kCodecMpeg4: + case OmxConfigurator::kCodecMpeg4: return "mpeg4"; - case media::OmxConfigurator::kCodecVc1: + case OmxConfigurator::kCodecVc1: return "vc1"; default: break; @@ -25,10 +25,6 @@ std::string GetCodecName(media::OmxConfigurator::Codec codec) { return ""; } -} // namespace - -namespace media { - std::string OmxDecoderConfigurator::GetRoleName() const { return "video_decoder." + GetCodecName(input_format().codec); } diff --git a/media/omx/omx_unittest.cc b/media/omx/omx_unittest.cc index 18dab47..a60e21a 100644 --- a/media/omx/omx_unittest.cc +++ b/media/omx/omx_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -9,10 +9,10 @@ #include "third_party/openmax/il/OMX_Component.h" #include "third_party/openmax/il/OMX_Core.h" -namespace { +namespace media { // Defines the maximum number of buffers created for I/O ports. -const int kMaxBufferNum = 256; +static const int kMaxBufferNum = 256; template <typename T> static void ResetHeader(T* param) { @@ -22,10 +22,6 @@ static void ResetHeader(T* param) { param->nSize = sizeof(T); } -} // namespace - -namespace media { - class OmxTest : public testing::Test { public: OmxTest() diff --git a/media/tools/mfdecoder/main.cc b/media/tools/mfdecoder/main.cc index 788bda0..ef31c48 100644 --- a/media/tools/mfdecoder/main.cc +++ b/media/tools/mfdecoder/main.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -26,20 +26,18 @@ #include "media/tools/mfdecoder/mfdecoder.h" #include "ui/gfx/gdi_util.h" -namespace { +static const char* const kWindowClass = "Chrome_MF_Decoder"; +static const char* const kWindowTitle = "MF Decoder"; +static const int kWindowStyleFlags = + (WS_OVERLAPPEDWINDOW | WS_VISIBLE) & ~(WS_MAXIMIZEBOX | WS_THICKFRAME); +static bool g_render_to_window = false; +static bool g_render_asap = false; -const char* const kWindowClass = "Chrome_MF_Decoder"; -const char* const kWindowTitle = "MF Decoder"; -const int kWindowStyleFlags = (WS_OVERLAPPEDWINDOW | WS_VISIBLE) & - ~(WS_MAXIMIZEBOX | WS_THICKFRAME); -bool g_render_to_window = false; -bool g_render_asap = false; +static base::TimeDelta* g_decode_time; +static base::TimeDelta* g_render_time; +static int64 g_num_frames = 0; -base::TimeDelta* g_decode_time; -base::TimeDelta* g_render_time; -int64 g_num_frames = 0; - -void usage() { +static void usage() { static char* usage_msg = "Usage: mfdecoder (-s|-h) (-d|-r|-f) input-file\n" "-s: Use software decoding\n" "-h: Use hardware decoding\n" @@ -57,7 +55,7 @@ void usage() { // space for the returned Unicode string from the heap and it is caller's // responsibility to free it. // Returns: An equivalent Unicode string if successful, NULL otherwise. -wchar_t* ConvertASCIIStringToUnicode(const char* source) { +static wchar_t* ConvertASCIIStringToUnicode(const char* source) { if (source == NULL) { LOG(ERROR) << "ConvertASCIIStringToUnicode: source cannot be NULL"; return NULL; @@ -83,8 +81,8 @@ wchar_t* ConvertASCIIStringToUnicode(const char* source) { // Converts the given raw data buffer into RGB32 format, and drawing the result // into the given window. This is only used when DXVA2 is not enabled. // Returns: true on success. -bool ConvertToRGBAndDrawToWindow(HWND video_window, uint8* data, int width, - int height, int stride) { +static bool ConvertToRGBAndDrawToWindow(HWND video_window, uint8* data, + int width, int height, int stride) { CHECK(video_window != NULL); CHECK(data != NULL); CHECK_GT(width, 0); @@ -132,8 +130,9 @@ bool ConvertToRGBAndDrawToWindow(HWND video_window, uint8* data, int width, // Obtains the underlying raw data buffer for the given IMFMediaBuffer, and // calls ConvertToRGBAndDrawToWindow() with it. // Returns: true on success. -bool PaintMediaBufferOntoWindow(HWND video_window, IMFMediaBuffer* video_buffer, - int width, int height, int stride) { +static bool PaintMediaBufferOntoWindow(HWND video_window, + IMFMediaBuffer* video_buffer, + int width, int height, int stride) { CHECK(video_buffer != NULL); HRESULT hr; BYTE* data; @@ -164,8 +163,8 @@ bool PaintMediaBufferOntoWindow(HWND video_window, IMFMediaBuffer* video_buffer, // Obtains the D3D9 surface from the given IMFMediaBuffer, then calls methods // in the D3D device to draw to the window associated with it. // Returns: true on success. -bool PaintD3D9BufferOntoWindow(IDirect3DDevice9* device, - IMFMediaBuffer* video_buffer) { +static bool PaintD3D9BufferOntoWindow(IDirect3DDevice9* device, + IMFMediaBuffer* video_buffer) { CHECK(device != NULL); ScopedComPtr<IDirect3DSurface9> surface; HRESULT hr = MFGetService(video_buffer, MR_BUFFER_SERVICE, @@ -219,8 +218,8 @@ bool PaintD3D9BufferOntoWindow(IDirect3DDevice9* device, // For H.264 format, there should only be 1 buffer per sample, so each buffer // represents 1 frame. // Returns: true if successful. -bool DrawVideoSample(HWND video_window, media::MFDecoder* decoder, - IDirect3DDevice9* device) { +static bool DrawVideoSample(HWND video_window, media::MFDecoder* decoder, + IDirect3DDevice9* device) { CHECK(video_window != NULL); CHECK(decoder != NULL); CHECK(decoder->initialized()); @@ -268,7 +267,7 @@ bool DrawVideoSample(HWND video_window, media::MFDecoder* decoder, // Creates a window with the given width and height. // Returns: A handle to the window on success, NULL otherwise. -HWND CreateDrawWindow(int width, int height) { +static HWND CreateDrawWindow(int width, int height) { WNDCLASS window_class = {0}; window_class.lpszClassName = kWindowClass; window_class.hInstance = NULL; @@ -303,8 +302,8 @@ HWND CreateDrawWindow(int width, int height) { // device. This function is used by mfdecoder.cc during the call to // MFDecoder::GetDXVA2AttributesForSourceReader(). // Returns: The D3D manager object if successful. Otherwise, NULL is returned. -IDirect3DDeviceManager9* CreateD3DDevManager(HWND video_window, - IDirect3DDevice9** device) { +static IDirect3DDeviceManager9* CreateD3DDevManager(HWND video_window, + IDirect3DDevice9** device) { CHECK(video_window != NULL); CHECK(device != NULL); int ret = -1; @@ -366,9 +365,9 @@ IDirect3DDeviceManager9* CreateD3DDevManager(HWND video_window, // buffer dimensions to the actual video frame dimensions. // Both the decoder and device should be initialized before calling this method. // Returns: true if successful. -bool AdjustD3DDeviceBackBufferDimensions(media::MFDecoder* decoder, - IDirect3DDevice9* device, - HWND video_window) { +static bool AdjustD3DDeviceBackBufferDimensions(media::MFDecoder* decoder, + IDirect3DDevice9* device, + HWND video_window) { CHECK(decoder != NULL); CHECK(decoder->initialized()); CHECK(decoder->use_dxva2()); @@ -390,8 +389,8 @@ bool AdjustD3DDeviceBackBufferDimensions(media::MFDecoder* decoder, // Post this task in the MessageLoop. This function keeps posting itself // until DrawVideoSample fails. -void RepaintTask(media::MFDecoder* decoder, HWND video_window, - IDirect3DDevice9* device) { +static void RepaintTask(media::MFDecoder* decoder, HWND video_window, + IDirect3DDevice9* device) { // This sends a WM_PAINT message so we can paint on the window later. // If we are using D3D9, then we do not send a WM_PAINT message since the two // do not work well together. @@ -418,8 +417,6 @@ void RepaintTask(media::MFDecoder* decoder, HWND video_window, } } -} // namespace - int main(int argc, char** argv) { if (argc < 2) { fprintf(stderr, "missing arguments\n"); diff --git a/media/tools/mfplayer/mfplayer.cc b/media/tools/mfplayer/mfplayer.cc index fbeb32f..79894ee 100644 --- a/media/tools/mfplayer/mfplayer.cc +++ b/media/tools/mfplayer/mfplayer.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -11,17 +11,16 @@ #include <cassert> -namespace { - template <class T> -void SafeRelease(T** pptr) { +static void SafeRelease(T** pptr) { if (pptr && *pptr) { (*pptr)->Release(); *pptr = NULL; } } -HRESULT ProbeTopology(IMFMediaEvent* event, IMFTopology** topology_ptr) { +static HRESULT ProbeTopology(IMFMediaEvent* event, + IMFTopology** topology_ptr) { HRESULT hr = S_OK; PROPVARIANT var; PropVariantInit(&var); @@ -36,8 +35,6 @@ HRESULT ProbeTopology(IMFMediaEvent* event, IMFTopology** topology_ptr) { return hr; } -} // namespace - namespace mfplayer { // Public methods diff --git a/media/tools/scaler_bench/scaler_bench.cc b/media/tools/scaler_bench/scaler_bench.cc index f9be6c6..86ee335 100644 --- a/media/tools/scaler_bench/scaler_bench.cc +++ b/media/tools/scaler_bench/scaler_bench.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -22,16 +22,14 @@ using base::TimeDelta; using base::TimeTicks; using media::VideoFrame; -namespace { +static int source_width = 1280; +static int source_height = 720; +static int dest_width = 1366; +static int dest_height = 768; +static int num_frames = 500; +static int num_buffers = 50; -int source_width = 1280; -int source_height = 720; -int dest_width = 1366; -int dest_height = 768; -int num_frames = 500; -int num_buffers = 50; - -double BenchmarkSkia() { +static double BenchmarkSkia() { std::vector<scoped_refptr<VideoFrame> > source_frames; ScopedVector<SkBitmap> dest_frames; for (int i = 0; i < num_buffers; i++) { @@ -87,7 +85,7 @@ double BenchmarkSkia() { return static_cast<double>((end - start).InMilliseconds()) / num_frames; } -double BenchmarkRGBToYUV() { +static double BenchmarkRGBToYUV() { int rgb_stride = source_width * 4; scoped_array<uint8> rgb_frame(new uint8[rgb_stride * source_height]); @@ -115,7 +113,7 @@ double BenchmarkRGBToYUV() { return static_cast<double>((end - start).InMilliseconds()) / num_frames; } -double BenchmarkFilter(media::ScaleFilter filter) { +static double BenchmarkFilter(media::ScaleFilter filter) { std::vector<scoped_refptr<VideoFrame> > source_frames; std::vector<scoped_refptr<VideoFrame> > dest_frames; @@ -158,8 +156,6 @@ double BenchmarkFilter(media::ScaleFilter filter) { return static_cast<double>((end - start).InMilliseconds()) / num_frames; } -} // namespace - int main(int argc, const char** argv) { CommandLine::Init(argc, argv); const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); diff --git a/media/tools/shader_bench/window_linux.cc b/media/tools/shader_bench/window_linux.cc index 1c43505..0063a8d 100644 --- a/media/tools/shader_bench/window_linux.cc +++ b/media/tools/shader_bench/window_linux.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -10,24 +10,22 @@ #include <gdk/gdkx.h> #include <gtk/gtk.h> -namespace { +namespace media { -gboolean OnDelete(GtkWidget* widget, GdkEventExpose* event) { +static gboolean OnDelete(GtkWidget* widget, GdkEventExpose* event) { gtk_main_quit(); return FALSE; } -gboolean OnExpose(GtkWidget* widget, GdkEventExpose* event, gpointer data) { - media::Window* window = reinterpret_cast<media::Window*>(data); +static gboolean OnExpose(GtkWidget* widget, + GdkEventExpose* event, + gpointer data) { + Window* window = reinterpret_cast<Window*>(data); if (window) window->OnPaint(); return FALSE; } -} // namespace - -namespace media { - gfx::NativeWindow Window::CreateNativeWindow(int width, int height) { GtkWidget* hwnd = gtk_window_new(GTK_WINDOW_TOPLEVEL); @@ -52,12 +50,12 @@ void Window::Start(int limit, Task* done_task, Painter* painter) { gtk_signal_connect(GTK_OBJECT(window_handle_), "delete_event", - reinterpret_cast<GtkSignalFunc>(::OnDelete), + reinterpret_cast<GtkSignalFunc>(OnDelete), NULL); gtk_signal_connect(GTK_OBJECT(window_handle_), "expose_event", - reinterpret_cast<GtkSignalFunc>(::OnExpose), + reinterpret_cast<GtkSignalFunc>(OnExpose), this); gtk_widget_queue_draw(GTK_WIDGET(window_handle_)); diff --git a/media/tools/shader_bench/window_win.cc b/media/tools/shader_bench/window_win.cc index 0d9c3f9..827e210 100644 --- a/media/tools/shader_bench/window_win.cc +++ b/media/tools/shader_bench/window_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -7,10 +7,10 @@ #include "base/task.h" #include "media/tools/shader_bench/painter.h" -namespace { +namespace media { -LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, - WPARAM w_param, LPARAM l_param) { +static LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, + WPARAM w_param, LPARAM l_param) { LRESULT result = 0; switch (msg) { case WM_CLOSE: @@ -25,9 +25,8 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, result = 1; break; case WM_PAINT: { - media::Window* window = - reinterpret_cast<media::Window*>( - GetWindowLongPtr(hwnd, GWL_USERDATA)); + Window* window = + reinterpret_cast<Window*>(GetWindowLongPtr(hwnd, GWL_USERDATA)); if (window != NULL) window->OnPaint(); ::ValidateRect(hwnd, NULL); @@ -40,10 +39,6 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, return result; } -} // namespace - -namespace media { - gfx::NativeWindow Window::CreateNativeWindow(int width, int height) { WNDCLASS wnd_class = {0}; HINSTANCE instance = GetModuleHandle(NULL); diff --git a/media/video/mft_h264_decode_engine.cc b/media/video/mft_h264_decode_engine.cc index 340043a..bb3143c 100644 --- a/media/video/mft_h264_decode_engine.cc +++ b/media/video/mft_h264_decode_engine.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -26,7 +26,7 @@ using base::TimeDelta; -namespace { +namespace media { // Creates an empty Media Foundation sample with no buffers. static IMFSample* CreateEmptySample() { @@ -132,11 +132,11 @@ static IMFSample* CreateInputSample(const uint8* stream, int size, return sample.Detach(); } -const GUID ConvertVideoFrameFormatToGuid(media::VideoFrame::Format format) { +const GUID ConvertVideoFrameFormatToGuid(VideoFrame::Format format) { switch (format) { - case media::VideoFrame::NV12: + case VideoFrame::NV12: return MFVideoFormat_NV12; - case media::VideoFrame::YV12: + case VideoFrame::YV12: return MFVideoFormat_YV12; default: NOTREACHED() << "Unsupported VideoFrame format"; @@ -146,10 +146,6 @@ const GUID ConvertVideoFrameFormatToGuid(media::VideoFrame::Format format) { return GUID_NULL; } -} // namespace - -namespace media { - // public methods MftH264DecodeEngine::MftH264DecodeEngine(bool use_dxva) @@ -689,7 +685,7 @@ bool MftH264DecodeEngine::DoDecode(const PipelineStatistics& statistics) { void MftH264DecodeEngine::OnUploadVideoFrameDone( ScopedComPtr<IDirect3DSurface9, &IID_IDirect3DSurface9> surface, - scoped_refptr<media::VideoFrame> frame, + scoped_refptr<VideoFrame> frame, PipelineStatistics statistics) { // After this method is exited the reference to surface is released. event_handler_->ConsumeVideoFrame(frame, statistics); |