Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1766)

Unified Diff: content/renderer/media/audio_message_filter.cc

Issue 1930393002: Switch stream creation and closing in Chrome audio rendering from IPC to Mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unique_ptr for Binding Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 9e7322d128e65f0d5f9507a544c8cf01943e7d16..1da6b4fda18a212401994322e7f091467937a10d 100644
--- a/content/renderer/media/audio_message_filter.cc
+++ b/content/renderer/media/audio_message_filter.cc
@@ -58,6 +58,8 @@ AudioMessageFilter::AudioMessageFilter(
AudioMessageFilter::~AudioMessageFilter() {
DCHECK_EQ(g_filter, this);
g_filter = NULL;
+
+ LOG(ERROR) << "^AudioMessageFilter";
}
// static
@@ -82,6 +84,10 @@ std::unique_ptr<media::AudioOutputIPC> AudioMessageFilter::CreateAudioOutputIPC(
new AudioOutputIPCImpl(this, render_frame_id));
}
+void AudioMessageFilter::CloseStream(int stream_id) {
+ Send(new AudioHostMsg_CloseStream(stream_id));
+}
+
void AudioMessageFilter::AudioOutputIPCImpl::RequestDeviceAuthorization(
media::AudioOutputIPCDelegate* delegate,
int session_id,
@@ -103,11 +109,18 @@ void AudioMessageFilter::AudioOutputIPCImpl::CreateStream(
const media::AudioParameters& params) {
DCHECK(filter_->io_task_runner_->BelongsToCurrentThread());
DCHECK(!stream_created_);
+ auto client = filter_->audio_output_clients_.find(render_frame_id_);
+ if (client == filter_->audio_output_clients_.end())
+ return;
if (stream_id_ == kStreamIDNotSet)
stream_id_ = filter_->delegates_.Add(delegate);
+ // TODO(rchtara): This is temporary. In soon upcoming CLs AudioMessageFilter
+ // and AudioMessageFilter::AudioOutputIPCImpl will be removed and replaced by
+ // AudioOutputClient.
- filter_->Send(
- new AudioHostMsg_CreateStream(stream_id_, render_frame_id_, params));
+ client->second->CreateStream(
+ stream_id_, params,
+ base::Bind(&AudioOutputClient::CreateStreamCallback, client->second));
stream_created_ = true;
}
@@ -124,7 +137,13 @@ void AudioMessageFilter::AudioOutputIPCImpl::PauseStream() {
void AudioMessageFilter::AudioOutputIPCImpl::CloseStream() {
DCHECK(filter_->io_task_runner_->BelongsToCurrentThread());
DCHECK_NE(stream_id_, kStreamIDNotSet);
- filter_->Send(new AudioHostMsg_CloseStream(stream_id_));
+ auto client = filter_->audio_output_clients_.find(render_frame_id_);
+ if (client == filter_->audio_output_clients_.end())
+ return;
+ // TODO(rchtara): This is temporary. In soon upcoming CLs AudioMessageFilter
+ // and AudioMessageFilter::AudioOutputIPCImpl will be removed and replaced by
+ // AudioOutputClient.
+ client->second->CloseStream(stream_id_);
filter_->delegates_.Remove(stream_id_);
stream_id_ = kStreamIDNotSet;
stream_created_ = false;
@@ -149,7 +168,6 @@ bool AudioMessageFilter::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(AudioMessageFilter, message)
IPC_MESSAGE_HANDLER(AudioMsg_NotifyDeviceAuthorized, OnDeviceAuthorized)
- IPC_MESSAGE_HANDLER(AudioMsg_NotifyStreamCreated, OnStreamCreated)
IPC_MESSAGE_HANDLER(AudioMsg_NotifyStreamStateChanged, OnStreamStateChanged)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -197,7 +215,7 @@ void AudioMessageFilter::OnDeviceAuthorized(
delegate->OnDeviceAuthorized(device_status, output_params, matched_device_id);
}
-void AudioMessageFilter::OnStreamCreated(
+void AudioMessageFilter::StreamCreated(
int stream_id,
base::SharedMemoryHandle handle,
base::SyncSocket::TransitDescriptor socket_descriptor,
@@ -213,7 +231,7 @@ void AudioMessageFilter::OnStreamCreated(
media::AudioOutputIPCDelegate* delegate = delegates_.Lookup(stream_id);
if (!delegate) {
- DLOG(WARNING) << "Got OnStreamCreated() event for a non-existent or removed"
+ DLOG(WARNING) << "Got StreamCreated() event for a non-existent or removed"
<< " audio renderer. (stream_id=" << stream_id << ").";
base::SharedMemory::CloseHandle(handle);
base::SyncSocket socket(socket_handle);
« no previous file with comments | « content/renderer/media/audio_message_filter.h ('k') | content/renderer/media/audio_message_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698