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

Side by Side Diff: content/browser/media/audio_output_impl.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: use of process_ instead of audio_renderer_host 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/media/audio_output_impl.h"
6 #include "content/browser/media/audio_output_stream_impl.h"
7
8 namespace content {
9
10 AudioOutputImpl::AudioOutputImpl(
11 RenderProcessHost* process,
12 int render_frame_id,
13 media::mojom::AudioOutputRequest request)
14 : process_(process),
15 render_frame_id_(render_frame_id),
16 binding_(this) {
17 DCHECK_CURRENTLY_ON(BrowserThread::IO);
18 binding_.Bind(std::move(request));
19 LOG(ERROR) << "AudioOutputImpl";
tommi (sloooow) - chröme 2016/05/20 13:26:12 ?
rchtara 2016/05/27 15:24:36 Done.
20 factory_ = base::Bind(AudioOutputStreamFactory::Factory);
Henrik Grunell 2016/05/20 13:35:39 I suppose |factory_| is needed for being modified
rchtara 2016/05/27 15:24:36 it's removed: not needed for the new tests
21 }
22
23 AudioOutputImpl::~AudioOutputImpl() {
24 LOG(ERROR) << "~AudioOutputImpl";
tommi (sloooow) - chröme 2016/05/20 13:26:12 please remove all of these
rchtara 2016/05/27 15:24:36 Done.
25 }
26
27 // static
28 void AudioOutputImpl::CreateService(
29 RenderProcessHost* process,
30 int render_frame_id,
31 media::mojom::AudioOutputRequest request) {
32 DCHECK_CURRENTLY_ON(BrowserThread::UI);
33
34 BrowserThread::PostTask(
35 BrowserThread::IO, FROM_HERE,
36 base::Bind(&AudioOutputImpl::CreateServiceOnIOThread, process,
37 render_frame_id, base::Passed(&request)));
38 }
39
40 // static
41 void AudioOutputImpl::CreateServiceOnIOThread(
42 RenderProcessHost* process,
43 int render_frame_id,
44 media::mojom::AudioOutputRequest request) {
45 if (request.is_pending()) {
46 DCHECK_CURRENTLY_ON(BrowserThread::IO);
tommi (sloooow) - chröme 2016/05/20 13:26:12 why would we only be on the io thread if the reque
Henrik Grunell 2016/05/20 13:35:39 Why can it be called on another thread if not pend
rchtara 2016/05/27 15:24:36 Done.
rchtara 2016/05/27 15:24:36 Done.
47 }
48
49 auto service = new AudioOutputImpl(process, render_frame_id,
50 std::move(request));
51
52 process->audio_renderer_host()->set_audio_output_impl(render_frame_id, service );
tommi (sloooow) - chröme 2016/05/20 13:26:12 please run git cl format
Henrik Grunell 2016/05/20 13:35:39 This is what we talked about offline, right? It wo
rchtara 2016/05/27 15:24:36 yes. exactly
rchtara 2016/05/27 15:24:36 Done.
rchtara 2016/05/27 15:24:36 Done.
53 }
54
55 void AudioOutputImpl::CreateStream(int stream_id,
56 const media::AudioParameters& params,
57 const CreateStreamCallback& callback) {
58 DCHECK_CURRENTLY_ON(BrowserThread::IO);
59 media::mojom::AudioOutputStreamPtr stream;
60 process_->audio_renderer_host()->CreateStream(stream_id, render_frame_id_,
61 params, callback);
62 }
63
64 media::mojom::AudioOutputStreamPtr AudioOutputImpl::StreamFactory(
Henrik Grunell 2016/05/20 13:35:39 It seems to be unnecessarily complicated to call t
rchtara 2016/05/27 15:24:36 Yes, but dale wants to removes code from the ARH.
65 int stream_id,
66 int render_frame_id,
67 AudioRendererHost* audio_renderer_host) {
68 DCHECK_CURRENTLY_ON(BrowserThread::IO);
69
70 media::mojom::AudioOutputStreamPtr stream =
71 media::mojom::AudioOutputStreamPtr();
72 std::unique_ptr<AudioOutputStreamImpl> stream_ptr(
73 factory_.Run(mojo::GetProxy(&stream), stream_id, render_frame_id,
74 audio_renderer_host));
75
76 auto ret =
77 stream_impls_.insert(std::make_pair(stream_id, std::move(stream_ptr)));
78 DCHECK(ret.second);
tommi (sloooow) - chröme 2016/05/20 13:26:12 do you get a build error for official builds? (re
rchtara 2016/05/27 15:24:36 On 2016/05/20 13:26:12, tommi-chrömium wrote: > do
79 return stream;
80 }
81
82 bool AudioOutputImpl::RemoveStream(int stream_id) {
83 LOG(ERROR) << "rm stream_id" << stream_id;
84 if (stream_impls_.erase(stream_id))
85 return true;
86 else
87 return false;
tommi (sloooow) - chröme 2016/05/20 13:26:12 please just do: return stream_impls_.erase(stream
rchtara 2016/05/27 15:24:36 Done.
88 }
89
90 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698