summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-11 19:09:28 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-11 19:09:28 +0000
commit3ab20f3c57298ee24e15ec802b7e4b2e33598ca0 (patch)
treea10aa65bd80c00b2422f2ed94576677f1b5d2909 /chrome
parent5e6aacc34dd3f8e9b6483e897fb7da1cf582edcd (diff)
downloadchromium_src-3ab20f3c57298ee24e15ec802b7e4b2e33598ca0.zip
chromium_src-3ab20f3c57298ee24e15ec802b7e4b2e33598ca0.tar.gz
chromium_src-3ab20f3c57298ee24e15ec802b7e4b2e33598ca0.tar.bz2
AudioRendererHost send ViewMsg_AudioStreamState
AudioRendererHost should use ViewMsg_AudioStreamState to notify renderer of its state instead of AudioOutputStream::State. The enum of AudioOutputStream::State is not used anywhere, thus removed. TEST=unit_tests --gtest_filter=Audio* Review URL: http://codereview.chromium.org/165255 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23061 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/renderer_host/audio_renderer_host.cc60
-rw-r--r--chrome/browser/renderer_host/audio_renderer_host.h27
-rw-r--r--chrome/browser/renderer_host/audio_renderer_host_unittest.cc20
-rw-r--r--chrome/common/render_messages.h46
-rw-r--r--chrome/common/render_messages_internal.h8
-rw-r--r--chrome/renderer/audio_message_filter.cc5
-rw-r--r--chrome/renderer/audio_message_filter.h7
-rw-r--r--chrome/renderer/audio_message_filter_unittest.cc24
-rw-r--r--chrome/renderer/media/audio_renderer_impl.cc15
-rw-r--r--chrome/renderer/media/audio_renderer_impl.h2
10 files changed, 108 insertions, 106 deletions
diff --git a/chrome/browser/renderer_host/audio_renderer_host.cc b/chrome/browser/renderer_host/audio_renderer_host.cc
index 495a8ea..962b570 100644
--- a/chrome/browser/renderer_host/audio_renderer_host.cc
+++ b/chrome/browser/renderer_host/audio_renderer_host.cc
@@ -68,15 +68,14 @@ AudioRendererHost::IPCAudioSource::IPCAudioSource(
hardware_packet_size_(hardware_packet_size),
decoded_packet_size_(decoded_packet_size),
buffer_capacity_(buffer_capacity),
- state_(AudioOutputStream::STATE_CREATED),
+ state_(kCreated),
push_source_(hardware_packet_size),
outstanding_request_(false),
last_copied_bytes_(0) {
}
AudioRendererHost::IPCAudioSource::~IPCAudioSource() {
- DCHECK(AudioOutputStream::STATE_STOPPED == state_ ||
- AudioOutputStream::STATE_CREATED == state_);
+ DCHECK(kClosed == state_ || kCreated == state_);
}
// static
@@ -158,29 +157,29 @@ AudioRendererHost::IPCAudioSource*
delete source;
}
- host->SendErrorMessage(route_id, stream_id, 0);
+ host->SendErrorMessage(route_id, stream_id);
return NULL;
}
-void AudioRendererHost::IPCAudioSource::Start() {
+void AudioRendererHost::IPCAudioSource::Play() {
// We can start from created or paused state.
- if (!stream_ ||
- (state_ != AudioOutputStream::STATE_CREATED &&
- state_ != AudioOutputStream::STATE_PAUSED))
+ if (!stream_ || (state_ != kCreated && state_ != kPaused))
return;
stream_->Start(this);
// Update the state and notify renderer.
- state_ = AudioOutputStream::STATE_STARTED;
+ state_ = kPaused;
+
+ ViewMsg_AudioStreamState state;
+ state.state = ViewMsg_AudioStreamState::kPlaying;
host_->Send(new ViewMsg_NotifyAudioStreamStateChanged(
- route_id_, stream_id_, state_, 0));
+ route_id_, stream_id_, state));
}
void AudioRendererHost::IPCAudioSource::Pause() {
// We can pause from started state.
- if (!stream_ ||
- state_ != AudioOutputStream::STATE_STARTED)
+ if (!stream_ || state_ != kPlaying)
return;
// TODO(hclam): use stop to simulate pause, make sure the AudioOutpusStream
@@ -188,9 +187,12 @@ void AudioRendererHost::IPCAudioSource::Pause() {
stream_->Stop();
// Update the state and notify renderer.
- state_ = AudioOutputStream::STATE_PAUSED;
+ state_ = kPaused;
+
+ ViewMsg_AudioStreamState state;
+ state.state = ViewMsg_AudioStreamState::kPaused;
host_->Send(new ViewMsg_NotifyAudioStreamStateChanged(
- route_id_, stream_id_, state_, 0));
+ route_id_, stream_id_, state));
}
void AudioRendererHost::IPCAudioSource::Close() {
@@ -203,7 +205,7 @@ void AudioRendererHost::IPCAudioSource::Close() {
stream_ = NULL;
// Update the current state.
- state_ = AudioOutputStream::STATE_STOPPED;
+ state_ = kClosed;
}
void AudioRendererHost::IPCAudioSource::SetVolume(double left, double right) {
@@ -243,7 +245,7 @@ void AudioRendererHost::IPCAudioSource::OnClose(AudioOutputStream* stream) {
void AudioRendererHost::IPCAudioSource::OnError(AudioOutputStream* stream,
int code) {
- host_->SendErrorMessage(route_id_, stream_id_, code);
+ host_->SendErrorMessage(route_id_, stream_id_);
// The following method call would cause this object to be destroyed on IO
// thread.
host_->DestroySource(this);
@@ -379,7 +381,7 @@ bool AudioRendererHost::OnMessageReceived(const IPC::Message& message,
IPC_BEGIN_MESSAGE_MAP_EX(AudioRendererHost, message, *message_was_ok)
IPC_MESSAGE_HANDLER(ViewHostMsg_CreateAudioStream, OnCreateStream)
- IPC_MESSAGE_HANDLER(ViewHostMsg_StartAudioStream, OnStartStream)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_PlayAudioStream, OnPlayStream)
IPC_MESSAGE_HANDLER(ViewHostMsg_PauseAudioStream, OnPauseStream)
IPC_MESSAGE_HANDLER(ViewHostMsg_CloseAudioStream, OnCloseStream)
IPC_MESSAGE_HANDLER(ViewHostMsg_NotifyAudioPacketReady, OnNotifyPacketReady)
@@ -394,7 +396,7 @@ bool AudioRendererHost::IsAudioRendererHostMessage(
const IPC::Message& message) {
switch (message.type()) {
case ViewHostMsg_CreateAudioStream::ID:
- case ViewHostMsg_StartAudioStream::ID:
+ case ViewHostMsg_PlayAudioStream::ID:
case ViewHostMsg_PauseAudioStream::ID:
case ViewHostMsg_CloseAudioStream::ID:
case ViewHostMsg_NotifyAudioPacketReady::ID:
@@ -432,17 +434,17 @@ void AudioRendererHost::OnCreateStream(
std::make_pair(
SourceID(source->route_id(), source->stream_id()), source));
} else {
- SendErrorMessage(msg.routing_id(), stream_id, 0);
+ SendErrorMessage(msg.routing_id(), stream_id);
}
}
-void AudioRendererHost::OnStartStream(const IPC::Message& msg, int stream_id) {
+void AudioRendererHost::OnPlayStream(const IPC::Message& msg, int stream_id) {
DCHECK(MessageLoop::current() == io_loop_);
IPCAudioSource* source = Lookup(msg.routing_id(), stream_id);
if (source) {
- source->Start();
+ source->Play();
} else {
- SendErrorMessage(msg.routing_id(), stream_id, 0);
+ SendErrorMessage(msg.routing_id(), stream_id);
}
}
@@ -452,7 +454,7 @@ void AudioRendererHost::OnPauseStream(const IPC::Message& msg, int stream_id) {
if (source) {
source->Pause();
} else {
- SendErrorMessage(msg.routing_id(), stream_id, 0);
+ SendErrorMessage(msg.routing_id(), stream_id);
}
}
@@ -471,7 +473,7 @@ void AudioRendererHost::OnSetVolume(const IPC::Message& msg, int stream_id,
if (source) {
source->SetVolume(left_channel, right_channel);
} else {
- SendErrorMessage(msg.routing_id(), stream_id, 0);
+ SendErrorMessage(msg.routing_id(), stream_id);
}
}
@@ -481,7 +483,7 @@ void AudioRendererHost::OnGetVolume(const IPC::Message& msg, int stream_id) {
if (source) {
source->GetVolume();
} else {
- SendErrorMessage(msg.routing_id(), stream_id, 0);
+ SendErrorMessage(msg.routing_id(), stream_id);
}
}
@@ -492,7 +494,7 @@ void AudioRendererHost::OnNotifyPacketReady(const IPC::Message& msg,
if (source) {
source->NotifyPacketReady(packet_size);
} else {
- SendErrorMessage(msg.routing_id(), stream_id, 0);
+ SendErrorMessage(msg.routing_id(), stream_id);
}
#ifdef IPC_MESSAGE_LOG_ENABLED
if (IPC::Logging::current() && IPC::Logging::current()->Enabled()) {
@@ -571,9 +573,11 @@ void AudioRendererHost::Send(IPC::Message* message) {
}
void AudioRendererHost::SendErrorMessage(int32 render_view_id,
- int32 stream_id, int info) {
+ int32 stream_id) {
+ ViewMsg_AudioStreamState state;
+ state.state = ViewMsg_AudioStreamState::kError;
Send(new ViewMsg_NotifyAudioStreamStateChanged(
- render_view_id, stream_id, AudioOutputStream::STATE_ERROR, info));
+ render_view_id, stream_id, state));
}
void AudioRendererHost::DestroySource(IPCAudioSource* source) {
diff --git a/chrome/browser/renderer_host/audio_renderer_host.h b/chrome/browser/renderer_host/audio_renderer_host.h
index 9326cf7..de193519 100644
--- a/chrome/browser/renderer_host/audio_renderer_host.h
+++ b/chrome/browser/renderer_host/audio_renderer_host.h
@@ -31,7 +31,7 @@
// .---------> [ Stopped ] <--------.
// | ^ |
// | | |
-// *[ Created ] --> [ Started ] --> [ Paused ]
+// *[ Created ] --> [ Playing ] --> [ Paused ]
// ^ |
// | |
// `-----------------`
@@ -48,8 +48,8 @@
// | <<<<<< RequestAudioPacket <<<<<<<< |
// | >>>>>>> AudioPacketReady >>>>>>>>> |
// | |
-// | >>>>>>>>>>>>> Start >>>>>>>>>>>>>> |
-// | <<<<<<<<<<<< Started <<<<<<<<<<<<< | time
+// | >>>>>>>>>>>>> Play >>>>>>>>>>>>>>> |
+// | <<<<<<<<<<<< Playing <<<<<<<<<<<<< | time
// | ... |
// | <<<<<< RequestAudioPacket <<<<<<<< |
// | >>>>>>> AudioPacketReady >>>>>>>>> |
@@ -126,9 +126,7 @@ class AudioRendererHost : public base::RefCountedThreadSafe<AudioRendererHost> {
virtual void Send(IPC::Message* message);
// A helper method for sending error IPC messages.
- virtual void SendErrorMessage(int32 render_view_id,
- int32 stream_id,
- int info);
+ virtual void SendErrorMessage(int32 render_view_id, int32 stream_id);
// A helper method for calling OnDestroySource on IO thread.
virtual void DestroySource(IPCAudioSource* source);
@@ -143,6 +141,15 @@ class AudioRendererHost : public base::RefCountedThreadSafe<AudioRendererHost> {
// via IPC.
class IPCAudioSource : public AudioOutputStream::AudioSourceCallback {
public:
+ // Internal state of the source.
+ enum State {
+ kCreated,
+ kPlaying,
+ kPaused,
+ kClosed,
+ kError,
+ };
+
// Factory method for creating an IPCAudioSource, returns NULL if failed.
// The IPCAudioSource object will have an internal state of
// AudioOutputStream::STATE_CREATED after creation.
@@ -170,7 +177,7 @@ class AudioRendererHost : public base::RefCountedThreadSafe<AudioRendererHost> {
// Starts the playback of this audio output stream. The internal state will
// be updated to AudioOutputStream::STATE_STARTED and the state update is
// sent to the renderer.
- void Start();
+ void Play();
// Pause this audio output stream. The audio output stream will stop
// reading from the |push_source_|. The internal state will be updated
@@ -236,7 +243,7 @@ class AudioRendererHost : public base::RefCountedThreadSafe<AudioRendererHost> {
size_t decoded_packet_size_;
size_t buffer_capacity_;
- AudioOutputStream::State state_;
+ State state_;
base::SharedMemory shared_memory_;
PushSource push_source_;
@@ -269,11 +276,11 @@ class AudioRendererHost : public base::RefCountedThreadSafe<AudioRendererHost> {
const ViewHostMsg_Audio_CreateStream& params);
// Starts buffering for the audio output stream. Delegates the start method
- // call to the corresponding IPCAudioSource::Start().
+ // call to the corresponding IPCAudioSource::Play().
// ViewMsg_NotifyAudioStreamStateChanged with
// AudioOutputStream::AUDIO_STREAM_ERROR is sent back to renderer if the
// required IPCAudioSource is not found.
- void OnStartStream(const IPC::Message& msg, int stream_id);
+ void OnPlayStream(const IPC::Message& msg, int stream_id);
// Pauses the audio output stream. Delegates the pause method call to the
// corresponding IPCAudioSource::Pause(),
diff --git a/chrome/browser/renderer_host/audio_renderer_host_unittest.cc b/chrome/browser/renderer_host/audio_renderer_host_unittest.cc
index 4a3f103..5418331 100644
--- a/chrome/browser/renderer_host/audio_renderer_host_unittest.cc
+++ b/chrome/browser/renderer_host/audio_renderer_host_unittest.cc
@@ -14,6 +14,7 @@ using ::testing::_;
using ::testing::DoAll;
using ::testing::InSequence;
using ::testing::Return;
+using ::testing::SaveArg;
using ::testing::SetArgumentPointee;
namespace {
@@ -43,9 +44,9 @@ class MockAudioRendererHost : public AudioRendererHost {
MOCK_METHOD3(OnStreamCreated,
void(int routing_id, int stream_id, int length));
- MOCK_METHOD4(OnStreamStateChanged,
+ MOCK_METHOD3(OnStreamStateChanged,
void(int routing_id, int stream_id,
- AudioOutputStream::State state, int info));
+ ViewMsg_AudioStreamState state));
MOCK_METHOD4(OnStreamVolume,
void(int routing_id, int stream_id, double left, double right));
@@ -95,8 +96,8 @@ class MockAudioRendererHost : public AudioRendererHost {
}
void OnStreamStateChanged(const IPC::Message& msg, int stream_id,
- AudioOutputStream::State state, int info) {
- OnStreamStateChanged(msg.routing_id(), stream_id, state, info);
+ ViewMsg_AudioStreamState state) {
+ OnStreamStateChanged(msg.routing_id(), stream_id, state);
}
void OnStreamVolume(const IPC::Message& msg, int stream_id,
@@ -206,10 +207,9 @@ TEST_F(AudioRendererHostTest, MockStreamDataConversation) {
2 * kPacketSize + 3 * kStep, _));
EXPECT_CALL(*host_,
OnRequestPacket(kRouteId, current_stream_id_, 3 * kPacketSize, _));
- EXPECT_CALL(*host_, OnStreamStateChanged(kRouteId,
- current_stream_id_,
- AudioOutputStream::STATE_STARTED,
- 0));
+ ViewMsg_AudioStreamState state;
+ EXPECT_CALL(*host_, OnStreamStateChanged(kRouteId, current_stream_id_, _))
+ .WillOnce(SaveArg<2>(&state));
source->NotifyPacketReady(kPacketSize);
source->NotifyPacketReady(kPacketSize);
@@ -217,7 +217,7 @@ TEST_F(AudioRendererHostTest, MockStreamDataConversation) {
source->NotifyPacketReady(kStep);
source->NotifyPacketReady(kStep);
source->NotifyPacketReady(kStep);
- source->Start();
+ source->Play();
+ EXPECT_EQ(ViewMsg_AudioStreamState::kPlaying, state.state);
source->Close();
}
-
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index af9ded8..63d91c0 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -82,6 +82,20 @@ struct ViewMsg_Navigate_Params {
base::Time request_time;
};
+// 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 {
+ enum State {
+ kPlaying,
+ kPaused,
+ kError
+ };
+
+ // Carries the current playback state.
+ State state;
+};
+
// Parameters structure for ViewHostMsg_FrameNavigate, which has too many data
// parameters to be reasonably put in a predefined IPC message.
struct ViewHostMsg_FrameNavigate_Params {
@@ -1805,44 +1819,34 @@ struct ParamTraits<gfx::NativeView> {
#endif // defined(OS_POSIX)
template <>
-struct ParamTraits<AudioOutputStream::State> {
- typedef AudioOutputStream::State param_type;
+struct ParamTraits<ViewMsg_AudioStreamState> {
+ typedef ViewMsg_AudioStreamState param_type;
static void Write(Message* m, const param_type& p) {
- m->WriteInt(p);
+ m->WriteInt(p.state);
}
static bool Read(const Message* m, void** iter, param_type* p) {
int type;
if (!m->ReadInt(iter, &type))
return false;
- *p = static_cast<AudioOutputStream::State>(type);
+ p->state = static_cast<ViewMsg_AudioStreamState::State>(type);
return true;
}
static void Log(const param_type& p, std::wstring* l) {
std::wstring state;
- switch (p) {
- case AudioOutputStream::STATE_CREATED:
- state = L"AudioOutputStream::STATE_CREATED";
- break;
- case AudioOutputStream::STATE_STARTED:
- state = L"AudioOutputStream::STATE_STARTED";
- break;
- case AudioOutputStream::STATE_PAUSED:
- state = L"AudioOutputStream::STATE_PAUSED";
+ switch (p.state) {
+ case ViewMsg_AudioStreamState::kPlaying:
+ state = L"ViewMsg_AudioStreamState::kPlaying";
break;
- case AudioOutputStream::STATE_STOPPED:
- state = L"AudioOutputStream::STATE_STOPPED";
+ case ViewMsg_AudioStreamState::kPaused:
+ state = L"ViewMsg_AudioStreamState::kPaused";
break;
- case AudioOutputStream::STATE_CLOSED:
- state = L"AudioOutputStream::STATE_CLOSED";
- break;
- case AudioOutputStream::STATE_ERROR:
- state = L"AudioOutputStream::STATE_ERROR";
+ case ViewMsg_AudioStreamState::kError:
+ state = L"ViewMsg_AudioStreamState::kError";
break;
default:
state = L"UNKNOWN";
break;
}
-
LogParam(state, l);
}
};
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index d831654..3d27fb5 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -554,11 +554,9 @@ IPC_BEGIN_MESSAGES(View)
// Notification message sent from AudioRendererHost to renderer for state
// update after the renderer has requested a Create/Start/Close.
- IPC_MESSAGE_ROUTED3(ViewMsg_NotifyAudioStreamStateChanged,
+ IPC_MESSAGE_ROUTED2(ViewMsg_NotifyAudioStreamStateChanged,
int /* stream id */,
- AudioOutputStream::State /* new state */,
- int /* additional information (e.g. platform specific
- error code*/)
+ ViewMsg_AudioStreamState /* new state */)
IPC_MESSAGE_ROUTED3(ViewMsg_NotifyAudioStreamVolume,
int /* stream id */,
@@ -1413,7 +1411,7 @@ IPC_BEGIN_MESSAGES(ViewHost)
size_t /* packet size */)
// Start buffering the audio stream specified by (render_view_id, stream_id).
- IPC_MESSAGE_ROUTED1(ViewHostMsg_StartAudioStream,
+ IPC_MESSAGE_ROUTED1(ViewHostMsg_PlayAudioStream,
int /* stream_id */)
// Pause the audio stream specified by (render_view_id, stream_id).
diff --git a/chrome/renderer/audio_message_filter.cc b/chrome/renderer/audio_message_filter.cc
index b875f92..9bd1b9a 100644
--- a/chrome/renderer/audio_message_filter.cc
+++ b/chrome/renderer/audio_message_filter.cc
@@ -116,15 +116,14 @@ void AudioMessageFilter::OnStreamCreated(int stream_id,
}
void AudioMessageFilter::OnStreamStateChanged(int stream_id,
- AudioOutputStream::State state,
- int info) {
+ ViewMsg_AudioStreamState state) {
Delegate* delegate = delegates_.Lookup(stream_id);
if (!delegate) {
DLOG(WARNING) << "Got audio stream event for a non-existent or removed"
" audio renderer.";
return;
}
- delegate->OnStateChanged(state, info);
+ delegate->OnStateChanged(state);
}
void AudioMessageFilter::OnStreamVolume(int stream_id,
diff --git a/chrome/renderer/audio_message_filter.h b/chrome/renderer/audio_message_filter.h
index 7fa17cb..f714e1b 100644
--- a/chrome/renderer/audio_message_filter.h
+++ b/chrome/renderer/audio_message_filter.h
@@ -12,8 +12,8 @@
#include "base/id_map.h"
#include "base/shared_memory.h"
+#include "chrome/common/render_messages.h"
#include "ipc/ipc_channel_proxy.h"
-#include "media/audio/audio_output.h"
#include "testing/gtest/include/gtest/gtest_prod.h"
class AudioMessageFilter : public IPC::ChannelProxy::MessageFilter {
@@ -25,7 +25,7 @@ class AudioMessageFilter : public IPC::ChannelProxy::MessageFilter {
const base::Time& message_timestamp) = 0;
// Called when state of an audio stream has changed in the browser process.
- virtual void OnStateChanged(AudioOutputStream::State state, int info) = 0;
+ virtual void OnStateChanged(ViewMsg_AudioStreamState state) = 0;
// Called when an audio stream has been created in the browser process.
virtual void OnCreated(base::SharedMemoryHandle handle, size_t length) = 0;
@@ -69,8 +69,7 @@ class AudioMessageFilter : public IPC::ChannelProxy::MessageFilter {
// Received when internal state of browser process' audio output device has
// changed.
- void OnStreamStateChanged(int stream_id, AudioOutputStream::State state,
- int info);
+ void OnStreamStateChanged(int stream_id, ViewMsg_AudioStreamState state);
// Notification of volume property of an audio output stream.
void OnStreamVolume(int stream_id, double left, double right);
diff --git a/chrome/renderer/audio_message_filter_unittest.cc b/chrome/renderer/audio_message_filter_unittest.cc
index d09a406..ee60ffa 100644
--- a/chrome/renderer/audio_message_filter_unittest.cc
+++ b/chrome/renderer/audio_message_filter_unittest.cc
@@ -23,10 +23,9 @@ class MockAudioDelegate : public AudioMessageFilter::Delegate {
message_timestamp_ = message_timestamp;
}
- virtual void OnStateChanged(AudioOutputStream::State state, int info) {
+ virtual void OnStateChanged(ViewMsg_AudioStreamState state) {
state_changed_received_ = true;
state_ = state;
- info_ = info;
}
virtual void OnCreated(base::SharedMemoryHandle handle, size_t length) {
@@ -47,8 +46,7 @@ class MockAudioDelegate : public AudioMessageFilter::Delegate {
message_timestamp_ = base::Time();
state_changed_received_ = false;
- state_ = AudioOutputStream::STATE_ERROR;
- info_ = 0;
+ state_.state = ViewMsg_AudioStreamState::kError;
created_received_ = false;
handle_ = base::SharedMemory::NULLHandle();
@@ -64,8 +62,7 @@ class MockAudioDelegate : public AudioMessageFilter::Delegate {
const base::Time& message_timestamp() { return message_timestamp_; }
bool state_changed_received() { return state_changed_received_; }
- AudioOutputStream::State state() { return state_; }
- int info() { return info_; }
+ ViewMsg_AudioStreamState state() { return state_; }
bool created_received() { return created_received_; }
base::SharedMemoryHandle handle() { return handle_; }
@@ -81,8 +78,7 @@ class MockAudioDelegate : public AudioMessageFilter::Delegate {
base::Time message_timestamp_;
bool state_changed_received_;
- AudioOutputStream::State state_;
- int info_;
+ ViewMsg_AudioStreamState state_;
bool created_received_;
base::SharedMemoryHandle handle_;
@@ -120,17 +116,13 @@ TEST(AudioMessageFilterTest, Basic) {
delegate.Reset();
// ViewMsg_NotifyAudioStreamStateChanged
- const AudioOutputStream::State kState = AudioOutputStream::STATE_STARTED;
- const int kStateInfo = 100;
+ const ViewMsg_AudioStreamState kState =
+ { ViewMsg_AudioStreamState::kPlaying };
EXPECT_FALSE(delegate.state_changed_received());
filter->OnMessageReceived(
- ViewMsg_NotifyAudioStreamStateChanged(kRouteId,
- stream_id,
- kState,
- kStateInfo));
+ ViewMsg_NotifyAudioStreamStateChanged(kRouteId, stream_id, kState));
EXPECT_TRUE(delegate.state_changed_received());
- EXPECT_TRUE(kState == delegate.state());
- EXPECT_EQ(kStateInfo, delegate.info());
+ EXPECT_TRUE(kState.state == delegate.state().state);
delegate.Reset();
// ViewMsg_NotifyAudioStreamCreated
diff --git a/chrome/renderer/media/audio_renderer_impl.cc b/chrome/renderer/media/audio_renderer_impl.cc
index c00d9c7..783acf3 100644
--- a/chrome/renderer/media/audio_renderer_impl.cc
+++ b/chrome/renderer/media/audio_renderer_impl.cc
@@ -183,16 +183,15 @@ void AudioRendererImpl::OnRequestPacket(size_t bytes_in_buffer,
OnNotifyPacketReady();
}
-void AudioRendererImpl::OnStateChanged(AudioOutputStream::State state,
- int info) {
+void AudioRendererImpl::OnStateChanged(ViewMsg_AudioStreamState state) {
DCHECK(MessageLoop::current() == io_loop_);
AutoLock auto_lock(lock_);
if (stopped_)
return;
- switch (state) {
- case AudioOutputStream::STATE_ERROR:
+ switch (state.state) {
+ case ViewMsg_AudioStreamState::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
@@ -201,8 +200,8 @@ void AudioRendererImpl::OnStateChanged(AudioOutputStream::State state,
host()->BroadcastMessage(media::kMsgDisableAudio);
break;
// TODO(hclam): handle these events.
- case AudioOutputStream::STATE_STARTED:
- case AudioOutputStream::STATE_PAUSED:
+ case ViewMsg_AudioStreamState::kPlaying:
+ case ViewMsg_AudioStreamState::kPaused:
break;
default:
NOTREACHED();
@@ -242,7 +241,7 @@ void AudioRendererImpl::OnCreateStream(
void AudioRendererImpl::OnPlay() {
DCHECK(MessageLoop::current() == io_loop_);
- filter_->Send(new ViewHostMsg_StartAudioStream(0, stream_id_));
+ filter_->Send(new ViewHostMsg_PlayAudioStream(0, stream_id_));
}
void AudioRendererImpl::OnPause() {
@@ -309,7 +308,7 @@ void AudioRendererImpl::OnNotifyPacketReady() {
if (filled > preroll_bytes_) {
prerolling_ = false;
preroll_bytes_ = 0;
- filter_->Send(new ViewHostMsg_StartAudioStream(0, stream_id_));
+ filter_->Send(new ViewHostMsg_PlayAudioStream(0, stream_id_));
} else {
preroll_bytes_ -= filled;
}
diff --git a/chrome/renderer/media/audio_renderer_impl.h b/chrome/renderer/media/audio_renderer_impl.h
index a087402..489bc60 100644
--- a/chrome/renderer/media/audio_renderer_impl.h
+++ b/chrome/renderer/media/audio_renderer_impl.h
@@ -118,7 +118,7 @@ class AudioRendererImpl : public media::AudioRendererBase,
// AudioMessageFilter::Delegate methods, called by AudioMessageFilter.
void OnRequestPacket(size_t bytes_in_buffer,
const base::Time& message_timestamp);
- void OnStateChanged(AudioOutputStream::State state, int info);
+ void OnStateChanged(ViewMsg_AudioStreamState state);
void OnCreated(base::SharedMemoryHandle handle, size_t length);
void OnVolume(double left, double right);