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

Unified Diff: remoting/host/audio_scheduler.cc

Issue 11260053: Use correct thread for audio capturing and encoding. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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: remoting/host/audio_scheduler.cc
diff --git a/remoting/host/audio_scheduler.cc b/remoting/host/audio_scheduler.cc
index 02cc989cd8131aa53b27424d7332152f57d4dff7..c4d83394ecb4221f4d7c955cf7f0da5a5de3de49 100644
--- a/remoting/host/audio_scheduler.cc
+++ b/remoting/host/audio_scheduler.cc
@@ -11,6 +11,7 @@
#include "base/single_thread_task_runner.h"
#include "remoting/codec/audio_encoder.h"
#include "remoting/host/audio_capturer.h"
+#include "remoting/host/desktop_environment.h"
#include "remoting/proto/audio.pb.h"
#include "remoting/protocol/audio_stub.h"
@@ -19,22 +20,21 @@ namespace remoting {
AudioScheduler::AudioScheduler(
scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
- AudioCapturer* audio_capturer,
+ DesktopEnvironment* desktop_environment,
scoped_ptr<AudioEncoder> audio_encoder,
protocol::AudioStub* audio_stub)
: audio_task_runner_(audio_task_runner),
network_task_runner_(network_task_runner),
- audio_capturer_(audio_capturer),
audio_encoder_(audio_encoder.Pass()),
audio_stub_(audio_stub),
network_stopped_(false),
enabled_(true) {
DCHECK(network_task_runner_->BelongsToCurrentThread());
- DCHECK(audio_capturer_);
DCHECK(audio_stub_);
audio_task_runner_->PostTask(
- FROM_HERE, base::Bind(&AudioScheduler::StartOnAudioThread, this));
+ FROM_HERE, base::Bind(&AudioScheduler::StartOnAudioThread, this,
+ desktop_environment));
Wez 2012/10/27 03:43:15 base::Unretained()?
Wez 2012/10/27 03:43:15 Add a comment reminding that |desktop_environment|
Sergey Ulanov 2012/10/29 23:43:04 AudioScheduler is ref-counted
Sergey Ulanov 2012/10/29 23:43:04 Done.
}
void AudioScheduler::Stop(const base::Closure& done_task) {
@@ -53,17 +53,22 @@ void AudioScheduler::Stop(const base::Closure& done_task) {
AudioScheduler::~AudioScheduler() {
}
-void AudioScheduler::StartOnAudioThread() {
+void AudioScheduler::StartOnAudioThread(
+ DesktopEnvironment* desktop_environment) {
DCHECK(audio_task_runner_->BelongsToCurrentThread());
- // TODO(kxing): Do something with the return value.
- audio_capturer_->Start(
- base::Bind(&AudioScheduler::EncodeAudioPacket, this));
+ audio_capturer_ = desktop_environment->CreateAudioCapturer();
+ if (!audio_capturer_->Start(
+ base::Bind(&AudioScheduler::EncodeAudioPacket, this))) {
Wez 2012/10/27 03:43:15 nit: Indentation.
Sergey Ulanov 2012/10/29 23:43:04 It is indented correctly - 4 spaces relative to st
+ LOG(ERROR) << "Failed to create audio capturer";
Wez 2012/10/27 03:43:15 nit: Failed to start audio capturer?
Sergey Ulanov 2012/10/29 23:43:04 Done.
+ audio_capturer_.reset();
+ }
}
void AudioScheduler::StopOnAudioThread(const base::Closure& done_task) {
DCHECK(audio_task_runner_->BelongsToCurrentThread());
- audio_capturer_->Stop();
+ if (audio_capturer_)
+ audio_capturer_->Stop();
Wez 2012/10/27 03:43:15 Not for this CL, but I wonder if we even need Audi
Sergey Ulanov 2012/10/29 23:43:04 No. I'll remove it in a separate CL.
network_task_runner_->PostTask(FROM_HERE, done_task);
}

Powered by Google App Engine
This is Rietveld 408576698