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

Side by Side Diff: remoting/host/ipc_audio_capturer.cc

Issue 11761019: Tiny little refactoring of DesktopEnvironment. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « remoting/host/ipc_audio_capturer.h ('k') | remoting/host/ipc_desktop_environment.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/host/ipc_audio_capturer.h" 5 #include "remoting/host/ipc_audio_capturer.h"
6 6
7 #include "remoting/host/desktop_session_proxy.h" 7 #include "remoting/host/desktop_session_proxy.h"
8 #include "remoting/proto/audio.pb.h" 8 #include "remoting/proto/audio.pb.h"
9 9
10 namespace remoting { 10 namespace remoting {
11 11
12 IpcAudioCapturer::IpcAudioCapturer( 12 IpcAudioCapturer::IpcAudioCapturer(
13 scoped_refptr<DesktopSessionProxy> desktop_session_proxy) 13 scoped_refptr<DesktopSessionProxy> desktop_session_proxy)
14 : desktop_session_proxy_(desktop_session_proxy) { 14 : desktop_session_proxy_(desktop_session_proxy),
15 started_(false) {
15 // The audio capturer is created on the network thread while used on the audio 16 // The audio capturer is created on the network thread while used on the audio
16 // capture thread. Detach |thread_checker_| from the current thread so that it 17 // capture thread. Detach |thread_checker_| from the current thread so that it
17 // will re-attach to the proper thread when Start() is called for the first 18 // will re-attach to the proper thread when Start() is called for the first
18 // time. 19 // time.
19 thread_checker_.DetachFromThread(); 20 thread_checker_.DetachFromThread();
20 } 21 }
21 22
22 IpcAudioCapturer::~IpcAudioCapturer() { 23 IpcAudioCapturer::~IpcAudioCapturer() {
23 DCHECK(callback_.is_null()); 24 DCHECK(!started_);
24 } 25 }
25 26
26 bool IpcAudioCapturer::Start(const PacketCapturedCallback& callback) { 27 bool IpcAudioCapturer::Start(const PacketCapturedCallback& callback) {
27 DCHECK(thread_checker_.CalledOnValidThread()); 28 DCHECK(thread_checker_.CalledOnValidThread());
28 DCHECK(callback_.is_null()); 29 DCHECK(!started_);
29 DCHECK(!callback.is_null());
30 30
31 callback_ = callback; 31 started_ = true;
32 desktop_session_proxy_->StartAudioCapturer(this); 32 desktop_session_proxy_->StartAudioCapturer(callback);
33 33
34 return true; 34 return true;
35 } 35 }
36 36
37 void IpcAudioCapturer::Stop() { 37 void IpcAudioCapturer::Stop() {
38 DCHECK(thread_checker_.CalledOnValidThread()); 38 DCHECK(thread_checker_.CalledOnValidThread());
39 DCHECK(!callback_.is_null()); 39 DCHECK(started_);
40 40
41 desktop_session_proxy_->StopAudioCapturer(); 41 desktop_session_proxy_->StopAudioCapturer();
42 callback_.Reset(); 42 started_ = false;
43 } 43 }
44 44
45 bool IpcAudioCapturer::IsStarted() { 45 bool IpcAudioCapturer::IsStarted() {
46 DCHECK(thread_checker_.CalledOnValidThread()); 46 DCHECK(thread_checker_.CalledOnValidThread());
47 47
48 return !callback_.is_null(); 48 return started_;
49 }
50
51 // Called when an audio packet has been received.
52 void IpcAudioCapturer::OnAudioPacket(scoped_ptr<AudioPacket> packet) {
53 DCHECK(thread_checker_.CalledOnValidThread());
54 DCHECK(!callback_.is_null());
55
56 callback_.Run(packet.Pass());
57 } 49 }
58 50
59 } // namespace remoting 51 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/ipc_audio_capturer.h ('k') | remoting/host/ipc_desktop_environment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698