summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-05 06:39:06 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-05 06:39:06 +0000
commitf6eeded10a75632e1bc5ecaad9be46553c4ab908 (patch)
tree8a400e987cd72f1a4b799ce086f3d4169d87b0e9
parent29a984ff619eb0bdd27bc612bed55f6146cce4fe (diff)
downloadchromium_src-f6eeded10a75632e1bc5ecaad9be46553c4ab908.zip
chromium_src-f6eeded10a75632e1bc5ecaad9be46553c4ab908.tar.gz
chromium_src-f6eeded10a75632e1bc5ecaad9be46553c4ab908.tar.bz2
Remove size_t from audio IPC code.
The change got to this size because I had to modify the surrounding code (I didn't want to just cast at the last minute). Review URL: http://codereview.chromium.org/577006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38192 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/renderer_host/audio_renderer_host.cc59
-rw-r--r--chrome/browser/renderer_host/audio_renderer_host.h32
-rw-r--r--chrome/browser/renderer_host/audio_renderer_host_unittest.cc20
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h1
-rw-r--r--chrome/common/render_messages.h38
-rw-r--r--chrome/common/render_messages_internal.h26
-rw-r--r--chrome/renderer/audio_message_filter.cc14
-rw-r--r--chrome/renderer/audio_message_filter.h19
-rw-r--r--chrome/renderer/audio_message_filter_unittest.cc30
-rw-r--r--chrome/renderer/media/audio_renderer_impl.cc32
-rw-r--r--chrome/renderer/media/audio_renderer_impl.h20
-rw-r--r--chrome/renderer/media/audio_renderer_impl_unittest.cc12
-rw-r--r--chrome/renderer/pepper_devices.cc8
-rw-r--r--chrome/renderer/pepper_devices.h8
-rw-r--r--media/audio/audio_output.h14
-rw-r--r--media/audio/fake_audio_output_stream.cc7
-rw-r--r--media/audio/fake_audio_output_stream.h6
-rw-r--r--media/audio/linux/alsa_output.cc66
-rw-r--r--media/audio/linux/alsa_output.h57
-rw-r--r--media/audio/linux/alsa_output_unittest.cc14
-rw-r--r--media/audio/mac/audio_output_mac.cc22
-rw-r--r--media/audio/mac/audio_output_mac.h8
-rw-r--r--media/audio/mac/audio_output_mac_unittest.cc16
-rw-r--r--media/audio/simple_sources.cc27
-rw-r--r--media/audio/simple_sources.h28
-rw-r--r--media/audio/simple_sources_unittest.cc26
-rw-r--r--media/audio/win/audio_output_win_unittest.cc56
-rw-r--r--media/audio/win/waveout_output_win.cc18
-rw-r--r--media/audio/win/waveout_output_win.h10
-rw-r--r--media/filters/audio_renderer_algorithm_base.cc10
-rw-r--r--media/filters/audio_renderer_algorithm_base.h10
-rw-r--r--media/filters/audio_renderer_algorithm_default.cc10
-rw-r--r--media/filters/audio_renderer_algorithm_default.h4
-rw-r--r--media/filters/audio_renderer_algorithm_ola.cc26
-rw-r--r--media/filters/audio_renderer_algorithm_ola.h14
-rw-r--r--media/filters/audio_renderer_base.cc8
-rw-r--r--media/filters/audio_renderer_base.h6
-rw-r--r--media/filters/audio_renderer_base_unittest.cc6
-rw-r--r--media/filters/audio_renderer_impl.cc11
-rw-r--r--media/filters/audio_renderer_impl.h6
40 files changed, 401 insertions, 404 deletions
diff --git a/chrome/browser/renderer_host/audio_renderer_host.cc b/chrome/browser/renderer_host/audio_renderer_host.cc
index 94d39ec..cf34c8f 100644
--- a/chrome/browser/renderer_host/audio_renderer_host.cc
+++ b/chrome/browser/renderer_host/audio_renderer_host.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
//
@@ -20,12 +20,13 @@
// variable. Writing to this variable needs to be protected in Play()
// and Pause().
+#include "chrome/browser/renderer_host/audio_renderer_host.h"
+
#include "base/histogram.h"
#include "base/lock.h"
#include "base/process.h"
#include "base/shared_memory.h"
#include "base/waitable_event.h"
-#include "chrome/browser/renderer_host/audio_renderer_host.h"
#include "chrome/common/render_messages.h"
#include "ipc/ipc_logging.h"
@@ -37,14 +38,14 @@ const int kSamplesPerHardwarePacket = 8192;
// If the size of the buffer is less than this number, then the low latency
// mode is to be used.
-const size_t kLowLatencyPacketThreshold = 1025;
+const uint32 kLowLatencyPacketThreshold = 1025;
-const size_t kMegabytes = 1024 * 1024;
+const uint32 kMegabytes = 1024 * 1024;
// The following parameters limit the request buffer and packet size from the
// renderer to avoid renderer from requesting too much memory.
-const size_t kMaxDecodedPacketSize = 2 * kMegabytes;
-const size_t kMaxBufferCapacity = 5 * kMegabytes;
+const uint32 kMaxDecodedPacketSize = 2 * kMegabytes;
+const uint32 kMaxBufferCapacity = 5 * kMegabytes;
static const int kMaxChannels = 32;
static const int kMaxBitsPerSample = 64;
static const int kMaxSampleRate = 192000;
@@ -60,9 +61,9 @@ AudioRendererHost::IPCAudioSource::IPCAudioSource(
int route_id,
int stream_id,
AudioOutputStream* stream,
- size_t hardware_packet_size,
- size_t decoded_packet_size,
- size_t buffer_capacity)
+ uint32 hardware_packet_size,
+ uint32 decoded_packet_size,
+ uint32 buffer_capacity)
: host_(host),
process_id_(process_id),
route_id_(route_id),
@@ -93,8 +94,8 @@ AudioRendererHost::IPCAudioSource::CreateIPCAudioSource(
int channels,
int sample_rate,
char bits_per_sample,
- size_t decoded_packet_size,
- size_t buffer_capacity) {
+ uint32 decoded_packet_size,
+ uint32 buffer_capacity) {
// Perform come preliminary checks on the parameters.
// Make sure the renderer didn't ask for too much memory.
if (buffer_capacity > kMaxBufferCapacity ||
@@ -119,7 +120,7 @@ AudioRendererHost::IPCAudioSource::CreateIPCAudioSource(
AudioManager::GetAudioManager()->MakeAudioStream(
format, channels, sample_rate, bits_per_sample);
- size_t hardware_packet_size = kSamplesPerHardwarePacket * channels *
+ uint32 hardware_packet_size = kSamplesPerHardwarePacket * channels *
bits_per_sample / 8;
if (stream && !stream->Open(hardware_packet_size)) {
stream->Close();
@@ -208,8 +209,8 @@ void AudioRendererHost::IPCAudioSource::Play() {
state_ = kPlaying;
}
- ViewMsg_AudioStreamState state;
- state.state = ViewMsg_AudioStreamState::kPlaying;
+ ViewMsg_AudioStreamState_Params state;
+ state.state = ViewMsg_AudioStreamState_Params::kPlaying;
host_->Send(new ViewMsg_NotifyAudioStreamStateChanged(
route_id_, stream_id_, state));
}
@@ -225,8 +226,8 @@ void AudioRendererHost::IPCAudioSource::Pause() {
state_ = kPaused;
}
- ViewMsg_AudioStreamState state;
- state.state = ViewMsg_AudioStreamState::kPaused;
+ ViewMsg_AudioStreamState_Params state;
+ state.state = ViewMsg_AudioStreamState_Params::kPaused;
host_->Send(new ViewMsg_NotifyAudioStreamStateChanged(
route_id_, stream_id_, state));
}
@@ -263,10 +264,10 @@ void AudioRendererHost::IPCAudioSource::GetVolume() {
volume));
}
-size_t AudioRendererHost::IPCAudioSource::OnMoreData(AudioOutputStream* stream,
+uint32 AudioRendererHost::IPCAudioSource::OnMoreData(AudioOutputStream* stream,
void* dest,
- size_t max_size,
- int pending_bytes) {
+ uint32 max_size,
+ uint32 pending_bytes) {
AutoLock auto_lock(lock_);
// Record the callback time.
@@ -278,7 +279,7 @@ size_t AudioRendererHost::IPCAudioSource::OnMoreData(AudioOutputStream* stream,
return 0;
}
- size_t size;
+ uint32 size;
if (!shared_socket_.get()) {
// Push source doesn't need to know the stream and number of pending bytes.
// So just pass in NULL and 0 for them.
@@ -287,7 +288,7 @@ size_t AudioRendererHost::IPCAudioSource::OnMoreData(AudioOutputStream* stream,
SubmitPacketRequest(&auto_lock);
} else {
// Low latency mode.
- size = std::min(shared_memory_.max_size(), max_size);
+ size = std::min(static_cast<uint32>(shared_memory_.max_size()), max_size);
memcpy(dest, shared_memory_.memory(), size);
memset(shared_memory_.memory(), 0, shared_memory_.max_size());
shared_socket_->Send(&pending_bytes, sizeof(pending_bytes));
@@ -313,7 +314,7 @@ void AudioRendererHost::IPCAudioSource::OnError(AudioOutputStream* stream,
}
void AudioRendererHost::IPCAudioSource::NotifyPacketReady(
- size_t decoded_packet_size) {
+ uint32 decoded_packet_size) {
// Packet ready notifications do not happen in low latency mode. If they
// do something is horribly wrong.
DCHECK(!shared_socket_.get());
@@ -324,8 +325,8 @@ void AudioRendererHost::IPCAudioSource::NotifyPacketReady(
// If reported size is greater than capacity of the shared memory, we have
// an error.
if (decoded_packet_size <= decoded_packet_size_) {
- for (size_t i = 0; i < decoded_packet_size; i += hardware_packet_size_) {
- size_t size = std::min(decoded_packet_size - i, hardware_packet_size_);
+ for (uint32 i = 0; i < decoded_packet_size; i += hardware_packet_size_) {
+ uint32 size = std::min(decoded_packet_size - i, hardware_packet_size_);
ok &= push_source_.Write(
static_cast<char*>(shared_memory_.memory()) + i, size);
// We have received a data packet but we didn't finish writing to push
@@ -353,7 +354,7 @@ void AudioRendererHost::IPCAudioSource::SubmitPacketRequest_Locked() {
// This variable keeps track of the total amount of bytes buffered for
// the associated AudioOutputStream. This value should consist of bytes
// buffered in AudioOutputStream and those kept inside |push_source_|.
- size_t buffered_bytes = pending_bytes_ + push_source_.UnProcessedBytes();
+ uint32 buffered_bytes = pending_bytes_ + push_source_.UnProcessedBytes();
host_->Send(
new ViewMsg_RequestAudioPacket(
route_id_,
@@ -458,7 +459,7 @@ bool AudioRendererHost::IsAudioRendererHostMessage(
void AudioRendererHost::OnCreateStream(
const IPC::Message& msg, int stream_id,
- const ViewHostMsg_Audio_CreateStream& params) {
+ const ViewHostMsg_Audio_CreateStream_Params& params) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
DCHECK(Lookup(msg.routing_id(), stream_id) == NULL);
@@ -535,7 +536,7 @@ void AudioRendererHost::OnGetVolume(const IPC::Message& msg, int stream_id) {
}
void AudioRendererHost::OnNotifyPacketReady(const IPC::Message& msg,
- int stream_id, size_t packet_size) {
+ int stream_id, uint32 packet_size) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
IPCAudioSource* source = Lookup(msg.routing_id(), stream_id);
if (source) {
@@ -604,8 +605,8 @@ void AudioRendererHost::Send(IPC::Message* message) {
void AudioRendererHost::SendErrorMessage(int32 render_view_id,
int32 stream_id) {
- ViewMsg_AudioStreamState state;
- state.state = ViewMsg_AudioStreamState::kError;
+ ViewMsg_AudioStreamState_Params state;
+ state.state = ViewMsg_AudioStreamState_Params::kError;
Send(new ViewMsg_NotifyAudioStreamStateChanged(
render_view_id, stream_id, state));
}
diff --git a/chrome/browser/renderer_host/audio_renderer_host.h b/chrome/browser/renderer_host/audio_renderer_host.h
index 13f28f0..78ae292 100644
--- a/chrome/browser/renderer_host/audio_renderer_host.h
+++ b/chrome/browser/renderer_host/audio_renderer_host.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
//
@@ -89,7 +89,7 @@
#include "testing/gtest/include/gtest/gtest_prod.h"
class AudioManager;
-struct ViewHostMsg_Audio_CreateStream;
+struct ViewHostMsg_Audio_CreateStream_Params;
class AudioRendererHost
: public base::RefCountedThreadSafe<
@@ -179,8 +179,8 @@ class AudioRendererHost
int channels, // Number of channels.
int sample_rate, // Sampling frequency/rate.
char bits_per_sample, // Number of bits per sample.
- size_t decoded_packet_size, // Number of bytes per packet.
- size_t buffer_capacity // Number of bytes in the buffer.
+ uint32 decoded_packet_size, // Number of bytes per packet.
+ uint32 buffer_capacity // Number of bytes in the buffer.
);
~IPCAudioSource();
@@ -211,11 +211,11 @@ class AudioRendererHost
// Notify this source that buffer has been filled and is ready to be
// consumed.
- void NotifyPacketReady(size_t packet_size);
+ void NotifyPacketReady(uint32 packet_size);
// AudioSourceCallback methods.
- virtual size_t OnMoreData(AudioOutputStream* stream, void* dest,
- size_t max_size, int pending_bytes);
+ virtual uint32 OnMoreData(AudioOutputStream* stream, void* dest,
+ uint32 max_size, uint32 pending_bytes);
virtual void OnClose(AudioOutputStream* stream);
virtual void OnError(AudioOutputStream* stream, int code);
@@ -229,10 +229,10 @@ class AudioRendererHost
int route_id, // Routing ID to RenderView.
int stream_id, // ID of this source.
AudioOutputStream* stream, // Stream associated.
- size_t hardware_packet_size,
- size_t decoded_packet_size, // Size of shared memory
+ uint32 hardware_packet_size,
+ uint32 decoded_packet_size, // Size of shared memory
// buffer for writing.
- size_t buffer_capacity); // Capacity of transportation
+ uint32 buffer_capacity); // Capacity of transportation
// buffer.
// Check the condition of |outstanding_request_| and |push_source_| to
@@ -250,9 +250,9 @@ class AudioRendererHost
int route_id_;
int stream_id_;
AudioOutputStream* stream_;
- size_t hardware_packet_size_;
- size_t decoded_packet_size_;
- size_t buffer_capacity_;
+ uint32 hardware_packet_size_;
+ uint32 decoded_packet_size_;
+ uint32 buffer_capacity_;
State state_;
@@ -266,7 +266,7 @@ class AudioRendererHost
bool outstanding_request_;
// Number of bytes copied in the last OnMoreData call.
- int pending_bytes_;
+ uint32 pending_bytes_;
base::Time last_callback_time_;
// Protects:
@@ -288,7 +288,7 @@ class AudioRendererHost
// required properties. See IPCAudioSource::CreateIPCAudioSource() for more
// details.
void OnCreateStream(const IPC::Message& msg, int stream_id,
- const ViewHostMsg_Audio_CreateStream& params);
+ const ViewHostMsg_Audio_CreateStream_Params& params);
// Starts buffering for the audio output stream. Delegates the start method
// call to the corresponding IPCAudioSource::Play().
@@ -329,7 +329,7 @@ class AudioRendererHost
// AudioOutputStream::AUDIO_STREAM_ERROR is sent back to renderer if the
// required IPCAudioSource is not found.
void OnNotifyPacketReady(const IPC::Message& msg, int stream_id,
- size_t packet_size);
+ uint32 packet_size);
// Called on IO thread when this object needs to be destroyed and after
// Destroy() is called from owner of this class in UI thread.
diff --git a/chrome/browser/renderer_host/audio_renderer_host_unittest.cc b/chrome/browser/renderer_host/audio_renderer_host_unittest.cc
index 2ae271a..f868c2a 100644
--- a/chrome/browser/renderer_host/audio_renderer_host_unittest.cc
+++ b/chrome/browser/renderer_host/audio_renderer_host_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -23,8 +23,8 @@ namespace {
const int kInvalidId = -1;
const int kProcessId = 100;
const int kRouteId = 200;
-const int kBufferCapacity = 65536;
-const int kPacketSize = 16384;
+const uint32 kBufferCapacity = 65536;
+const uint32 kPacketSize = 16384;
} // namespace
@@ -37,14 +37,14 @@ class MockAudioRendererHost : public AudioRendererHost {
// A list of mock methods.
MOCK_METHOD4(OnRequestPacket,
void(int routing_id, int stream_id,
- size_t bytes_in_buffer, int64 message_timestamp));
+ uint32 bytes_in_buffer, int64 message_timestamp));
MOCK_METHOD3(OnStreamCreated,
void(int routing_id, int stream_id, int length));
MOCK_METHOD3(OnStreamStateChanged,
void(int routing_id, int stream_id,
- ViewMsg_AudioStreamState state));
+ const ViewMsg_AudioStreamState_Params& state));
MOCK_METHOD3(OnStreamVolume,
void(int routing_id, int stream_id, double volume));
@@ -79,13 +79,13 @@ class MockAudioRendererHost : public AudioRendererHost {
// These handler methods do minimal things and delegate to the mock methods.
void OnRequestPacket(const IPC::Message& msg, int stream_id,
- size_t bytes_in_buffer, int64 message_timestamp) {
+ uint32 bytes_in_buffer, int64 message_timestamp) {
OnRequestPacket(msg.routing_id(), stream_id, bytes_in_buffer,
message_timestamp);
}
void OnStreamCreated(const IPC::Message& msg, int stream_id,
- base::SharedMemoryHandle handle, int length) {
+ base::SharedMemoryHandle handle, uint32 length) {
// Maps the shared memory.
shared_memory_.reset(new base::SharedMemory(handle, true));
CHECK(shared_memory_->Map(length));
@@ -96,7 +96,7 @@ class MockAudioRendererHost : public AudioRendererHost {
}
void OnStreamStateChanged(const IPC::Message& msg, int stream_id,
- ViewMsg_AudioStreamState state) {
+ const ViewMsg_AudioStreamState_Params& state) {
OnStreamStateChanged(msg.routing_id(), stream_id, state);
}
@@ -210,7 +210,7 @@ TEST_F(AudioRendererHostTest, MockStreamDataConversation) {
2 * kPacketSize + 3 * kStep, _));
EXPECT_CALL(*host_,
OnRequestPacket(kRouteId, current_stream_id_, 3 * kPacketSize, _));
- ViewMsg_AudioStreamState state;
+ ViewMsg_AudioStreamState_Params state;
EXPECT_CALL(*host_, OnStreamStateChanged(kRouteId, current_stream_id_, _))
.WillOnce(SaveArg<2>(&state));
@@ -221,6 +221,6 @@ TEST_F(AudioRendererHostTest, MockStreamDataConversation) {
source->NotifyPacketReady(kStep);
source->NotifyPacketReady(kStep);
source->Play();
- EXPECT_EQ(ViewMsg_AudioStreamState::kPlaying, state.state);
+ EXPECT_EQ(ViewMsg_AudioStreamState_Params::kPlaying, state.state);
source->Close();
}
diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h
index e813ae1..2467645 100644
--- a/chrome/browser/renderer_host/resource_message_filter.h
+++ b/chrome/browser/renderer_host/resource_message_filter.h
@@ -43,7 +43,6 @@ class NotificationsPrefsCache;
class Profile;
class RenderWidgetHelper;
class URLRequestContextGetter;
-struct ViewHostMsg_Audio_CreateStream;
struct ViewHostMsg_CreateWorker_Params;
struct WebPluginInfo;
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index ed99e66..21bb359 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -1,13 +1,13 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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_RENDER_MESSAGES_H_
#define CHROME_COMMON_RENDER_MESSAGES_H_
+#include <map>
#include <string>
#include <vector>
-#include <map>
#include "app/clipboard/clipboard.h"
#include "app/gfx/native_widget_types.h"
@@ -107,7 +107,7 @@ struct ViewMsg_Navigate_Params {
// Current status of the audio output stream in the browser process. Browser
// sends information about the current playback state and error to the
// renderer process using this type.
-struct ViewMsg_AudioStreamState {
+struct ViewMsg_AudioStreamState_Params {
enum State {
kPlaying,
kPaused,
@@ -432,7 +432,7 @@ enum ViewHostMsg_ImeControl {
};
// Parameters for creating an audio output stream.
-struct ViewHostMsg_Audio_CreateStream {
+struct ViewHostMsg_Audio_CreateStream_Params {
// Format request for the stream.
AudioManager::Format format;
@@ -447,11 +447,11 @@ struct ViewHostMsg_Audio_CreateStream {
// Number of bytes per packet. Determines the maximum number of bytes
// transported for each audio packet request.
- size_t packet_size;
+ uint32 packet_size;
// Maximum number of bytes of audio packets that should be kept in the browser
// process.
- size_t buffer_capacity;
+ uint32 buffer_capacity;
};
// This message is used for supporting popup menus on Mac OS X using native
@@ -1842,10 +1842,10 @@ struct ParamTraits<AudioManager::Format> {
}
};
-// Traits for ViewHostMsg_Audio_CreateStream.
+// Traits for ViewHostMsg_Audio_CreateStream_Params.
template <>
-struct ParamTraits<ViewHostMsg_Audio_CreateStream> {
- typedef ViewHostMsg_Audio_CreateStream param_type;
+struct ParamTraits<ViewHostMsg_Audio_CreateStream_Params> {
+ typedef ViewHostMsg_Audio_CreateStream_Params param_type;
static void Write(Message* m, const param_type& p) {
WriteParam(m, p.format);
WriteParam(m, p.channels);
@@ -1864,7 +1864,7 @@ struct ParamTraits<ViewHostMsg_Audio_CreateStream> {
ReadParam(m, iter, &p->buffer_capacity);
}
static void Log(const param_type& p, std::wstring* l) {
- l->append(L"<ViewHostMsg_Audio_CreateStream>(");
+ l->append(L"<ViewHostMsg_Audio_CreateStream_Params>(");
LogParam(p.format, l);
l->append(L", ");
LogParam(p.channels, l);
@@ -1907,8 +1907,8 @@ struct ParamTraits<gfx::NativeView> {
#endif // defined(OS_POSIX)
template <>
-struct ParamTraits<ViewMsg_AudioStreamState> {
- typedef ViewMsg_AudioStreamState param_type;
+struct ParamTraits<ViewMsg_AudioStreamState_Params> {
+ typedef ViewMsg_AudioStreamState_Params param_type;
static void Write(Message* m, const param_type& p) {
m->WriteInt(p.state);
}
@@ -1916,20 +1916,20 @@ struct ParamTraits<ViewMsg_AudioStreamState> {
int type;
if (!m->ReadInt(iter, &type))
return false;
- p->state = static_cast<ViewMsg_AudioStreamState::State>(type);
+ p->state = static_cast<ViewMsg_AudioStreamState_Params::State>(type);
return true;
}
static void Log(const param_type& p, std::wstring* l) {
std::wstring state;
switch (p.state) {
- case ViewMsg_AudioStreamState::kPlaying:
- state = L"ViewMsg_AudioStreamState::kPlaying";
+ case ViewMsg_AudioStreamState_Params::kPlaying:
+ state = L"ViewMsg_AudioStreamState_Params::kPlaying";
break;
- case ViewMsg_AudioStreamState::kPaused:
- state = L"ViewMsg_AudioStreamState::kPaused";
+ case ViewMsg_AudioStreamState_Params::kPaused:
+ state = L"ViewMsg_AudioStreamState_Params::kPaused";
break;
- case ViewMsg_AudioStreamState::kError:
- state = L"ViewMsg_AudioStreamState::kError";
+ case ViewMsg_AudioStreamState_Params::kError:
+ state = L"ViewMsg_AudioStreamState_Params::kError";
break;
default:
state = L"UNKNOWN";
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index c3f96a9..bd23f31 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -6,38 +6,24 @@
// header guard.
// See ipc_message_macros.h for explanation of the macros and passes.
-#include <map>
-#include <string>
-#include <vector>
-
#include "build/build_config.h"
-#include "app/clipboard/clipboard.h"
-#include "app/gfx/native_widget_types.h"
#include "base/file_path.h"
#include "base/nullable_string16.h"
-#include "base/platform_file.h"
#include "base/gfx/rect.h"
-#include "base/shared_memory.h"
#include "base/sync_socket.h"
#include "base/values.h"
#include "chrome/common/content_settings.h"
-#include "chrome/common/css_colors.h"
#include "chrome/common/extensions/update_manifest.h"
#include "chrome/common/nacl_types.h"
#include "chrome/common/notification_type.h"
#include "chrome/common/page_zoom.h"
-#include "chrome/common/transport_dib.h"
-#include "chrome/common/view_types.h"
#include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_message_macros.h"
-#include "ipc/ipc_platform_file.h"
#include "third_party/skia/include/core/SkBitmap.h"
-#include "webkit/appcache/appcache_interfaces.h"
#include "webkit/glue/dom_operations.h"
#include "webkit/glue/webcursor.h"
-#include "webkit/glue/webplugin.h"
#if defined(OS_POSIX)
#include "base/file_descriptor_posix.h"
@@ -636,7 +622,7 @@ IPC_BEGIN_MESSAGES(View)
// Sent by AudioRendererHost to renderer to request an audio packet.
IPC_MESSAGE_ROUTED3(ViewMsg_RequestAudioPacket,
int /* stream id */,
- size_t /* bytes in buffer */,
+ uint32 /* bytes in buffer */,
int64 /* message timestamp */)
// Tell the renderer process that the audio stream has been created, renderer
@@ -645,7 +631,7 @@ IPC_BEGIN_MESSAGES(View)
IPC_MESSAGE_ROUTED3(ViewMsg_NotifyAudioStreamCreated,
int /* stream id */,
base::SharedMemoryHandle /* handle */,
- int /* length */)
+ uint32 /* length */)
// Tell the renderer process that a low latency audio stream has been created,
// renderer process would be given a SyncSocket that it should write to from
@@ -654,13 +640,13 @@ IPC_BEGIN_MESSAGES(View)
int /* stream id */,
base::SharedMemoryHandle /* handle */,
base::SyncSocket::Handle /* socket handle */,
- int /* length */)
+ uint32 /* length */)
// Notification message sent from AudioRendererHost to renderer for state
// update after the renderer has requested a Create/Start/Close.
IPC_MESSAGE_ROUTED2(ViewMsg_NotifyAudioStreamStateChanged,
int /* stream id */,
- ViewMsg_AudioStreamState /* new state */)
+ ViewMsg_AudioStreamState_Params /* new state */)
IPC_MESSAGE_ROUTED2(ViewMsg_NotifyAudioStreamVolume,
int /* stream id */,
@@ -1729,13 +1715,13 @@ IPC_BEGIN_MESSAGES(ViewHost)
// Request that got sent to browser for creating an audio output stream
IPC_MESSAGE_ROUTED2(ViewHostMsg_CreateAudioStream,
int /* stream_id */,
- ViewHostMsg_Audio_CreateStream)
+ ViewHostMsg_Audio_CreateStream_Params)
// Tell the browser the audio buffer prepared for stream
// (render_view_id, stream_id) is filled and is ready to be consumed.
IPC_MESSAGE_ROUTED2(ViewHostMsg_NotifyAudioPacketReady,
int /* stream_id */,
- size_t /* packet size */)
+ uint32 /* packet size */)
// Start buffering the audio stream specified by (render_view_id, stream_id).
IPC_MESSAGE_ROUTED1(ViewHostMsg_PlayAudioStream,
diff --git a/chrome/renderer/audio_message_filter.cc b/chrome/renderer/audio_message_filter.cc
index d5cd323..31c1df4 100644
--- a/chrome/renderer/audio_message_filter.cc
+++ b/chrome/renderer/audio_message_filter.cc
@@ -1,10 +1,11 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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 "chrome/renderer/audio_message_filter.h"
+
#include "base/message_loop.h"
#include "chrome/common/render_messages.h"
-#include "chrome/renderer/audio_message_filter.h"
#include "ipc/ipc_logging.h"
AudioMessageFilter::AudioMessageFilter(int32 route_id)
@@ -58,7 +59,7 @@ void AudioMessageFilter::OnChannelClosing() {
void AudioMessageFilter::OnRequestPacket(const IPC::Message& msg,
int stream_id,
- size_t bytes_in_buffer,
+ uint32 bytes_in_buffer,
int64 message_timestamp) {
Delegate* delegate = delegates_.Lookup(stream_id);
if (!delegate) {
@@ -73,7 +74,7 @@ void AudioMessageFilter::OnRequestPacket(const IPC::Message& msg,
void AudioMessageFilter::OnStreamCreated(int stream_id,
base::SharedMemoryHandle handle,
- int length) {
+ uint32 length) {
Delegate* delegate = delegates_.Lookup(stream_id);
if (!delegate) {
DLOG(WARNING) << "Got audio stream event for a non-existent or removed"
@@ -83,8 +84,9 @@ void AudioMessageFilter::OnStreamCreated(int stream_id,
delegate->OnCreated(handle, length);
}
-void AudioMessageFilter::OnStreamStateChanged(int stream_id,
- ViewMsg_AudioStreamState state) {
+void AudioMessageFilter::OnStreamStateChanged(
+ int stream_id,
+ const ViewMsg_AudioStreamState_Params& state) {
Delegate* delegate = delegates_.Lookup(stream_id);
if (!delegate) {
DLOG(WARNING) << "Got audio stream event for a non-existent or removed"
diff --git a/chrome/renderer/audio_message_filter.h b/chrome/renderer/audio_message_filter.h
index 8d1a0b5..3dfacdc 100644
--- a/chrome/renderer/audio_message_filter.h
+++ b/chrome/renderer/audio_message_filter.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
//
@@ -12,22 +12,26 @@
#include "base/id_map.h"
#include "base/shared_memory.h"
+#include "base/time.h"
#include "ipc/ipc_channel_proxy.h"
#include "testing/gtest/include/gtest/gtest_prod.h"
+struct ViewMsg_AudioStreamState_Params;
+
class AudioMessageFilter : public IPC::ChannelProxy::MessageFilter {
public:
class Delegate {
public:
// Called when an audio packet is requested from the browser process.
- virtual void OnRequestPacket(size_t bytes_in_buffer,
+ virtual void OnRequestPacket(uint32 bytes_in_buffer,
const base::Time& message_timestamp) = 0;
// Called when state of an audio stream has changed in the browser process.
- virtual void OnStateChanged(ViewMsg_AudioStreamState state) = 0;
+ virtual void OnStateChanged(
+ const ViewMsg_AudioStreamState_Params& state) = 0;
// Called when an audio stream has been created in the browser process.
- virtual void OnCreated(base::SharedMemoryHandle handle, size_t length) = 0;
+ virtual void OnCreated(base::SharedMemoryHandle handle, uint32 length) = 0;
// Called when notification of stream volume is received from the browser
// process.
@@ -66,15 +70,16 @@ class AudioMessageFilter : public IPC::ChannelProxy::MessageFilter {
// Received when browser process wants more audio packet.
void OnRequestPacket(const IPC::Message& msg, int stream_id,
- size_t bytes_in_buffer, int64 message_timestamp);
+ uint32 bytes_in_buffer, int64 message_timestamp);
// Received when browser process has created an audio output stream.
void OnStreamCreated(int stream_id, base::SharedMemoryHandle handle,
- int length);
+ uint32 length);
// Received when internal state of browser process' audio output device has
// changed.
- void OnStreamStateChanged(int stream_id, ViewMsg_AudioStreamState state);
+ void OnStreamStateChanged(int stream_id,
+ const ViewMsg_AudioStreamState_Params& state);
// Notification of volume property of an audio output stream.
void OnStreamVolume(int stream_id, double volume);
diff --git a/chrome/renderer/audio_message_filter_unittest.cc b/chrome/renderer/audio_message_filter_unittest.cc
index 878b284..3dce864 100644
--- a/chrome/renderer/audio_message_filter_unittest.cc
+++ b/chrome/renderer/audio_message_filter_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -16,19 +16,19 @@ class MockAudioDelegate : public AudioMessageFilter::Delegate {
Reset();
}
- virtual void OnRequestPacket(size_t bytes_in_buffer,
+ virtual void OnRequestPacket(uint32 bytes_in_buffer,
const base::Time& message_timestamp) {
request_packet_received_ = true;
bytes_in_buffer_ = bytes_in_buffer;
message_timestamp_ = message_timestamp;
}
- virtual void OnStateChanged(ViewMsg_AudioStreamState state) {
+ virtual void OnStateChanged(const ViewMsg_AudioStreamState_Params& state) {
state_changed_received_ = true;
state_ = state;
}
- virtual void OnCreated(base::SharedMemoryHandle handle, size_t length) {
+ virtual void OnCreated(base::SharedMemoryHandle handle, uint32 length) {
created_received_ = true;
handle_ = handle;
length_ = length;
@@ -45,7 +45,7 @@ class MockAudioDelegate : public AudioMessageFilter::Delegate {
message_timestamp_ = base::Time();
state_changed_received_ = false;
- state_.state = ViewMsg_AudioStreamState::kError;
+ state_.state = ViewMsg_AudioStreamState_Params::kError;
created_received_ = false;
handle_ = base::SharedMemory::NULLHandle();
@@ -56,30 +56,30 @@ class MockAudioDelegate : public AudioMessageFilter::Delegate {
}
bool request_packet_received() { return request_packet_received_; }
- size_t bytes_in_buffer() { return bytes_in_buffer_; }
+ uint32 bytes_in_buffer() { return bytes_in_buffer_; }
const base::Time& message_timestamp() { return message_timestamp_; }
bool state_changed_received() { return state_changed_received_; }
- ViewMsg_AudioStreamState state() { return state_; }
+ ViewMsg_AudioStreamState_Params state() { return state_; }
bool created_received() { return created_received_; }
base::SharedMemoryHandle handle() { return handle_; }
- size_t length() { return length_; }
+ uint32 length() { return length_; }
bool volume_received() { return volume_received_; }
double volume() { return volume_; }
private:
bool request_packet_received_;
- size_t bytes_in_buffer_;
+ uint32 bytes_in_buffer_;
base::Time message_timestamp_;
bool state_changed_received_;
- ViewMsg_AudioStreamState state_;
+ ViewMsg_AudioStreamState_Params state_;
bool created_received_;
base::SharedMemoryHandle handle_;
- size_t length_;
+ uint32 length_;
bool volume_received_;
double volume_;
@@ -99,7 +99,7 @@ TEST(AudioMessageFilterTest, Basic) {
int stream_id = filter->AddDelegate(&delegate);
// ViewMsg_RequestAudioPacket
- const size_t kSizeInBuffer = 1024;
+ const uint32 kSizeInBuffer = 1024;
const int64 kMessageTimestamp = 99;
EXPECT_FALSE(delegate.request_packet_received());
filter->OnMessageReceived(ViewMsg_RequestAudioPacket(kRouteId,
@@ -112,8 +112,8 @@ TEST(AudioMessageFilterTest, Basic) {
delegate.Reset();
// ViewMsg_NotifyAudioStreamStateChanged
- const ViewMsg_AudioStreamState kState =
- { ViewMsg_AudioStreamState::kPlaying };
+ const ViewMsg_AudioStreamState_Params kState =
+ { ViewMsg_AudioStreamState_Params::kPlaying };
EXPECT_FALSE(delegate.state_changed_received());
filter->OnMessageReceived(
ViewMsg_NotifyAudioStreamStateChanged(kRouteId, stream_id, kState));
@@ -122,7 +122,7 @@ TEST(AudioMessageFilterTest, Basic) {
delegate.Reset();
// ViewMsg_NotifyAudioStreamCreated
- const size_t kLength = 1024;
+ const uint32 kLength = 1024;
EXPECT_FALSE(delegate.created_received());
filter->OnMessageReceived(
ViewMsg_NotifyAudioStreamCreated(kRouteId,
diff --git a/chrome/renderer/media/audio_renderer_impl.cc b/chrome/renderer/media/audio_renderer_impl.cc
index f10ff37..3aba1c1 100644
--- a/chrome/renderer/media/audio_renderer_impl.cc
+++ b/chrome/renderer/media/audio_renderer_impl.cc
@@ -1,12 +1,13 @@
-// 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.
+// Copyright (c) 2010 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 "chrome/renderer/media/audio_renderer_impl.h"
#include <math.h>
#include "chrome/common/render_messages.h"
#include "chrome/renderer/audio_message_filter.h"
-#include "chrome/renderer/media/audio_renderer_impl.h"
#include "chrome/renderer/render_view.h"
#include "chrome/renderer/render_thread.h"
#include "media/base/filter_host.h"
@@ -76,8 +77,8 @@ bool AudioRendererImpl::OnInitialize(const media::MediaFormat& media_format) {
// Create the audio output stream in browser process.
bytes_per_second_ = sample_rate_ * channels_ * sample_bits_ / 8;
- size_t packet_size = bytes_per_second_ * kMillisecondsPerPacket / 1000;
- size_t buffer_capacity = packet_size * kPacketsInBuffer;
+ uint32 packet_size = bytes_per_second_ * kMillisecondsPerPacket / 1000;
+ uint32 buffer_capacity = packet_size * kPacketsInBuffer;
// Calculate the amount for prerolling.
preroll_bytes_ = bytes_per_second_ * kMillisecondsPreroll / 1000;
@@ -161,7 +162,7 @@ void AudioRendererImpl::SetVolume(float volume) {
}
void AudioRendererImpl::OnCreated(base::SharedMemoryHandle handle,
- size_t length) {
+ uint32 length) {
DCHECK(MessageLoop::current() == io_loop_);
AutoLock auto_lock(lock_);
@@ -173,7 +174,7 @@ void AudioRendererImpl::OnCreated(base::SharedMemoryHandle handle,
shared_memory_size_ = length;
}
-void AudioRendererImpl::OnRequestPacket(size_t bytes_in_buffer,
+void AudioRendererImpl::OnRequestPacket(uint32 bytes_in_buffer,
const base::Time& message_timestamp) {
DCHECK(MessageLoop::current() == io_loop_);
@@ -192,7 +193,8 @@ void AudioRendererImpl::OnRequestPacket(size_t bytes_in_buffer,
OnNotifyPacketReady();
}
-void AudioRendererImpl::OnStateChanged(ViewMsg_AudioStreamState state) {
+void AudioRendererImpl::OnStateChanged(
+ const ViewMsg_AudioStreamState_Params& state) {
DCHECK(MessageLoop::current() == io_loop_);
AutoLock auto_lock(lock_);
@@ -200,7 +202,7 @@ void AudioRendererImpl::OnStateChanged(ViewMsg_AudioStreamState state) {
return;
switch (state.state) {
- case ViewMsg_AudioStreamState::kError:
+ case ViewMsg_AudioStreamState_Params::kError:
// We receive this error if we counter an hardware error on the browser
// side. We can proceed with ignoring the audio stream.
// TODO(hclam): We need more handling of these kind of error. For example
@@ -209,8 +211,8 @@ void AudioRendererImpl::OnStateChanged(ViewMsg_AudioStreamState state) {
host()->BroadcastMessage(media::kMsgDisableAudio);
break;
// TODO(hclam): handle these events.
- case ViewMsg_AudioStreamState::kPlaying:
- case ViewMsg_AudioStreamState::kPaused:
+ case ViewMsg_AudioStreamState_Params::kPlaying:
+ case ViewMsg_AudioStreamState_Params::kPaused:
break;
default:
NOTREACHED();
@@ -225,7 +227,7 @@ void AudioRendererImpl::OnVolume(double volume) {
void AudioRendererImpl::OnCreateStream(
AudioManager::Format format, int channels, int sample_rate,
- int bits_per_sample, size_t packet_size, size_t buffer_capacity) {
+ int bits_per_sample, uint32 packet_size, uint32 buffer_capacity) {
DCHECK(MessageLoop::current() == io_loop_);
AutoLock auto_lock(lock_);
@@ -237,7 +239,7 @@ void AudioRendererImpl::OnCreateStream(
stream_id_ = filter_->AddDelegate(this);
io_loop_->AddDestructionObserver(this);
- ViewHostMsg_Audio_CreateStream params;
+ ViewHostMsg_Audio_CreateStream_Params params;
params.format = format;
params.channels = channels;
params.sample_rate = sample_rate;
@@ -324,7 +326,7 @@ void AudioRendererImpl::OnNotifyPacketReady() {
GetPlaybackRate())));
}
- size_t filled = FillBuffer(static_cast<uint8*>(shared_memory_->memory()),
+ uint32 filled = FillBuffer(static_cast<uint8*>(shared_memory_->memory()),
shared_memory_size_,
request_delay);
// TODO(hclam): we should try to fill in the buffer as much as possible.
diff --git a/chrome/renderer/media/audio_renderer_impl.h b/chrome/renderer/media/audio_renderer_impl.h
index 01885be..2c4d990 100644
--- a/chrome/renderer/media/audio_renderer_impl.h
+++ b/chrome/renderer/media/audio_renderer_impl.h
@@ -1,6 +1,6 @@
-// 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.
+// Copyright (c) 2010 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.
//
// Audio rendering unit utilizing audio output stream provided by browser
// process through IPC.
@@ -118,10 +118,10 @@ class AudioRendererImpl : public media::AudioRendererBase,
// Methods called on IO thread ----------------------------------------------
// AudioMessageFilter::Delegate methods, called by AudioMessageFilter.
- void OnRequestPacket(size_t bytes_in_buffer,
+ void OnRequestPacket(uint32 bytes_in_buffer,
const base::Time& message_timestamp);
- void OnStateChanged(ViewMsg_AudioStreamState state);
- void OnCreated(base::SharedMemoryHandle handle, size_t length);
+ void OnStateChanged(const ViewMsg_AudioStreamState_Params& state);
+ void OnCreated(base::SharedMemoryHandle handle, uint32 length);
void OnVolume(double volume);
// Methods called on pipeline thread ----------------------------------------
@@ -163,7 +163,7 @@ class AudioRendererImpl : public media::AudioRendererBase,
// sends IPC messages on that thread.
void OnCreateStream(AudioManager::Format format, int channels,
int sample_rate, int bits_per_sample,
- size_t packet_size, size_t buffer_capacity);
+ uint32 packet_size, uint32 buffer_capacity);
void OnPlay();
void OnPause();
void OnSetVolume(double volume);
@@ -177,7 +177,7 @@ class AudioRendererImpl : public media::AudioRendererBase,
int channels_;
int sample_rate_;
int sample_bits_;
- size_t bytes_per_second_;
+ uint32 bytes_per_second_;
scoped_refptr<AudioMessageFilter> filter_;
@@ -186,7 +186,7 @@ class AudioRendererImpl : public media::AudioRendererBase,
// Memory shared by the browser process for audio buffer.
scoped_ptr<base::SharedMemory> shared_memory_;
- size_t shared_memory_size_;
+ uint32 shared_memory_size_;
// Message loop for the IO thread.
MessageLoop* io_loop_;
@@ -214,7 +214,7 @@ class AudioRendererImpl : public media::AudioRendererBase,
bool prerolling_;
// Remaining bytes for prerolling to complete.
- size_t preroll_bytes_;
+ uint32 preroll_bytes_;
DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl);
};
diff --git a/chrome/renderer/media/audio_renderer_impl_unittest.cc b/chrome/renderer/media/audio_renderer_impl_unittest.cc
index 1dda05d..5b823e8 100644
--- a/chrome/renderer/media/audio_renderer_impl_unittest.cc
+++ b/chrome/renderer/media/audio_renderer_impl_unittest.cc
@@ -100,12 +100,12 @@ TEST_F(AudioRendererImplTest, SetVolume) {
TEST_F(AudioRendererImplTest, Stop) {
// Declare some state messages.
- const ViewMsg_AudioStreamState kError =
- { ViewMsg_AudioStreamState::kError };
- const ViewMsg_AudioStreamState kPlaying =
- { ViewMsg_AudioStreamState::kPlaying };
- const ViewMsg_AudioStreamState kPaused =
- { ViewMsg_AudioStreamState::kPaused };
+ const ViewMsg_AudioStreamState_Params kError =
+ { ViewMsg_AudioStreamState_Params::kError };
+ const ViewMsg_AudioStreamState_Params kPlaying =
+ { ViewMsg_AudioStreamState_Params::kPlaying };
+ const ViewMsg_AudioStreamState_Params kPaused =
+ { ViewMsg_AudioStreamState_Params::kPaused };
// Execute Stop() codepath to create an IPC message.
renderer_->Stop();
diff --git a/chrome/renderer/pepper_devices.cc b/chrome/renderer/pepper_devices.cc
index ff39088..3b14d16 100644
--- a/chrome/renderer/pepper_devices.cc
+++ b/chrome/renderer/pepper_devices.cc
@@ -107,7 +107,7 @@ NPError AudioDeviceContext::Initialize(
DCHECK_EQ(0, stream_id_);
stream_id_ = filter_->AddDelegate(this);
- ViewHostMsg_Audio_CreateStream params;
+ ViewHostMsg_Audio_CreateStream_Params params;
params.format = AudioManager::AUDIO_PCM_LINEAR;
params.channels = config->outputChannelMap;
params.sample_rate = config->sampleRate;
@@ -146,18 +146,18 @@ void AudioDeviceContext::OnDestroy() {
}
void AudioDeviceContext::OnRequestPacket(
- size_t bytes_in_buffer, const base::Time& message_timestamp) {
+ uint32 bytes_in_buffer, const base::Time& message_timestamp) {
context_->config.callback(context_);
filter_->Send(new ViewHostMsg_NotifyAudioPacketReady(0, stream_id_,
shared_memory_size_));
}
void AudioDeviceContext::OnStateChanged(
- ViewMsg_AudioStreamState state) {
+ const ViewMsg_AudioStreamState_Params& state) {
}
void AudioDeviceContext::OnCreated(
- base::SharedMemoryHandle handle, size_t length) {
+ base::SharedMemoryHandle handle, uint32 length) {
shared_memory_.reset(new base::SharedMemory(handle, false));
shared_memory_->Map(length);
shared_memory_size_ = length;
diff --git a/chrome/renderer/pepper_devices.h b/chrome/renderer/pepper_devices.h
index 1abd554..31a2d11 100644
--- a/chrome/renderer/pepper_devices.h
+++ b/chrome/renderer/pepper_devices.h
@@ -58,10 +58,10 @@ class AudioDeviceContext : public AudioMessageFilter::Delegate {
NPDeviceContextAudio* context);
// AudioMessageFilter::Delegate implementation
- virtual void OnRequestPacket(size_t bytes_in_buffer,
+ virtual void OnRequestPacket(uint32 bytes_in_buffer,
const base::Time& message_timestamp);
- virtual void OnStateChanged(ViewMsg_AudioStreamState state);
- virtual void OnCreated(base::SharedMemoryHandle handle, size_t length);
+ virtual void OnStateChanged(const ViewMsg_AudioStreamState_Params& state);
+ virtual void OnCreated(base::SharedMemoryHandle handle, uint32 length);
virtual void OnVolume(double volume);
// End of AudioMessageFilter::Delegate implementation
@@ -74,7 +74,7 @@ class AudioDeviceContext : public AudioMessageFilter::Delegate {
scoped_refptr<AudioMessageFilter> filter_;
int32 stream_id_;
scoped_ptr<base::SharedMemory> shared_memory_;
- size_t shared_memory_size_;
+ uint32 shared_memory_size_;
};
#endif // CHROME_RENDERER_PEPPER_DEVICES_H_
diff --git a/media/audio/audio_output.h b/media/audio/audio_output.h
index 2d249d7..6b87a68 100644
--- a/media/audio/audio_output.h
+++ b/media/audio/audio_output.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2008-2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -55,8 +55,8 @@ class AudioOutputStream {
// |dest| is platform and format specific.
// |pending_bytes| is the number of bytes will be played before the
// requested data is played.
- virtual size_t OnMoreData(AudioOutputStream* stream, void* dest,
- size_t max_size, int pending_bytes) = 0;
+ virtual uint32 OnMoreData(AudioOutputStream* stream, void* dest,
+ uint32 max_size, uint32 pending_bytes) = 0;
// The stream is done with this callback. After this call the audio source
// can go away or be destroyed.
@@ -80,7 +80,7 @@ class AudioOutputStream {
//
// TODO(ajwong): Streams are not reusable, so try to move packet_size into the
// constructor.
- virtual bool Open(size_t packet_size) = 0;
+ virtual bool Open(uint32 packet_size) = 0;
// Starts playing audio and generating AudioSourceCallback::OnMoreData().
// Since implementor of AudioOutputStream may have internal buffers, right
@@ -120,11 +120,11 @@ class AudioManager {
};
// Telephone quality sample rate, mostly for speech-only audio.
- static const int kTelephoneSampleRate = 8000;
+ static const uint32 kTelephoneSampleRate = 8000;
// CD sampling rate is 44.1 KHz or conveniently 2x2x3x3x5x5x7x7.
- static const int kAudioCDSampleRate = 44100;
+ static const uint32 kAudioCDSampleRate = 44100;
// Digital Audio Tape sample rate.
- static const int kAudioDATSampleRate = 48000;
+ static const uint32 kAudioDATSampleRate = 48000;
// Returns true if the OS reports existence of audio devices. This does not
// guarantee that the existing devices support all formats and sample rates.
diff --git a/media/audio/fake_audio_output_stream.cc b/media/audio/fake_audio_output_stream.cc
index cd57719..8bfa28e 100644
--- a/media/audio/fake_audio_output_stream.cc
+++ b/media/audio/fake_audio_output_stream.cc
@@ -1,10 +1,11 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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/at_exit.h"
#include "media/audio/fake_audio_output_stream.h"
+#include "base/at_exit.h"
+
bool FakeAudioOutputStream::has_created_fake_stream_ = false;
FakeAudioOutputStream* FakeAudioOutputStream::last_fake_stream_ = NULL;
@@ -22,7 +23,7 @@ FakeAudioOutputStream* FakeAudioOutputStream::GetLastFakeStream() {
return last_fake_stream_;
}
-bool FakeAudioOutputStream::Open(size_t packet_size) {
+bool FakeAudioOutputStream::Open(uint32 packet_size) {
if (packet_size < sizeof(int16))
return false;
packet_size_ = packet_size;
diff --git a/media/audio/fake_audio_output_stream.h b/media/audio/fake_audio_output_stream.h
index 5c7da82..59afec7 100644
--- a/media/audio/fake_audio_output_stream.h
+++ b/media/audio/fake_audio_output_stream.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
//
@@ -19,7 +19,7 @@ class FakeAudioOutputStream : public AudioOutputStream {
static AudioOutputStream* MakeFakeStream();
static FakeAudioOutputStream* GetLastFakeStream();
- virtual bool Open(size_t packet_size);
+ virtual bool Open(uint32 packet_size);
virtual void Start(AudioSourceCallback* callback);
virtual void Stop();
virtual void SetVolume(double volume);
@@ -40,7 +40,7 @@ class FakeAudioOutputStream : public AudioOutputStream {
double volume_;
AudioSourceCallback* callback_;
scoped_array<char> buffer_;
- size_t packet_size_;
+ uint32 packet_size_;
DISALLOW_COPY_AND_ASSIGN(FakeAudioOutputStream);
};
diff --git a/media/audio/linux/alsa_output.cc b/media/audio/linux/alsa_output.cc
index d878a74..8971ca6 100644
--- a/media/audio/linux/alsa_output.cc
+++ b/media/audio/linux/alsa_output.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
//
@@ -86,12 +86,12 @@
// Amount of time to wait if we've exhausted the data source. This is to avoid
// busy looping.
-static const int kNoDataSleepMilliseconds = 10;
+static const uint32 kNoDataSleepMilliseconds = 10;
// According to the linux nanosleep manpage, nanosleep on linux can miss the
// deadline by up to 10ms because the kernel timeslice is 10ms. Give a 2x
// buffer to compensate for the timeslice, and any additional slowdowns.
-static const int kSleepErrorMilliseconds = 20;
+static const uint32 kSleepErrorMilliseconds = 20;
// Set to 0 during debugging if you want error messages due to underrun
// events or other recoverable errors.
@@ -107,14 +107,14 @@ 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 int AlsaPcmOutputStream::kMinLatencyMicros =
+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 kMaxSampleRate = 48000;
+const uint32 kMaxSampleRate = 48000;
snd_pcm_format_t BitsToFormat(char bits_per_sample) {
switch (bits_per_sample) {
@@ -152,7 +152,7 @@ snd_pcm_format_t BitsToFormat(char bits_per_sample) {
// 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(int channels) {
+const char* GuessSpecificDeviceName(uint32 channels) {
switch (channels) {
case 8:
return "surround71";
@@ -177,10 +177,10 @@ const char* GuessSpecificDeviceName(int channels) {
// Reorder PCM from AAC layout to Alsa layout.
// TODO(fbarchard): Switch layout when ffmpeg is updated.
template<class Format>
-static void Swizzle50Layout(Format* b, size_t filled) {
- static const int kNumSurroundChannels = 5;
+static void Swizzle50Layout(Format* b, uint32 filled) {
+ static const uint32 kNumSurroundChannels = 5;
Format aac[kNumSurroundChannels];
- for (size_t i = 0; i < filled; i += sizeof(aac), b += kNumSurroundChannels) {
+ for (uint32 i = 0; i < filled; i += sizeof(aac), b += kNumSurroundChannels) {
memcpy(aac, b, sizeof(aac));
b[0] = aac[1]; // L
b[1] = aac[2]; // R
@@ -191,10 +191,10 @@ static void Swizzle50Layout(Format* b, size_t filled) {
}
template<class Format>
-static void Swizzle51Layout(Format* b, size_t filled) {
- static const int kNumSurroundChannels = 6;
+static void Swizzle51Layout(Format* b, uint32 filled) {
+ static const uint32 kNumSurroundChannels = 6;
Format aac[kNumSurroundChannels];
- for (size_t i = 0; i < filled; i += sizeof(aac), b += kNumSurroundChannels) {
+ for (uint32 i = 0; i < filled; i += sizeof(aac), b += kNumSurroundChannels) {
memcpy(aac, b, sizeof(aac));
b[0] = aac[1]; // L
b[1] = aac[2]; // R
@@ -235,9 +235,9 @@ std::ostream& operator<<(std::ostream& os,
AlsaPcmOutputStream::AlsaPcmOutputStream(const std::string& device_name,
AudioManager::Format format,
- int channels,
- int sample_rate,
- int bits_per_sample,
+ uint32 channels,
+ uint32 sample_rate,
+ uint32 bits_per_sample,
AlsaWrapper* wrapper,
AudioManagerLinux* manager,
MessageLoop* message_loop)
@@ -287,7 +287,7 @@ AlsaPcmOutputStream::~AlsaPcmOutputStream() {
// where the stream is not always stopped and closed, causing this to fail.
}
-bool AlsaPcmOutputStream::Open(size_t packet_size) {
+bool AlsaPcmOutputStream::Open(uint32 packet_size) {
DCHECK_EQ(MessageLoop::current(), client_thread_loop_);
DCHECK_EQ(0U, packet_size % bytes_per_frame_)
@@ -371,7 +371,7 @@ void AlsaPcmOutputStream::GetVolume(double* volume) {
*volume = shared_data_.volume();
}
-void AlsaPcmOutputStream::OpenTask(size_t packet_size) {
+void AlsaPcmOutputStream::OpenTask(uint32 packet_size) {
DCHECK_EQ(MessageLoop::current(), message_loop_);
// Initialize the configuration variables.
@@ -434,8 +434,8 @@ void AlsaPcmOutputStream::StartTask() {
// the maximum number of full packets that can fit into the buffer.
//
// TODO(ajwong): Handle EAGAIN.
- const int num_preroll = latency_micros_ / micros_per_packet_;
- for (int i = 0; i < num_preroll; ++i) {
+ const uint32 num_preroll = latency_micros_ / micros_per_packet_;
+ for (uint32 i = 0; i < num_preroll; ++i) {
BufferPacket(packet_.get());
WritePacket(packet_.get());
}
@@ -621,12 +621,12 @@ void AlsaPcmOutputStream::ScheduleNextWrite(Packet* current_packet) {
// Calculate when we should have enough buffer for another packet of data.
// Make sure to take into consideration down-mixing.
- int frames_leftover =
+ uint32 frames_leftover =
FramesInPacket(*current_packet, bytes_per_output_frame_);
- int frames_avail_wanted =
+ uint32 frames_avail_wanted =
(frames_leftover > 0) ? frames_leftover : frames_per_packet_;
- int frames_until_empty_enough = frames_avail_wanted - GetAvailableFrames();
- int next_fill_time_ms =
+ uint32 frames_until_empty_enough = frames_avail_wanted - GetAvailableFrames();
+ uint32 next_fill_time_ms =
FramesToMillis(frames_until_empty_enough, sample_rate_);
// Adjust for timer resolution issues.
@@ -659,20 +659,20 @@ void AlsaPcmOutputStream::ScheduleNextWrite(Packet* current_packet) {
}
}
-snd_pcm_sframes_t AlsaPcmOutputStream::FramesInPacket(const Packet& packet,
- int bytes_per_frame) {
+uint32 AlsaPcmOutputStream::FramesInPacket(const Packet& packet,
+ uint32 bytes_per_frame) {
return (packet.size - packet.used) / bytes_per_frame;
}
-int64 AlsaPcmOutputStream::FramesToMicros(int frames, int sample_rate) {
+uint32 AlsaPcmOutputStream::FramesToMicros(uint32 frames, uint32 sample_rate) {
return frames * base::Time::kMicrosecondsPerSecond / sample_rate;
}
-int64 AlsaPcmOutputStream::FramesToMillis(int frames, int sample_rate) {
+uint32 AlsaPcmOutputStream::FramesToMillis(uint32 frames, uint32 sample_rate) {
return frames * base::Time::kMillisecondsPerSecond / sample_rate;
}
-std::string AlsaPcmOutputStream::FindDeviceForChannels(int channels) {
+std::string AlsaPcmOutputStream::FindDeviceForChannels(uint32 channels) {
// Constants specified by the ALSA API for device hints.
static const int kGetAllDevices = -1;
static const char kPcmInterfaceName[] = "pcm";
@@ -721,7 +721,7 @@ std::string AlsaPcmOutputStream::FindDeviceForChannels(int channels) {
}
snd_pcm_t* AlsaPcmOutputStream::OpenDevice(const std::string& device_name,
- int channels,
+ uint32 channels,
unsigned int latency) {
snd_pcm_t* handle = NULL;
int error = wrapper_->PcmOpen(&handle, device_name.c_str(),
@@ -822,7 +822,7 @@ snd_pcm_t* AlsaPcmOutputStream::AutoSelectDevice(unsigned int latency) {
// downmixing.
//
// TODO(ajwong): We need a SupportsFolding() function.
- int default_channels = channels_;
+ uint32 default_channels = channels_;
if (default_channels >= 5 && default_channels <= 6) {
should_downmix_ = true;
default_channels = 2;
@@ -921,10 +921,10 @@ void AlsaPcmOutputStream::SharedData::set_volume(float v) {
volume_ = v;
}
-size_t AlsaPcmOutputStream::SharedData::OnMoreData(AudioOutputStream* stream,
+uint32 AlsaPcmOutputStream::SharedData::OnMoreData(AudioOutputStream* stream,
void* dest,
- size_t max_size,
- int pending_bytes) {
+ uint32 max_size,
+ uint32 pending_bytes) {
AutoLock l(lock_);
if (source_callback_) {
return source_callback_->OnMoreData(stream, dest, max_size, pending_bytes);
diff --git a/media/audio/linux/alsa_output.h b/media/audio/linux/alsa_output.h
index 8aa0af3..240076a 100644
--- a/media/audio/linux/alsa_output.h
+++ b/media/audio/linux/alsa_output.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
//
@@ -58,7 +58,7 @@ class AlsaPcmOutputStream :
static const char kPlugPrefix[];
// The minimum latency that is accepted by the device.
- static const int kMinLatencyMicros;
+ static const uint32 kMinLatencyMicros;
// Create a PCM Output stream for the ALSA device identified by
// |device_name|. The AlsaPcmOutputStream uses |wrapper| to communicate with
@@ -69,15 +69,15 @@ class AlsaPcmOutputStream :
// If unsure of what to use for |device_name|, use |kAutoSelectDevice|.
AlsaPcmOutputStream(const std::string& device_name,
AudioManager::Format format,
- int channels,
- int sample_rate,
- int bits_per_sample,
+ uint32 channels,
+ uint32 sample_rate,
+ uint32 bits_per_sample,
AlsaWrapper* wrapper,
AudioManagerLinux* manager,
MessageLoop* message_loop);
// Implementation of AudioOutputStream.
- virtual bool Open(size_t packet_size);
+ virtual bool Open(uint32 packet_size);
virtual void Close();
virtual void Start(AudioSourceCallback* callback);
virtual void Stop();
@@ -112,15 +112,15 @@ class AlsaPcmOutputStream :
// TODO(ajwong): There are now about 3 buffer/packet implementations. Factor
// them out.
struct Packet {
- explicit Packet(int new_capacity)
+ explicit Packet(uint32 new_capacity)
: capacity(new_capacity),
size(0),
used(0),
buffer(new char[capacity]) {
}
- size_t capacity;
- size_t size;
- size_t used;
+ uint32 capacity;
+ uint32 size;
+ uint32 used;
scoped_array<char> buffer;
};
@@ -136,7 +136,7 @@ class AlsaPcmOutputStream :
friend std::ostream& ::operator<<(std::ostream& os, InternalState);
// Various tasks that complete actions started in the public API.
- void OpenTask(size_t packet_size);
+ void OpenTask(uint32 packet_size);
void StartTask();
void CloseTask();
@@ -148,20 +148,19 @@ class AlsaPcmOutputStream :
void ScheduleNextWrite(Packet* current_packet);
// Utility functions for talking with the ALSA API.
- static snd_pcm_sframes_t FramesInPacket(const Packet& packet,
- int bytes_per_frame);
- static int64 FramesToMicros(int frames, int sample_rate);
- static int64 FramesToMillis(int frames, int sample_rate);
- std::string FindDeviceForChannels(int channels);
+ static uint32 FramesInPacket(const Packet& packet, uint32 bytes_per_frame);
+ static uint32 FramesToMicros(uint32 frames, uint32 sample_rate);
+ static uint32 FramesToMillis(uint32 frames, uint32 sample_rate);
+ std::string FindDeviceForChannels(uint32 channels);
snd_pcm_t* OpenDevice(const std::string& device_name,
- int channels,
- unsigned int latency);
+ uint32 channels,
+ uint32 latency);
bool CloseDevice(snd_pcm_t* handle);
snd_pcm_sframes_t GetAvailableFrames();
// Attempts to find the best matching linux audio device for the given number
// of channels. This function will set |device_name_| and |should_downmix_|.
- snd_pcm_t* AutoSelectDevice(unsigned int latency);
+ snd_pcm_t* AutoSelectDevice(uint32 latency);
// Thread-asserting accessors for member variables.
AudioManagerLinux* manager();
@@ -191,8 +190,8 @@ class AlsaPcmOutputStream :
// is passed into the output stream, but ownership is not transfered which
// requires a synchronization on access of the |source_callback_| to avoid
// using a deleted callback.
- size_t OnMoreData(AudioOutputStream* stream, void* dest,
- size_t max_size, int pending_bytes);
+ uint32 OnMoreData(AudioOutputStream* stream, void* dest,
+ uint32 max_size, uint32 pending_bytes);
void OnClose(AudioOutputStream* stream);
void OnError(AudioOutputStream* stream, int code);
@@ -217,17 +216,17 @@ class AlsaPcmOutputStream :
// since they are constants.
const std::string requested_device_name_;
const snd_pcm_format_t pcm_format_;
- const int channels_;
- const int sample_rate_;
- const int bytes_per_sample_;
- const int bytes_per_frame_;
+ const uint32 channels_;
+ const uint32 sample_rate_;
+ const uint32 bytes_per_sample_;
+ const uint32 bytes_per_frame_;
// Device configuration data. Populated after OpenTask() completes.
std::string device_name_;
bool should_downmix_;
- int latency_micros_;
- int micros_per_packet_;
- int bytes_per_output_frame_;
+ uint32 latency_micros_;
+ uint32 micros_per_packet_;
+ uint32 bytes_per_output_frame_;
// Flag indicating the code should stop reading from the data source or
// writing to the ALSA device. This is set because the device has entered
@@ -246,7 +245,7 @@ class AlsaPcmOutputStream :
snd_pcm_t* playback_handle_;
scoped_ptr<Packet> packet_;
- int frames_per_packet_;
+ uint32 frames_per_packet_;
// Used to check which message loop is allowed to call the public APIs.
MessageLoop* client_thread_loop_;
diff --git a/media/audio/linux/alsa_output_unittest.cc b/media/audio/linux/alsa_output_unittest.cc
index b426301..3dcc610 100644
--- a/media/audio/linux/alsa_output_unittest.cc
+++ b/media/audio/linux/alsa_output_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -53,8 +53,8 @@ class MockAlsaWrapper : public AlsaWrapper {
class MockAudioSourceCallback : public AudioOutputStream::AudioSourceCallback {
public:
- MOCK_METHOD4(OnMoreData, size_t(AudioOutputStream* stream, void* dest,
- size_t max_size, int pending_bytes));
+ MOCK_METHOD4(OnMoreData, uint32(AudioOutputStream* stream, void* dest,
+ uint32 max_size, uint32 pending_bytes));
MOCK_METHOD1(OnClose, void(AudioOutputStream* stream));
MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code));
};
@@ -112,8 +112,8 @@ class AlsaPcmOutputStreamTest : public testing::Test {
static const AudioManager::Format kTestFormat;
static const char kTestDeviceName[];
static const char kDummyMessage[];
- static const int kTestFramesPerPacket;
- static const size_t kTestPacketSize;
+ static const uint32 kTestFramesPerPacket;
+ static const uint32 kTestPacketSize;
static const int kTestFailedErrno;
static snd_pcm_t* const kFakeHandle;
@@ -147,8 +147,8 @@ const AudioManager::Format AlsaPcmOutputStreamTest::kTestFormat =
AudioManager::AUDIO_PCM_LINEAR;
const char AlsaPcmOutputStreamTest::kTestDeviceName[] = "TestDevice";
const char AlsaPcmOutputStreamTest::kDummyMessage[] = "dummy";
-const int AlsaPcmOutputStreamTest::kTestFramesPerPacket = 1000;
-const size_t AlsaPcmOutputStreamTest::kTestPacketSize =
+const uint32 AlsaPcmOutputStreamTest::kTestFramesPerPacket = 1000;
+const uint32 AlsaPcmOutputStreamTest::kTestPacketSize =
AlsaPcmOutputStreamTest::kTestFramesPerPacket *
AlsaPcmOutputStreamTest::kTestBytesPerFrame;
const int AlsaPcmOutputStreamTest::kTestFailedErrno = -EACCES;
diff --git a/media/audio/mac/audio_output_mac.cc b/media/audio/mac/audio_output_mac.cc
index 24dc86b..77c34df 100644
--- a/media/audio/mac/audio_output_mac.cc
+++ b/media/audio/mac/audio_output_mac.cc
@@ -1,13 +1,13 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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/audio/mac/audio_manager_mac.h"
#include "media/audio/mac/audio_output_mac.h"
#include "base/basictypes.h"
#include "base/logging.h"
#include "media/audio/audio_util.h"
+#include "media/audio/mac/audio_manager_mac.h"
// Overview of operation:
// 1) An object of PCMQueueOutAudioOutputStream is created by the AudioManager
@@ -78,7 +78,7 @@ void PCMQueueOutAudioOutputStream::HandleError(OSStatus err) {
NOTREACHED() << "error code " << err;
}
-bool PCMQueueOutAudioOutputStream::Open(size_t packet_size) {
+bool PCMQueueOutAudioOutputStream::Open(uint32 packet_size) {
if (0 == packet_size) {
// TODO(cpu) : Impelement default buffer computation.
return false;
@@ -92,7 +92,7 @@ bool PCMQueueOutAudioOutputStream::Open(size_t packet_size) {
return false;
}
// Allocate the hardware-managed buffers.
- for (size_t ix = 0; ix != kNumBuffers; ++ix) {
+ for (uint32 ix = 0; ix != kNumBuffers; ++ix) {
err = AudioQueueAllocateBuffer(audio_queue_, packet_size, &buffer_[ix]);
if (err != noErr) {
HandleError(err);
@@ -113,7 +113,7 @@ void PCMQueueOutAudioOutputStream::Close() {
// might be NULL.
if (audio_queue_) {
OSStatus err = 0;
- for (size_t ix = 0; ix != kNumBuffers; ++ix) {
+ for (uint32 ix = 0; ix != kNumBuffers; ++ix) {
if (buffer_[ix]) {
err = AudioQueueFreeBuffer(audio_queue_, buffer_[ix]);
if (err != noErr) {
@@ -168,10 +168,10 @@ void PCMQueueOutAudioOutputStream::GetVolume(double* volume) {
// TODO(fbarchard): Switch layout when ffmpeg is updated.
namespace {
template<class Format>
-static void SwizzleLayout(Format* b, size_t filled) {
+static void SwizzleLayout(Format* b, uint32 filled) {
static const int kNumSurroundChannels = 6;
Format aac[kNumSurroundChannels];
- for (size_t i = 0; i < filled; i += sizeof(aac), b += kNumSurroundChannels) {
+ for (uint32 i = 0; i < filled; i += sizeof(aac), b += kNumSurroundChannels) {
memcpy(aac, b, sizeof(aac));
b[0] = aac[1]; // L
b[1] = aac[2]; // R
@@ -200,8 +200,8 @@ void PCMQueueOutAudioOutputStream::RenderCallback(void* p_this,
// Adjust the number of pending bytes by subtracting the amount played.
audio_stream->pending_bytes_ -= buffer->mAudioDataByteSize;
- size_t capacity = buffer->mAudioDataBytesCapacity;
- size_t filled = source->OnMoreData(audio_stream, buffer->mAudioData,
+ uint32 capacity = buffer->mAudioDataBytesCapacity;
+ uint32 filled = source->OnMoreData(audio_stream, buffer->mAudioData,
capacity, audio_stream->pending_bytes_);
// In order to keep the callback running, we need to provide a positive amount
@@ -253,12 +253,12 @@ void PCMQueueOutAudioOutputStream::Start(AudioSourceCallback* callback) {
source_ = callback;
pending_bytes_ = 0;
// Ask the source to pre-fill all our buffers before playing.
- for (size_t ix = 0; ix != kNumBuffers; ++ix) {
+ for (uint32 ix = 0; ix != kNumBuffers; ++ix) {
buffer_[ix]->mAudioDataByteSize = 0;
RenderCallback(this, NULL, buffer_[ix]);
}
// Queue the buffers to the audio driver, sounds starts now.
- for (size_t ix = 0; ix != kNumBuffers; ++ix) {
+ for (uint32 ix = 0; ix != kNumBuffers; ++ix) {
err = AudioQueueEnqueueBuffer(audio_queue_, buffer_[ix], 0, NULL);
if (err != noErr) {
HandleError(err);
diff --git a/media/audio/mac/audio_output_mac.h b/media/audio/mac/audio_output_mac.h
index 10fc229..0f58cae 100644
--- a/media/audio/mac/audio_output_mac.h
+++ b/media/audio/mac/audio_output_mac.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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,7 +29,7 @@ class PCMQueueOutAudioOutputStream : public AudioOutputStream {
virtual ~PCMQueueOutAudioOutputStream();
// Implementation of AudioOutputStream.
- virtual bool Open(size_t packet_size);
+ virtual bool Open(uint32 packet_size);
virtual void Close();
virtual void Start(AudioSourceCallback* callback);
virtual void Stop();
@@ -38,7 +38,7 @@ class PCMQueueOutAudioOutputStream : public AudioOutputStream {
private:
// The audio is double buffered.
- static const size_t kNumBuffers = 2;
+ static const uint32 kNumBuffers = 2;
// The OS calls back here when an audio buffer has been processed.
static void RenderCallback(void* p_this, AudioQueueRef queue,
@@ -61,7 +61,7 @@ class PCMQueueOutAudioOutputStream : public AudioOutputStream {
// Volume level from 0 to 1.
float volume_;
// Number of bytes yet to be played in audio buffer.
- int pending_bytes_;
+ uint32 pending_bytes_;
DISALLOW_COPY_AND_ASSIGN(PCMQueueOutAudioOutputStream);
};
diff --git a/media/audio/mac/audio_output_mac_unittest.cc b/media/audio/mac/audio_output_mac_unittest.cc
index 06d7f96..ee589f5 100644
--- a/media/audio/mac/audio_output_mac_unittest.cc
+++ b/media/audio/mac/audio_output_mac_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -19,8 +19,8 @@ using ::testing::Return;
class MockAudioSource : public AudioOutputStream::AudioSourceCallback {
public:
- MOCK_METHOD4(OnMoreData, size_t(AudioOutputStream* stream, void* dest,
- size_t max_size, int pending_bytes));
+ MOCK_METHOD4(OnMoreData, uint32(AudioOutputStream* stream, void* dest,
+ uint32 max_size, uint32 pending_bytes));
MOCK_METHOD1(OnClose, void(AudioOutputStream* stream));
MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code));
};
@@ -28,7 +28,7 @@ class MockAudioSource : public AudioOutputStream::AudioSourceCallback {
// Validate that the SineWaveAudioSource writes the expected values for
// the FORMAT_16BIT_MONO.
TEST(MacAudioTest, SineWaveAudio16MonoTest) {
- const size_t samples = 1024;
+ const uint32 samples = 1024;
const int freq = 200;
SineWaveAudioSource source(SineWaveAudioSource::FORMAT_16BIT_LINEAR_PCM, 1,
@@ -88,7 +88,7 @@ TEST(MacAudioTest, PCMWaveStreamPlay200HzTone44KssMono) {
SineWaveAudioSource source(SineWaveAudioSource::FORMAT_16BIT_LINEAR_PCM, 1,
200.0, AudioManager::kAudioCDSampleRate);
- size_t bytes_100_ms = (AudioManager::kAudioCDSampleRate / 10) * 2;
+ uint32 bytes_100_ms = (AudioManager::kAudioCDSampleRate / 10) * 2;
EXPECT_TRUE(oas->Open(bytes_100_ms));
@@ -121,7 +121,7 @@ TEST(MacAudioTest, PCMWaveStreamPlay200HzTone22KssMono) {
SineWaveAudioSource source(SineWaveAudioSource::FORMAT_16BIT_LINEAR_PCM, 1,
200.0, AudioManager::kAudioCDSampleRate/2);
- size_t bytes_100_ms = (AudioManager::kAudioCDSampleRate / 20) * 2;
+ uint32 bytes_100_ms = (AudioManager::kAudioCDSampleRate / 20) * 2;
EXPECT_TRUE(oas->Open(bytes_100_ms));
oas->Start(&source);
@@ -132,7 +132,7 @@ TEST(MacAudioTest, PCMWaveStreamPlay200HzTone22KssMono) {
// Custom action to clear a memory buffer.
static void ClearBuffer(AudioOutputStream* strea, void* dest,
- size_t max_size, size_t pending_bytes) {
+ uint32 max_size, uint32 pending_bytes) {
memset(dest, 0, max_size);
}
@@ -147,7 +147,7 @@ TEST(MacAudioTest, PCMWaveStreamPendingBytes) {
ASSERT_TRUE(NULL != oas);
NiceMock<MockAudioSource> source;
- size_t bytes_100_ms = (AudioManager::kAudioCDSampleRate / 10) * 2;
+ uint32 bytes_100_ms = (AudioManager::kAudioCDSampleRate / 10) * 2;
EXPECT_TRUE(oas->Open(bytes_100_ms));
// We expect the amount of pending bytes will reaching |bytes_100_ms|
diff --git a/media/audio/simple_sources.cc b/media/audio/simple_sources.cc
index d9b30c7..228057b 100644
--- a/media/audio/simple_sources.cc
+++ b/media/audio/simple_sources.cc
@@ -1,14 +1,15 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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/audio/simple_sources.h"
+
#include <algorithm>
#include <math.h>
#include "base/basictypes.h"
#include "base/logging.h"
#include "media/audio/audio_output.h"
-#include "media/audio/simple_sources.h"
//////////////////////////////////////////////////////////////////////////////
// SineWaveAudioSource implementation.
@@ -25,14 +26,14 @@ SineWaveAudioSource::SineWaveAudioSource(Format format, int channels,
// The implementation could be more efficient if a lookup table is constructed
// but it is efficient enough for our simple needs.
-size_t SineWaveAudioSource::OnMoreData(AudioOutputStream* stream, void* dest,
- size_t max_size, int pending_bytes) {
+uint32 SineWaveAudioSource::OnMoreData(AudioOutputStream* stream, void* dest,
+ uint32 max_size, uint32 pending_bytes) {
const double kTwoPi = 2.0 * 3.141592653589;
double f = freq_ / sample_freq_;
int16* sin_tbl = reinterpret_cast<int16*>(dest);
- size_t len = max_size / sizeof(int16);
+ uint32 len = max_size / sizeof(int16);
// The table is filled with s(t) = 32768*sin(2PI*f*t).
- for (size_t ix = 0; ix != len; ++ix) {
+ for (uint32 ix = 0; ix != len; ++ix) {
double th = kTwoPi * ix * f;
sin_tbl[ix] = static_cast<int16>((1 << 15) * sin(th));
}
@@ -49,7 +50,7 @@ void SineWaveAudioSource::OnError(AudioOutputStream* stream, int code) {
//////////////////////////////////////////////////////////////////////////////
// PushSource implementation.
-PushSource::PushSource(size_t packet_size)
+PushSource::PushSource(uint32 packet_size)
: packet_size_(packet_size),
buffered_bytes_(0),
front_buffer_consumed_(0) {
@@ -59,9 +60,9 @@ PushSource::~PushSource() {
CleanUp();
}
-size_t PushSource::OnMoreData(AudioOutputStream* stream, void* dest,
- size_t max_size, int pending_bytes) {
- size_t copied = 0;
+uint32 PushSource::OnMoreData(AudioOutputStream* stream, void* dest,
+ uint32 max_size, uint32 pending_bytes) {
+ uint32 copied = 0;
while (copied < max_size) {
AutoLock auto_lock(lock_);
@@ -69,7 +70,7 @@ size_t PushSource::OnMoreData(AudioOutputStream* stream, void* dest,
if (!packets_.size())
break;
Packet packet = packets_.front();
- size_t size = std::min(max_size - copied,
+ uint32 size = std::min(max_size - copied,
packet.size - front_buffer_consumed_);
memcpy(static_cast<char*>(dest) + copied,
packet.buffer + front_buffer_consumed_,
@@ -95,7 +96,7 @@ void PushSource::OnError(AudioOutputStream* stream, int code) {
}
// TODO(cpu): Manage arbitrary large sizes.
-bool PushSource::Write(const void *data, size_t len) {
+bool PushSource::Write(const void *data, uint32 len) {
if (len == 0) {
NOTREACHED();
return false;
@@ -109,7 +110,7 @@ bool PushSource::Write(const void *data, size_t len) {
return true;
}
-size_t PushSource::UnProcessedBytes() {
+uint32 PushSource::UnProcessedBytes() {
AutoLock auto_lock(lock_);
return buffered_bytes_;
}
diff --git a/media/audio/simple_sources.h b/media/audio/simple_sources.h
index d43fcdf..9d0619f 100644
--- a/media/audio/simple_sources.h
+++ b/media/audio/simple_sources.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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,8 +25,8 @@ class SineWaveAudioSource : public AudioOutputStream::AudioSourceCallback {
virtual ~SineWaveAudioSource() {}
// Implementation of AudioSourceCallback.
- virtual size_t OnMoreData(AudioOutputStream* stream,
- void* dest, size_t max_size, int pending_bytes);
+ virtual uint32 OnMoreData(AudioOutputStream* stream,
+ void* dest, uint32 max_size, uint32 pending_bytes);
virtual void OnClose(AudioOutputStream* stream);
virtual void OnError(AudioOutputStream* stream, int code);
@@ -45,11 +45,11 @@ class PushAudioOutput {
// Write audio data to the audio device. It will be played eventually.
// Returns false on failure.
- virtual bool Write(const void* data, size_t len) = 0;
+ virtual bool Write(const void* data, uint32 len) = 0;
// Returns the number of bytes that have been buffered but not yet given
// to the audio device.
- virtual size_t UnProcessedBytes() = 0;
+ virtual uint32 UnProcessedBytes() = 0;
};
// A fairly basic class to connect a push model provider PushAudioOutput to
@@ -61,19 +61,19 @@ class PushSource : public AudioOutputStream::AudioSourceCallback,
// Construct the audio source. Pass the same |packet_size| specified in the
// AudioOutputStream::Open() here.
// TODO(hclam): |packet_size| is not used anymore, remove it.
- explicit PushSource(size_t packet_size);
+ explicit PushSource(uint32 packet_size);
virtual ~PushSource();
// Write one buffer. The ideal size is |packet_size| but smaller sizes are
// accepted.
- virtual bool Write(const void* data, size_t len);
+ virtual bool Write(const void* data, uint32 len);
// Return the total number of bytes not given to the audio device yet.
- virtual size_t UnProcessedBytes();
+ virtual uint32 UnProcessedBytes();
// Implementation of AudioSourceCallback.
- virtual size_t OnMoreData(AudioOutputStream* stream,
- void* dest, size_t max_size, int pending_bytes);
+ virtual uint32 OnMoreData(AudioOutputStream* stream,
+ void* dest, uint32 max_size, uint32 pending_bytes);
virtual void OnClose(AudioOutputStream* stream);
virtual void OnError(AudioOutputStream* stream, int code);
@@ -81,17 +81,17 @@ class PushSource : public AudioOutputStream::AudioSourceCallback,
// Defines the unit of playback. We own the memory pointed by |buffer|.
struct Packet {
char* buffer;
- size_t size;
+ uint32 size;
};
// Free acquired resources.
void CleanUp();
- const size_t packet_size_;
+ const uint32 packet_size_;
typedef std::list<Packet> PacketList;
PacketList packets_;
- size_t buffered_bytes_;
- size_t front_buffer_consumed_;
+ uint32 buffered_bytes_;
+ uint32 front_buffer_consumed_;
// Serialize access to packets_ and buffered_bytes_ using this lock.
Lock lock_;
};
diff --git a/media/audio/simple_sources_unittest.cc b/media/audio/simple_sources_unittest.cc
index 51eb8db..6436170 100644
--- a/media/audio/simple_sources_unittest.cc
+++ b/media/audio/simple_sources_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -12,7 +12,7 @@
namespace {
-void GenerateRandomData(char* buffer, size_t len) {
+void GenerateRandomData(char* buffer, uint32 len) {
static bool called = false;
if (!called) {
called = true;
@@ -21,7 +21,7 @@ void GenerateRandomData(char* buffer, size_t len) {
LOG(INFO) << "Random seed: " << seed;
}
- for (size_t i = 0; i < len; i++) {
+ for (uint32 i = 0; i < len; i++) {
buffer[i] = static_cast<char>(rand());
}
}
@@ -30,13 +30,13 @@ void GenerateRandomData(char* buffer, size_t len) {
// To test write size smaller than read size.
TEST(SimpleSourcesTest, PushSourceSmallerWrite) {
- const size_t kDataSize = 40960;
+ const uint32 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;
+ const uint32 kWriteSize = 283;
+ const uint32 kReadSize = 293;
scoped_array<char> read_data(new char[kReadSize]);
// Create a PushSource that assumes the hardware audio buffer size is always
@@ -45,15 +45,15 @@ TEST(SimpleSourcesTest, PushSourceSmallerWrite) {
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);
+ for (uint32 i = 0; i < kDataSize; i += kWriteSize) {
+ uint32 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);
+ for (uint32 i = 0; i < kDataSize; i += kReadSize) {
+ uint32 size = std::min(kDataSize - i , kReadSize);
EXPECT_EQ(size, push_source.OnMoreData(NULL, read_data.get(), size, 0));
EXPECT_EQ(0, memcmp(data.get() + i, read_data.get(), size));
}
@@ -67,8 +67,8 @@ TEST(SimpleSourcesTest, PushSourceSmallerWrite) {
// do not affect the result. We also test that AudioManager::GetLastMockBuffer
// works.
TEST(SimpleSources, SineWaveAudio16MonoTest) {
- const size_t samples = 1024;
- const size_t bytes_per_sample = 2;
+ const uint32 samples = 1024;
+ const uint32 bytes_per_sample = 2;
const int freq = 200;
SineWaveAudioSource source(SineWaveAudioSource::FORMAT_16BIT_LINEAR_PCM, 1,
@@ -93,7 +93,7 @@ TEST(SimpleSources, SineWaveAudio16MonoTest) {
FakeAudioOutputStream::GetLastFakeStream()->buffer());
ASSERT_TRUE(NULL != last_buffer);
- size_t half_period = AudioManager::kTelephoneSampleRate / (freq * 2);
+ uint32 half_period = AudioManager::kTelephoneSampleRate / (freq * 2);
// Spot test positive incursion of sine wave.
EXPECT_EQ(0, last_buffer[0]);
diff --git a/media/audio/win/audio_output_win_unittest.cc b/media/audio/win/audio_output_win_unittest.cc
index 70e9329..0bb18a2 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) 2006-2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -38,8 +38,8 @@ class TestSourceBasic : public AudioOutputStream::AudioSourceCallback {
was_closed_(0) {
}
// AudioSourceCallback::OnMoreData implementation:
- virtual size_t OnMoreData(AudioOutputStream* stream,
- void* dest, size_t max_size, int pending_bytes) {
+ virtual uint32 OnMoreData(AudioOutputStream* stream,
+ void* dest, uint32 max_size, uint32 pending_bytes) {
++callback_count_;
// Touch the first byte to make sure memory is good.
if (max_size)
@@ -94,8 +94,8 @@ class TestSourceTripleBuffer : public TestSourceBasic {
buffer_address_[2] = NULL;
}
// Override of TestSourceBasic::OnMoreData.
- virtual size_t OnMoreData(AudioOutputStream* stream,
- void* dest, size_t max_size, int pending_bytes) {
+ virtual uint32 OnMoreData(AudioOutputStream* stream,
+ void* dest, uint32 max_size, uint32 pending_bytes) {
// Call the base, which increments the callback_count_.
TestSourceBasic::OnMoreData(stream, dest, max_size, 0);
if (callback_count() % kNumBuffers == 2) {
@@ -113,7 +113,7 @@ class TestSourceTripleBuffer : public TestSourceBasic {
}
private:
- bool CompareExistingIfNotNULL(size_t index, void* address) {
+ bool CompareExistingIfNotNULL(uint32 index, void* address) {
void*& entry = buffer_address_[index];
if (!entry)
entry = address;
@@ -130,8 +130,8 @@ class TestSourceLaggy : public TestSourceBasic {
TestSourceLaggy(int laggy_after_buffer, int lag_in_ms)
: laggy_after_buffer_(laggy_after_buffer), lag_in_ms_(lag_in_ms) {
}
- virtual size_t OnMoreData(AudioOutputStream* stream,
- void* dest, size_t max_size, int pending_bytes) {
+ virtual uint32 OnMoreData(AudioOutputStream* stream,
+ void* dest, uint32 max_size, uint32 pending_bytes) {
// Call the base, which increments the callback_count_.
TestSourceBasic::OnMoreData(stream, dest, max_size, 0);
if (callback_count() > kNumBuffers) {
@@ -146,8 +146,8 @@ class TestSourceLaggy : public TestSourceBasic {
class MockAudioSource : public AudioOutputStream::AudioSourceCallback {
public:
- MOCK_METHOD4(OnMoreData, size_t(AudioOutputStream* stream, void* dest,
- size_t max_size, int pending_bytes));
+ MOCK_METHOD4(OnMoreData, uint32(AudioOutputStream* stream, void* dest,
+ uint32 max_size, uint32 pending_bytes));
MOCK_METHOD1(OnClose, void(AudioOutputStream* stream));
MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code));
};
@@ -186,18 +186,18 @@ class ReadOnlyMappedFile {
return ((start_ > 0) && (size_ > 0));
}
// Returns the size in bytes of the mapped memory.
- size_t size() const {
+ uint32 size() const {
return size_;
}
// Returns the memory backing the file.
- const void* GetChunkAt(size_t offset) {
+ const void* GetChunkAt(uint32 offset) {
return &start_[offset];
}
private:
HANDLE fmap_;
char* start_;
- size_t size_;
+ uint32 size_;
};
// ============================================================================
@@ -353,7 +353,7 @@ TEST(WinAudioTest, PCMWaveStreamPlaySlowLoop) {
SineWaveAudioSource source(SineWaveAudioSource::FORMAT_16BIT_LINEAR_PCM, 1,
200.0, AudioManager::kAudioCDSampleRate);
- size_t bytes_100_ms = (AudioManager::kAudioCDSampleRate / 10) * 2;
+ uint32 bytes_100_ms = (AudioManager::kAudioCDSampleRate / 10) * 2;
EXPECT_TRUE(oas->Open(bytes_100_ms));
oas->SetVolume(1.0);
@@ -384,7 +384,7 @@ TEST(WinAudioTest, PCMWaveStreamPlay200HzTone44Kss) {
SineWaveAudioSource source(SineWaveAudioSource::FORMAT_16BIT_LINEAR_PCM, 1,
200.0, AudioManager::kAudioCDSampleRate);
- size_t bytes_100_ms = (AudioManager::kAudioCDSampleRate / 10) * 2;
+ uint32 bytes_100_ms = (AudioManager::kAudioCDSampleRate / 10) * 2;
EXPECT_TRUE(oas->Open(bytes_100_ms));
oas->SetVolume(1.0);
@@ -412,7 +412,7 @@ TEST(WinAudioTest, PCMWaveStreamPlay200HzTone22Kss) {
SineWaveAudioSource source(SineWaveAudioSource::FORMAT_16BIT_LINEAR_PCM, 1,
200.0, AudioManager::kAudioCDSampleRate/2);
- size_t bytes_100_ms = (AudioManager::kAudioCDSampleRate / 20) * 2;
+ uint32 bytes_100_ms = (AudioManager::kAudioCDSampleRate / 20) * 2;
EXPECT_TRUE(oas->Open(bytes_100_ms));
@@ -456,17 +456,17 @@ TEST(WinAudioTest, PushSourceFile16KHz) {
ASSERT_TRUE(NULL != oas);
// compute buffer size for 100ms of audio. Which is 3200 bytes.
- const size_t kSize50ms = 2 * (16000 / 1000) * 100;
+ const uint32 kSize50ms = 2 * (16000 / 1000) * 100;
EXPECT_TRUE(oas->Open(kSize50ms));
- size_t offset = 0;
- const size_t kMaxStartOffset = file_reader.size() - kSize50ms;
+ uint32 offset = 0;
+ const uint32 kMaxStartOffset = file_reader.size() - kSize50ms;
// We buffer and play at the same time, buffering happens every ~10ms and the
// consuming of the buffer happens every ~50ms. We do 100 buffers which
// effectively wrap around the file more than once.
PushSource push_source(kSize50ms);
- for (size_t ix = 0; ix != 100; ++ix) {
+ for (uint32 ix = 0; ix != 100; ++ix) {
push_source.Write(file_reader.GetChunkAt(offset), kSize50ms);
if (ix == 2) {
// For glitch free, start playing after some buffers are in.
@@ -502,7 +502,7 @@ TEST(WinAudioTest, PCMWaveStreamPlayTwice200HzTone44Kss) {
SineWaveAudioSource source(SineWaveAudioSource::FORMAT_16BIT_LINEAR_PCM, 1,
200.0, AudioManager::kAudioCDSampleRate);
- size_t bytes_100_ms = (AudioManager::kAudioCDSampleRate / 10) * 2;
+ uint32 bytes_100_ms = (AudioManager::kAudioCDSampleRate / 10) * 2;
EXPECT_TRUE(oas->Open(bytes_100_ms));
oas->SetVolume(1.0);
@@ -541,7 +541,7 @@ TEST(WinAudioTest, PCMWaveStreamPlay200HzTone44KssLowLatency) {
SineWaveAudioSource source(SineWaveAudioSource::FORMAT_16BIT_LINEAR_PCM, 1,
200.0, AudioManager::kAudioCDSampleRate);
- size_t bytes_50_ms = (AudioManager::kAudioCDSampleRate / 20) * sizeof(uint16);
+ uint32 bytes_50_ms = (AudioManager::kAudioCDSampleRate / 20) * sizeof(uint16);
EXPECT_TRUE(oas->Open(bytes_50_ms));
oas->SetVolume(1.0);
@@ -567,7 +567,7 @@ TEST(WinAudioTest, PCMWaveStreamPendingBytes) {
ASSERT_TRUE(NULL != oas);
NiceMock<MockAudioSource> source;
- size_t bytes_100_ms = (AudioManager::kAudioCDSampleRate / 10) * 2;
+ uint32 bytes_100_ms = (AudioManager::kAudioCDSampleRate / 10) * 2;
EXPECT_TRUE(oas->Open(bytes_100_ms));
// We expect the amount of pending bytes will reaching 2 times of
@@ -610,10 +610,10 @@ class SyncSocketSource : public AudioOutputStream::AudioSourceCallback {
}
// AudioSourceCallback::OnMoreData implementation:
- virtual size_t OnMoreData(AudioOutputStream* stream,
- void* dest, size_t max_size, int pending_bytes) {
+ virtual uint32 OnMoreData(AudioOutputStream* stream,
+ void* dest, uint32 max_size, uint32 pending_bytes) {
socket_->Send(&pending_bytes, sizeof(pending_bytes));
- size_t got = socket_->Receive(dest, max_size);
+ uint32 got = socket_->Receive(dest, max_size);
return got;
}
// AudioSourceCallback::OnClose implementation:
@@ -631,7 +631,7 @@ struct SyncThreadContext {
base::SyncSocket* socket;
int sample_rate;
double sine_freq;
- size_t packet_size;
+ uint32 packet_size;
};
// This thread provides the data that the SyncSocketSource above needs
@@ -688,7 +688,7 @@ TEST(WinAudioTest, SyncSocketBasic) {
ASSERT_TRUE(NULL != oas);
// compute buffer size for 20ms of audio, 882 samples (mono).
- const size_t kSamples20ms = sample_rate / 50 * sizeof(uint16);
+ const uint32 kSamples20ms = sample_rate / 50 * sizeof(uint16);
ASSERT_TRUE(oas->Open(kSamples20ms));
base::SyncSocket* sockets[2];
diff --git a/media/audio/win/waveout_output_win.cc b/media/audio/win/waveout_output_win.cc
index e0fdd1e..59f4c1c 100644
--- a/media/audio/win/waveout_output_win.cc
+++ b/media/audio/win/waveout_output_win.cc
@@ -1,13 +1,13 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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/audio/win/waveout_output_win.h"
+
#include <windows.h>
#include <mmsystem.h>
#pragma comment(lib, "winmm.lib")
-#include "media/audio/win/waveout_output_win.h"
-
#include "base/basictypes.h"
#include "base/logging.h"
#include "media/audio/audio_output.h"
@@ -31,7 +31,7 @@
namespace {
// Sixty four MB is the maximum buffer size per AudioOutputStream.
-const size_t kMaxOpenBufferSize = 1024 * 1024 * 64;
+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.
@@ -71,7 +71,7 @@ PCMWaveOutAudioOutputStream::~PCMWaveOutAudioOutputStream() {
DCHECK(NULL == waveout_);
}
-bool PCMWaveOutAudioOutputStream::Open(size_t buffer_size) {
+bool PCMWaveOutAudioOutputStream::Open(uint32 buffer_size) {
if (state_ != PCMA_BRAND_NEW)
return false;
if (buffer_size > kMaxOpenBufferSize)
@@ -96,11 +96,11 @@ bool PCMWaveOutAudioOutputStream::Open(size_t buffer_size) {
return true;
}
-void PCMWaveOutAudioOutputStream::SetupBuffers(size_t rq_size) {
+void PCMWaveOutAudioOutputStream::SetupBuffers(uint32 rq_size) {
WAVEHDR* last = NULL;
WAVEHDR* first = NULL;
for (int ix = 0; ix != num_buffers_; ++ix) {
- size_t sz = sizeof(WAVEHDR) + rq_size;
+ uint32 sz = sizeof(WAVEHDR) + rq_size;
buffer_ = reinterpret_cast<WAVEHDR*>(new char[sz]);
buffer_->lpData = reinterpret_cast<char*>(buffer_) + sizeof(WAVEHDR);
buffer_->dwBufferLength = rq_size;
@@ -235,8 +235,8 @@ void PCMWaveOutAudioOutputStream::QueueNextPacket(WAVEHDR *buffer) {
// If we are down sampling to a smaller number of channels, we need to
// scale up the amount of pending bytes.
// TODO(fbarchard): Handle used 0 by queueing more.
- int scaled_pending_bytes = pending_bytes_ * channels_ / format_.nChannels;
- size_t used = callback_->OnMoreData(this, buffer->lpData, buffer_size_,
+ uint32 scaled_pending_bytes = pending_bytes_ * channels_ / format_.nChannels;
+ uint32 used = callback_->OnMoreData(this, buffer->lpData, buffer_size_,
scaled_pending_bytes);
if (used <= buffer_size_) {
buffer->dwBufferLength = used * format_.nChannels / channels_;
diff --git a/media/audio/win/waveout_output_win.h b/media/audio/win/waveout_output_win.h
index d587c8c..df35542 100644
--- a/media/audio/win/waveout_output_win.h
+++ b/media/audio/win/waveout_output_win.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -34,7 +34,7 @@ class PCMWaveOutAudioOutputStream : public AudioOutputStream {
virtual ~PCMWaveOutAudioOutputStream();
// Implementation of AudioOutputStream.
- virtual bool Open(size_t packet_size);
+ virtual bool Open(uint32 packet_size);
virtual void Close();
virtual void Start(AudioSourceCallback* callback);
virtual void Stop();
@@ -64,7 +64,7 @@ class PCMWaveOutAudioOutputStream : public AudioOutputStream {
void HandleError(MMRESULT error);
// Allocates and prepares the memory that will be used for playback. Only
// two buffers are created.
- void SetupBuffers(size_t rq_size);
+ void SetupBuffers(uint32 rq_size);
// Deallocates the memory allocated in SetupBuffers.
void FreeBuffers();
@@ -84,7 +84,7 @@ class PCMWaveOutAudioOutputStream : public AudioOutputStream {
const int num_buffers_;
// The size in bytes of each audio buffer, we usually have two of these.
- size_t buffer_size_;
+ uint32 buffer_size_;
// Volume level from 0 to 1.
float volume_;
@@ -93,7 +93,7 @@ class PCMWaveOutAudioOutputStream : public AudioOutputStream {
const int channels_;
// Number of bytes yet to be played in the hardware buffer.
- int pending_bytes_;
+ uint32 pending_bytes_;
// The id assigned by the operating system to the selected wave output
// hardware device. Usually this is just -1 which means 'default device'.
diff --git a/media/filters/audio_renderer_algorithm_base.cc b/media/filters/audio_renderer_algorithm_base.cc
index be28537..fe6131c 100644
--- a/media/filters/audio_renderer_algorithm_base.cc
+++ b/media/filters/audio_renderer_algorithm_base.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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,7 +11,7 @@ namespace media {
// The size in bytes we try to maintain for the |queue_|. Previous usage
// maintained a deque of 16 Buffers, each of size 4Kb. This worked well, so we
// maintain this number of bytes (16 * 4096).
-const size_t kDefaultMinQueueSizeInBytes = 65536;
+const uint32 kDefaultMinQueueSizeInBytes = 65536;
AudioRendererAlgorithmBase::AudioRendererAlgorithmBase()
: channels_(0),
@@ -82,18 +82,18 @@ bool AudioRendererAlgorithmBase::IsQueueFull() {
return (queue_.SizeInBytes() >= kDefaultMinQueueSizeInBytes);
}
-size_t AudioRendererAlgorithmBase::QueueSize() {
+uint32 AudioRendererAlgorithmBase::QueueSize() {
return queue_.SizeInBytes();
}
-void AudioRendererAlgorithmBase::AdvanceInputPosition(size_t bytes) {
+void AudioRendererAlgorithmBase::AdvanceInputPosition(uint32 bytes) {
queue_.Consume(bytes);
if (!IsQueueFull())
request_read_callback_->Run();
}
-size_t AudioRendererAlgorithmBase::CopyFromInput(uint8* dest, size_t bytes) {
+uint32 AudioRendererAlgorithmBase::CopyFromInput(uint8* dest, uint32 bytes) {
return queue_.Copy(dest, bytes);
}
diff --git a/media/filters/audio_renderer_algorithm_base.h b/media/filters/audio_renderer_algorithm_base.h
index 8822de5..6ad1c6d 100644
--- a/media/filters/audio_renderer_algorithm_base.h
+++ b/media/filters/audio_renderer_algorithm_base.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -52,7 +52,7 @@ class AudioRendererAlgorithmBase {
// Implement this strategy method in derived classes. Tries to fill |length|
// bytes of |dest| with possibly scaled data from our |queue_|. Returns the
// number of bytes copied into |dest|.
- virtual size_t FillBuffer(uint8* dest, size_t length) = 0;
+ virtual uint32 FillBuffer(uint8* dest, uint32 length) = 0;
// Clears |queue_|.
virtual void FlushBuffers();
@@ -75,15 +75,15 @@ class AudioRendererAlgorithmBase {
virtual bool IsQueueFull();
// Returns the number of bytes left in |queue_|.
- virtual size_t QueueSize();
+ virtual uint32 QueueSize();
protected:
// Advances |queue_|'s internal pointer by |bytes|.
- void AdvanceInputPosition(size_t bytes);
+ void AdvanceInputPosition(uint32 bytes);
// Tries to copy |bytes| bytes from |queue_| to |dest|. Returns the number of
// bytes successfully copied.
- size_t CopyFromInput(uint8* dest, size_t bytes);
+ uint32 CopyFromInput(uint8* dest, uint32 bytes);
// Number of audio channels.
virtual int channels();
diff --git a/media/filters/audio_renderer_algorithm_default.cc b/media/filters/audio_renderer_algorithm_default.cc
index b0ada26..7ebc10e 100644
--- a/media/filters/audio_renderer_algorithm_default.cc
+++ b/media/filters/audio_renderer_algorithm_default.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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 @@ AudioRendererAlgorithmDefault::AudioRendererAlgorithmDefault() {
AudioRendererAlgorithmDefault::~AudioRendererAlgorithmDefault() {
}
-size_t AudioRendererAlgorithmDefault::FillBuffer(uint8* dest, size_t length) {
+uint32 AudioRendererAlgorithmDefault::FillBuffer(uint8* dest, uint32 length) {
if (playback_rate() == 0.0f) {
return 0;
}
- size_t dest_written = 0;
+ uint32 dest_written = 0;
if (playback_rate() == 1.0f) {
// If we don't have enough data, copy what we have.
@@ -35,8 +35,8 @@ size_t AudioRendererAlgorithmDefault::FillBuffer(uint8* dest, size_t length) {
memset(dest, 0, dest_written);
// Calculate the number of bytes we "used".
- size_t scaled_dest_length =
- static_cast<size_t>(dest_written * playback_rate());
+ uint32 scaled_dest_length =
+ static_cast<uint32>(dest_written * playback_rate());
// If this is more than we have, report the correct amount consumed.
if (QueueSize() < scaled_dest_length) {
diff --git a/media/filters/audio_renderer_algorithm_default.h b/media/filters/audio_renderer_algorithm_default.h
index a796ba7..510df8b 100644
--- a/media/filters/audio_renderer_algorithm_default.h
+++ b/media/filters/audio_renderer_algorithm_default.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -20,7 +20,7 @@ class AudioRendererAlgorithmDefault : public AudioRendererAlgorithmBase {
virtual ~AudioRendererAlgorithmDefault();
// AudioRendererAlgorithmBase implementation
- virtual size_t FillBuffer(uint8* dest, size_t length);
+ virtual uint32 FillBuffer(uint8* dest, uint32 length);
private:
DISALLOW_COPY_AND_ASSIGN(AudioRendererAlgorithmDefault);
diff --git a/media/filters/audio_renderer_algorithm_ola.cc b/media/filters/audio_renderer_algorithm_ola.cc
index 63c3868..d393c59 100644
--- a/media/filters/audio_renderer_algorithm_ola.cc
+++ b/media/filters/audio_renderer_algorithm_ola.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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,13 +29,13 @@ AudioRendererAlgorithmOLA::AudioRendererAlgorithmOLA()
AudioRendererAlgorithmOLA::~AudioRendererAlgorithmOLA() {
}
-size_t AudioRendererAlgorithmOLA::FillBuffer(uint8* dest, size_t length) {
+uint32 AudioRendererAlgorithmOLA::FillBuffer(uint8* dest, uint32 length) {
if (IsQueueEmpty())
return 0;
if (playback_rate() == 0.0f)
return 0;
- size_t dest_written = 0;
+ uint32 dest_written = 0;
// Handle the simple case of normal playback.
if (playback_rate() == 1.0f) {
@@ -61,15 +61,15 @@ size_t AudioRendererAlgorithmOLA::FillBuffer(uint8* dest, size_t length) {
QueueSize() < window_size_) {
// Calculate the ideal input/output steps based on the size of the
// destination buffer.
- size_t input_step = static_cast<size_t>(ceil(
+ uint32 input_step = static_cast<uint32>(ceil(
static_cast<float>(length * playback_rate())));
- size_t output_step = length;
+ uint32 output_step = length;
// If the ideal size is too big, recalculate based on how much is left in
// the queue.
if (input_step > QueueSize()) {
input_step = QueueSize();
- output_step = static_cast<size_t>(ceil(
+ output_step = static_cast<uint32>(ceil(
static_cast<float>(input_step / playback_rate())));
}
@@ -98,7 +98,7 @@ size_t AudioRendererAlgorithmOLA::FillBuffer(uint8* dest, size_t length) {
// Copy bulk of data to output (including some to crossfade to the next
// copy), then add to our running sum of written data and subtract from
// our tally of remaining requested.
- size_t copied = CopyFromInput(dest, output_step_ + crossfade_size_);
+ uint32 copied = CopyFromInput(dest, output_step_ + crossfade_size_);
dest_written += copied;
length -= copied;
@@ -107,7 +107,7 @@ size_t AudioRendererAlgorithmOLA::FillBuffer(uint8* dest, size_t length) {
AdvanceInputPosition(input_step_);
// Prepare intermediate buffer.
- size_t crossfade_size;
+ uint32 crossfade_size;
scoped_array<uint8> src(new uint8[crossfade_size_]);
crossfade_size = CopyFromInput(src.get(), crossfade_size_);
@@ -145,7 +145,7 @@ void AudioRendererAlgorithmOLA::set_playback_rate(float new_rate) {
// Calculate the window size from our default length and our audio properties.
// Precision is not an issue because we will round this to a sample boundary.
// This will not overflow because each parameter is checked in Initialize().
- window_size_ = static_cast<size_t>(sample_rate()
+ window_size_ = static_cast<uint32>(sample_rate()
* sample_bytes()
* channels()
* kDefaultWindowLength);
@@ -153,10 +153,10 @@ void AudioRendererAlgorithmOLA::set_playback_rate(float new_rate) {
// Adjusting step sizes to accommodate requested playback rate.
if (playback_rate() > 1.0f) {
input_step_ = window_size_;
- output_step_ = static_cast<size_t>(ceil(
+ output_step_ = static_cast<uint32>(ceil(
static_cast<float>(window_size_ / playback_rate())));
} else {
- input_step_ = static_cast<size_t>(ceil(
+ input_step_ = static_cast<uint32>(ceil(
static_cast<float>(window_size_ * playback_rate())));
output_step_ = window_size_;
}
@@ -164,7 +164,7 @@ void AudioRendererAlgorithmOLA::set_playback_rate(float new_rate) {
AlignToSampleBoundary(&output_step_);
// Calculate length for crossfading.
- crossfade_size_ = static_cast<size_t>(sample_rate()
+ crossfade_size_ = static_cast<uint32>(sample_rate()
* sample_bytes()
* channels()
* kDefaultCrossfadeLength);
@@ -179,7 +179,7 @@ void AudioRendererAlgorithmOLA::set_playback_rate(float new_rate) {
output_step_ -= crossfade_size_;
}
-void AudioRendererAlgorithmOLA::AlignToSampleBoundary(size_t* value) {
+void AudioRendererAlgorithmOLA::AlignToSampleBoundary(uint32* value) {
(*value) -= ((*value) % (channels() * sample_bytes()));
}
diff --git a/media/filters/audio_renderer_algorithm_ola.h b/media/filters/audio_renderer_algorithm_ola.h
index 5987ce8..0dff39f 100644
--- a/media/filters/audio_renderer_algorithm_ola.h
+++ b/media/filters/audio_renderer_algorithm_ola.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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,7 +25,7 @@ class AudioRendererAlgorithmOLA : public AudioRendererAlgorithmBase {
virtual ~AudioRendererAlgorithmOLA();
// AudioRendererAlgorithmBase implementation
- virtual size_t FillBuffer(uint8* dest, size_t length);
+ virtual uint32 FillBuffer(uint8* dest, uint32 length);
virtual void set_playback_rate(float new_rate);
@@ -36,7 +36,7 @@ class AudioRendererAlgorithmOLA : public AudioRendererAlgorithmBase {
FRIEND_TEST(AudioRendererAlgorithmOLATest, FillBuffer_QuarterRate);
// Aligns |value| to a channel and sample boundary.
- void AlignToSampleBoundary(size_t* value);
+ void AlignToSampleBoundary(uint32* value);
// Crossfades |samples| samples of |dest| with the data in |src|. Assumes
// there is room in |dest| and enough data in |src|. Type is the datatype
@@ -48,14 +48,14 @@ class AudioRendererAlgorithmOLA : public AudioRendererAlgorithmBase {
// Members for ease of calculation in FillBuffer(). These members are based
// on |playback_rate_|, but are stored separately so they don't have to be
// recalculated on every call to FillBuffer().
- size_t input_step_;
- size_t output_step_;
+ uint32 input_step_;
+ uint32 output_step_;
// Length for crossfade in bytes.
- size_t crossfade_size_;
+ uint32 crossfade_size_;
// Window size, in bytes (calculated from audio properties).
- size_t window_size_;
+ uint32 window_size_;
DISALLOW_COPY_AND_ASSIGN(AudioRendererAlgorithmOLA);
};
diff --git a/media/filters/audio_renderer_base.cc b/media/filters/audio_renderer_base.cc
index 4ec7403..c141803 100644
--- a/media/filters/audio_renderer_base.cc
+++ b/media/filters/audio_renderer_base.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -165,8 +165,8 @@ void AudioRendererBase::OnReadComplete(Buffer* buffer_in) {
}
}
-size_t AudioRendererBase::FillBuffer(uint8* dest,
- size_t dest_len,
+uint32 AudioRendererBase::FillBuffer(uint8* dest,
+ uint32 dest_len,
const base::TimeDelta& playback_delay) {
// The timestamp of the last buffer written during the last call to
// FillBuffer().
@@ -181,7 +181,7 @@ size_t AudioRendererBase::FillBuffer(uint8* dest,
// zeros. This gets around the tricky situation of pausing and resuming
// the audio IPC layer in Chrome. Ideally, we should return zero and then
// the subclass can restart the conversation.
- const size_t kZeroLength = 8192;
+ const uint32 kZeroLength = 8192;
dest_written = std::min(kZeroLength, dest_len);
memset(dest, 0, dest_written);
return dest_written;
diff --git a/media/filters/audio_renderer_base.h b/media/filters/audio_renderer_base.h
index 07b62e4..3b3b593 100644
--- a/media/filters/audio_renderer_base.h
+++ b/media/filters/audio_renderer_base.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -76,8 +76,8 @@ class AudioRendererBase : public AudioRenderer {
// hardware plays the buffer, then |playback_delay| should be zero.
//
// Safe to call on any thread.
- size_t FillBuffer(uint8* dest,
- size_t len,
+ uint32 FillBuffer(uint8* dest,
+ uint32 len,
const base::TimeDelta& playback_delay);
// Helper to parse a media format and return whether we were successful
diff --git a/media/filters/audio_renderer_base_unittest.cc b/media/filters/audio_renderer_base_unittest.cc
index df4c9f0..5aae2de 100644
--- a/media/filters/audio_renderer_base_unittest.cc
+++ b/media/filters/audio_renderer_base_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -186,8 +186,8 @@ TEST_F(AudioRendererBaseTest, OneCompleteReadCycle) {
// Now satisfy the read requests. Our callback should be executed after
// exiting this loop.
- const size_t kDataSize = 1024;
- size_t bytes_buffered = 0;
+ const uint32 kDataSize = 1024;
+ uint32 bytes_buffered = 0;
while (!read_queue_.empty()) {
scoped_refptr<DataBuffer> buffer = new DataBuffer(kDataSize);
buffer->SetDataSize(kDataSize);
diff --git a/media/filters/audio_renderer_impl.cc b/media/filters/audio_renderer_impl.cc
index 0f6c4a9..591b0b2 100644
--- a/media/filters/audio_renderer_impl.cc
+++ b/media/filters/audio_renderer_impl.cc
@@ -1,11 +1,12 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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/audio_renderer_impl.h"
+
#include <math.h>
#include "media/base/filter_host.h"
-#include "media/filters/audio_renderer_impl.h"
namespace media {
@@ -50,8 +51,8 @@ void AudioRendererImpl::SetVolume(float volume) {
stream_->SetVolume(volume);
}
-size_t AudioRendererImpl::OnMoreData(AudioOutputStream* stream, void* dest_void,
- size_t len, int pending_bytes) {
+uint32 AudioRendererImpl::OnMoreData(AudioOutputStream* stream, void* dest_void,
+ uint32 len, uint32 pending_bytes) {
// TODO(scherkus): handle end of stream.
if (!stream_)
return 0;
@@ -59,7 +60,7 @@ size_t AudioRendererImpl::OnMoreData(AudioOutputStream* stream, void* dest_void,
// TODO(scherkus): Maybe change OnMoreData to pass in char/uint8 or similar.
// TODO(fbarchard): Waveout_output_win.h should handle zero length buffers
// without clicking.
- pending_bytes = static_cast<int>(ceil(pending_bytes * GetPlaybackRate()));
+ pending_bytes = static_cast<uint32>(ceil(pending_bytes * GetPlaybackRate()));
base::TimeDelta delay = base::TimeDelta::FromMicroseconds(
base::Time::kMicrosecondsPerSecond * pending_bytes / bytes_per_second_);
return FillBuffer(static_cast<uint8*>(dest_void), len, delay);
diff --git a/media/filters/audio_renderer_impl.h b/media/filters/audio_renderer_impl.h
index b15c83d..ced7a9e 100644
--- a/media/filters/audio_renderer_impl.h
+++ b/media/filters/audio_renderer_impl.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -43,8 +43,8 @@ class AudioRendererImpl : public AudioRendererBase,
virtual void SetVolume(float volume);
// AudioSourceCallback implementation.
- virtual size_t OnMoreData(AudioOutputStream* stream, void* dest,
- size_t len, int pending_bytes);
+ virtual uint32 OnMoreData(AudioOutputStream* stream, void* dest,
+ uint32 len, uint32 pending_bytes);
virtual void OnClose(AudioOutputStream* stream);
virtual void OnError(AudioOutputStream* stream, int code);