summaryrefslogtreecommitdiffstats
path: root/media/audio
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-17 00:59:12 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-17 00:59:12 +0000
commit3f86af3b4bd82cfece0c57eff1ffa2e8237219a2 (patch)
tree1dbf7605c1300deebcdc6ac3c2ba563bf9fab1e0 /media/audio
parent07f65b49bc63751dad9c2676d2feb96bfaa379be (diff)
downloadchromium_src-3f86af3b4bd82cfece0c57eff1ffa2e8237219a2.zip
chromium_src-3f86af3b4bd82cfece0c57eff1ffa2e8237219a2.tar.gz
chromium_src-3f86af3b4bd82cfece0c57eff1ffa2e8237219a2.tar.bz2
Setting svn:eol-style LF for media source files.
Removed some trailing whitespace as well and fixed some style nits. No code change. TEST=none BUG=none TBR=hclam Review URL: http://codereview.chromium.org/125225 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18577 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio')
-rw-r--r--media/audio/mac/audio_manager_mac.h9
-rw-r--r--media/audio/mac/audio_output_mac.cc8
-rw-r--r--media/audio/mac/audio_output_mac_unittest.cc16
-rw-r--r--media/audio/simple_sources_unittest.cc124
4 files changed, 79 insertions, 78 deletions
diff --git a/media/audio/mac/audio_manager_mac.h b/media/audio/mac/audio_manager_mac.h
index 670b51c..46cb2a5 100644
--- a/media/audio/mac/audio_manager_mac.h
+++ b/media/audio/mac/audio_manager_mac.h
@@ -14,8 +14,9 @@ class PCMQueueOutAudioOutputStream;
// to the audio output and only internal users can call methods not exposed by
// the AudioManager class.
class AudioManagerMac : public AudioManager {
-public:
+ public:
AudioManagerMac() {};
+
// Implementation of AudioManager.
virtual bool HasAudioDevices();
virtual AudioOutputStream* MakeAudioStream(Format format, int channels,
@@ -24,13 +25,13 @@ public:
virtual void MuteAll();
virtual void UnMuteAll();
virtual const void* GetLastMockBuffer();
-
+
// Mac-only method to free a stream created in MakeAudioStream.
// It is called internally by the audio stream when it has been closed.
void ReleaseStream(PCMQueueOutAudioOutputStream* stream);
-private:
- friend void DestroyAudioManagerMac(void *);
+ private:
+ friend void DestroyAudioManagerMac(void*);
virtual ~AudioManagerMac() {};
DISALLOW_COPY_AND_ASSIGN(AudioManagerMac);
};
diff --git a/media/audio/mac/audio_output_mac.cc b/media/audio/mac/audio_output_mac.cc
index 0b90d2c..4d7c6bb 100644
--- a/media/audio/mac/audio_output_mac.cc
+++ b/media/audio/mac/audio_output_mac.cc
@@ -122,13 +122,13 @@ void PCMQueueOutAudioOutputStream::Close() {
void PCMQueueOutAudioOutputStream::Stop() {
// We request a synchronous stop, so the next call can take some time. In
- // the windows implementation we block here as well.
+ // the windows implementation we block here as well.
source_ = NULL;
// We set the source to null to signal to the data queueing thread it can stop
// queueing data, however at most one callback might still be in flight which
// could attempt to enqueue right after the next call. Rather that trying to
// use a lock we rely on the internal Mac queue lock so the enqueue might
- // succeed or might fail but it won't crash or leave the queue itself in an
+ // succeed or might fail but it won't crash or leave the queue itself in an
// inconsistent state.
OSStatus err = AudioQueueStop(audio_queue_, true);
if (err != noErr)
@@ -194,7 +194,7 @@ void PCMQueueOutAudioOutputStream::Start(AudioSourceCallback* callback) {
HandleError(err);
return;
}
- source_ = callback;
+ source_ = callback;
// Ask the source to pre-fill all our buffers before playing.
for(size_t ix = 0; ix != kNumBuffers; ++ix) {
RenderCallback(this, NULL, buffer_[ix]);
@@ -202,7 +202,7 @@ void PCMQueueOutAudioOutputStream::Start(AudioSourceCallback* callback) {
// Queue the buffers to the audio driver, sounds starts now.
for(size_t ix = 0; ix != kNumBuffers; ++ix) {
err = AudioQueueEnqueueBuffer(audio_queue_, buffer_[ix], 0, NULL);
- if (err != noErr) {
+ if (err != noErr) {
HandleError(err);
return;
}
diff --git a/media/audio/mac/audio_output_mac_unittest.cc b/media/audio/mac/audio_output_mac_unittest.cc
index c0f5348..d6abefd 100644
--- a/media/audio/mac/audio_output_mac_unittest.cc
+++ b/media/audio/mac/audio_output_mac_unittest.cc
@@ -9,14 +9,14 @@
// Validate that the SineWaveAudioSource writes the expected values for
-// the FORMAT_16BIT_MONO.
+// the FORMAT_16BIT_MONO.
TEST(MacAudioTest, SineWaveAudio16MonoTest) {
const size_t samples = 1024;
const int freq = 200;
-
+
SineWaveAudioSource source(SineWaveAudioSource::FORMAT_16BIT_LINEAR_PCM, 1,
freq, AudioManager::kTelephoneSampleRate);
-
+
// TODO(cpu): Put the real test when the mock renderer is ported.
int16 buffer[samples] = { 0xffff };
source.OnMoreData(NULL, buffer, sizeof(buffer));
@@ -68,11 +68,11 @@ TEST(MacAudioTest, PCMWaveStreamPlay200HzTone44KssMono) {
audio_man->MakeAudioStream(AudioManager::AUDIO_PCM_LINEAR, 1,
AudioManager::kAudioCDSampleRate, 16);
ASSERT_TRUE(NULL != oas);
-
+
SineWaveAudioSource source(SineWaveAudioSource::FORMAT_16BIT_LINEAR_PCM, 1,
200.0, AudioManager::kAudioCDSampleRate);
size_t bytes_100_ms = (AudioManager::kAudioCDSampleRate / 10) * 2;
-
+
EXPECT_TRUE(oas->Open(bytes_100_ms));
oas->Start(&source);
usleep(1500000);
@@ -93,14 +93,14 @@ TEST(MacAudioTest, PCMWaveStreamPlay200HzTone22KssMono) {
audio_man->MakeAudioStream(AudioManager::AUDIO_PCM_LINEAR, 1,
AudioManager::kAudioCDSampleRate/2, 16);
ASSERT_TRUE(NULL != oas);
-
+
SineWaveAudioSource source(SineWaveAudioSource::FORMAT_16BIT_LINEAR_PCM, 1,
200.0, AudioManager::kAudioCDSampleRate/2);
size_t bytes_100_ms = (AudioManager::kAudioCDSampleRate / 20) * 2;
-
+
EXPECT_TRUE(oas->Open(bytes_100_ms));
oas->Start(&source);
- usleep(1500000);
+ usleep(1500000);
oas->Stop();
oas->Close();
}
diff --git a/media/audio/simple_sources_unittest.cc b/media/audio/simple_sources_unittest.cc
index b40c0b4..32176b7 100644
--- a/media/audio/simple_sources_unittest.cc
+++ b/media/audio/simple_sources_unittest.cc
@@ -1,62 +1,62 @@
-// Copyright (c) 2009 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 "base/basictypes.h"
-#include "base/scoped_ptr.h"
-#include "base/time.h"
-#include "media/audio/simple_sources.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-void GenerateRandomData(char* buffer, size_t len) {
- static bool called = false;
- if (!called) {
- called = true;
- int seed = static_cast<int>(base::Time::Now().ToInternalValue());
- srand(seed);
- LOG(INFO) << "Random seed: " << seed;
- }
-
- for (size_t i = 0; i < len; i++) {
- buffer[i] = static_cast<char>(rand());
- }
-}
-
-} // namespace
-
-// To test write size smaller than read size.
-TEST(SimpleSourcesTest, PushSourceSmallerWrite) {
- const size_t kDataSize = 40960;
- scoped_array<char> data(new char[kDataSize]);
- GenerateRandomData(data.get(), kDataSize);
-
- // Choose two prime numbers for read and write sizes.
- const size_t kWriteSize = 283;
- const size_t kReadSize = 293;
- scoped_array<char> read_data(new char[kReadSize]);
-
- // Create a PushSource that assumes the hardware audio buffer size is always
- // bigger than the write size.
- PushSource push_source(kReadSize);
- EXPECT_EQ(0u, push_source.UnProcessedBytes());
-
- // Write everything into this push source.
- for (size_t i = 0; i < kDataSize; i += kWriteSize) {
- size_t size = std::min(kDataSize - i, kWriteSize);
- EXPECT_TRUE(push_source.Write(data.get() + i, size));
- }
- EXPECT_EQ(kDataSize, push_source.UnProcessedBytes());
-
- // Read everything from the push source.
- for (size_t i = 0; i < kDataSize; i += kReadSize) {
- size_t size = std::min(kDataSize - i , kReadSize);
- EXPECT_EQ(size, push_source.OnMoreData(NULL, read_data.get(), size));
- EXPECT_EQ(0, memcmp(data.get() + i, read_data.get(), size));
- }
- EXPECT_EQ(0u, push_source.UnProcessedBytes());
-
- push_source.OnClose(NULL);
-}
+// Copyright (c) 2009 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 "base/basictypes.h"
+#include "base/scoped_ptr.h"
+#include "base/time.h"
+#include "media/audio/simple_sources.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+void GenerateRandomData(char* buffer, size_t len) {
+ static bool called = false;
+ if (!called) {
+ called = true;
+ int seed = static_cast<int>(base::Time::Now().ToInternalValue());
+ srand(seed);
+ LOG(INFO) << "Random seed: " << seed;
+ }
+
+ for (size_t i = 0; i < len; i++) {
+ buffer[i] = static_cast<char>(rand());
+ }
+}
+
+} // namespace
+
+// To test write size smaller than read size.
+TEST(SimpleSourcesTest, PushSourceSmallerWrite) {
+ const size_t kDataSize = 40960;
+ scoped_array<char> data(new char[kDataSize]);
+ GenerateRandomData(data.get(), kDataSize);
+
+ // Choose two prime numbers for read and write sizes.
+ const size_t kWriteSize = 283;
+ const size_t kReadSize = 293;
+ scoped_array<char> read_data(new char[kReadSize]);
+
+ // Create a PushSource that assumes the hardware audio buffer size is always
+ // bigger than the write size.
+ PushSource push_source(kReadSize);
+ EXPECT_EQ(0u, push_source.UnProcessedBytes());
+
+ // Write everything into this push source.
+ for (size_t i = 0; i < kDataSize; i += kWriteSize) {
+ size_t size = std::min(kDataSize - i, kWriteSize);
+ EXPECT_TRUE(push_source.Write(data.get() + i, size));
+ }
+ EXPECT_EQ(kDataSize, push_source.UnProcessedBytes());
+
+ // Read everything from the push source.
+ for (size_t i = 0; i < kDataSize; i += kReadSize) {
+ size_t size = std::min(kDataSize - i , kReadSize);
+ EXPECT_EQ(size, push_source.OnMoreData(NULL, read_data.get(), size));
+ EXPECT_EQ(0, memcmp(data.get() + i, read_data.get(), size));
+ }
+ EXPECT_EQ(0u, push_source.UnProcessedBytes());
+
+ push_source.OnClose(NULL);
+}