| Index: content/renderer/media/audio_message_filter.cc
|
| diff --git a/content/renderer/media/audio_message_filter.cc b/content/renderer/media/audio_message_filter.cc
|
| index ce26c13b40c40095cfeceb24998df915db68168e..8f62083f9651effb1278d392f91d45e9179bfb04 100644
|
| --- a/content/renderer/media/audio_message_filter.cc
|
| +++ b/content/renderer/media/audio_message_filter.cc
|
| @@ -4,6 +4,8 @@
|
|
|
| #include "content/renderer/media/audio_message_filter.h"
|
|
|
| +#include <string>
|
| +
|
| #include "base/bind.h"
|
| #include "base/message_loop/message_loop_proxy.h"
|
| #include "base/strings/stringprintf.h"
|
| @@ -33,6 +35,10 @@ class AudioMessageFilter::AudioOutputIPCImpl
|
| void PauseStream() override;
|
| void CloseStream() override;
|
| void SetVolume(double volume) override;
|
| + void SwitchDevice(const std::string& device_id,
|
| + const GURL& security_origin,
|
| + int request_id,
|
| + const base::Callback<void(int)>& callback) override;
|
|
|
| private:
|
| const scoped_refptr<AudioMessageFilter> filter_;
|
| @@ -111,6 +117,21 @@ void AudioMessageFilter::AudioOutputIPCImpl::SetVolume(double volume) {
|
| filter_->Send(new AudioHostMsg_SetVolume(stream_id_, volume));
|
| }
|
|
|
| +void AudioMessageFilter::AudioOutputIPCImpl::SwitchDevice(
|
| + const std::string& device_id,
|
| + const GURL& security_origin,
|
| + int request_id,
|
| + const base::Callback<void(int)>& callback) {
|
| + DCHECK_NE(stream_id_, kStreamIDNotSet);
|
| + DVLOG(1) << __FUNCTION__
|
| + << "(" << device_id << ", " << security_origin << ")";
|
| + filter_->Send(new AudioHostMsg_SwitchOutputDevice(stream_id_,
|
| + device_id,
|
| + security_origin,
|
| + render_frame_id_,
|
| + request_id));
|
| +}
|
| +
|
| void AudioMessageFilter::Send(IPC::Message* message) {
|
| DCHECK(io_message_loop_->BelongsToCurrentThread());
|
| if (!sender_) {
|
| @@ -126,6 +147,8 @@ bool AudioMessageFilter::OnMessageReceived(const IPC::Message& message) {
|
| IPC_BEGIN_MESSAGE_MAP(AudioMessageFilter, message)
|
| IPC_MESSAGE_HANDLER(AudioMsg_NotifyStreamCreated, OnStreamCreated)
|
| IPC_MESSAGE_HANDLER(AudioMsg_NotifyStreamStateChanged, OnStreamStateChanged)
|
| + IPC_MESSAGE_HANDLER(AudioMsg_NotifyOutputDeviceSwitched,
|
| + OnOutputDeviceSwitched)
|
| IPC_MESSAGE_UNHANDLED(handled = false)
|
| IPC_END_MESSAGE_MAP()
|
| return handled;
|
| @@ -196,4 +219,20 @@ void AudioMessageFilter::OnStreamStateChanged(
|
| delegate->OnStateChanged(state);
|
| }
|
|
|
| +void AudioMessageFilter::OnOutputDeviceSwitched(
|
| + int stream_id,
|
| + int request_id,
|
| + media::AudioOutputIPCDelegate::DeviceSwitchResult result) {
|
| + DCHECK(io_message_loop_->BelongsToCurrentThread());
|
| + DVLOG(1) << __FUNCTION__
|
| + << "(" << stream_id << ", " << request_id << ", " << result << ")";
|
| + media::AudioOutputIPCDelegate* delegate = delegates_.Lookup(stream_id);
|
| + if (!delegate) {
|
| + DLOG(WARNING) << "Got OnOutputDeviceSwitched() event for a nonexistent or"
|
| + << " removed audio renderer. State: " << result;
|
| + return;
|
| + }
|
| + delegate->OnDeviceSwitched(request_id, result);
|
| +}
|
| +
|
| } // namespace content
|
|
|