Index: media/audio/fake_audio_worker.cc |
diff --git a/media/audio/fake_audio_consumer.cc b/media/audio/fake_audio_worker.cc |
similarity index 66% |
rename from media/audio/fake_audio_consumer.cc |
rename to media/audio/fake_audio_worker.cc |
index ca99424f419bc8c174615226f042038cdf06659a..e74bf6d712524384bc2a5756805c8b3b63af5ffa 100644 |
--- a/media/audio/fake_audio_consumer.cc |
+++ b/media/audio/fake_audio_worker.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "media/audio/fake_audio_consumer.h" |
+#include "media/audio/fake_audio_worker.h" |
#include "base/bind.h" |
#include "base/bind_helpers.h" |
@@ -19,14 +19,14 @@ |
namespace media { |
-class FakeAudioConsumer::Worker |
- : public base::RefCountedThreadSafe<FakeAudioConsumer::Worker> { |
+class FakeAudioWorker::Worker |
+ : public base::RefCountedThreadSafe<FakeAudioWorker::Worker> { |
public: |
Worker(const scoped_refptr<base::SingleThreadTaskRunner>& worker_task_runner, |
const AudioParameters& params); |
bool IsStopped(); |
- void Start(const ReadCB& read_cb); |
+ void Start(const WorkerCB& worker_cb); |
void Stop(); |
private: |
@@ -39,7 +39,7 @@ class FakeAudioConsumer::Worker |
// Cancel any delayed callbacks to DoRead() in the worker loop's queue. |
void DoCancel(); |
- // Task that regularly calls |read_cb_| according to the playback rate as |
+ // Task that regularly calls |worker_cb_| according to the playback rate as |
// determined by the audio parameters given during construction. Runs on |
// the worker loop. |
void DoRead(); |
@@ -48,38 +48,38 @@ class FakeAudioConsumer::Worker |
const scoped_ptr<AudioBus> audio_bus_; |
DaleCurtis
2015/02/18 19:04:49
Delete?
phoglund_chromium
2015/02/19 15:44:11
Done.
|
const base::TimeDelta buffer_duration_; |
- base::Lock read_cb_lock_; // Held while mutating or running |read_cb_|. |
- ReadCB read_cb_; |
+ base::Lock worker_cb_lock_; // Held while mutating or running |worker_cb_|. |
+ WorkerCB worker_cb_; |
base::TimeTicks next_read_time_; |
// Used to cancel any delayed tasks still inside the worker loop's queue. |
- base::CancelableClosure read_task_cb_; |
+ base::CancelableClosure worker_task_cb_; |
base::ThreadChecker thread_checker_; |
DISALLOW_COPY_AND_ASSIGN(Worker); |
}; |
-FakeAudioConsumer::FakeAudioConsumer( |
+FakeAudioWorker::FakeAudioWorker( |
const scoped_refptr<base::SingleThreadTaskRunner>& worker_task_runner, |
const AudioParameters& params) |
: worker_(new Worker(worker_task_runner, params)) { |
} |
-FakeAudioConsumer::~FakeAudioConsumer() { |
+FakeAudioWorker::~FakeAudioWorker() { |
DCHECK(worker_->IsStopped()); |
} |
-void FakeAudioConsumer::Start(const ReadCB& read_cb) { |
+void FakeAudioWorker::Start(const WorkerCB& worker_cb) { |
DCHECK(worker_->IsStopped()); |
- worker_->Start(read_cb); |
+ worker_->Start(worker_cb); |
} |
-void FakeAudioConsumer::Stop() { |
+void FakeAudioWorker::Stop() { |
worker_->Stop(); |
} |
-FakeAudioConsumer::Worker::Worker( |
+FakeAudioWorker::Worker::Worker( |
const scoped_refptr<base::SingleThreadTaskRunner>& worker_task_runner, |
const AudioParameters& params) |
: worker_task_runner_(worker_task_runner), |
@@ -94,59 +94,59 @@ FakeAudioConsumer::Worker::Worker( |
thread_checker_.DetachFromThread(); |
} |
-FakeAudioConsumer::Worker::~Worker() { |
- DCHECK(read_cb_.is_null()); |
+FakeAudioWorker::Worker::~Worker() { |
+ DCHECK(worker_cb_.is_null()); |
} |
-bool FakeAudioConsumer::Worker::IsStopped() { |
- base::AutoLock scoped_lock(read_cb_lock_); |
- return read_cb_.is_null(); |
+bool FakeAudioWorker::Worker::IsStopped() { |
+ base::AutoLock scoped_lock(worker_cb_lock_); |
+ return worker_cb_.is_null(); |
} |
-void FakeAudioConsumer::Worker::Start(const ReadCB& read_cb) { |
+void FakeAudioWorker::Worker::Start(const WorkerCB& worker_cb) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
- DCHECK(!read_cb.is_null()); |
+ DCHECK(!worker_cb.is_null()); |
{ |
- base::AutoLock scoped_lock(read_cb_lock_); |
- DCHECK(read_cb_.is_null()); |
- read_cb_ = read_cb; |
+ base::AutoLock scoped_lock(worker_cb_lock_); |
+ DCHECK(worker_cb_.is_null()); |
+ worker_cb_ = worker_cb; |
} |
worker_task_runner_->PostTask(FROM_HERE, base::Bind(&Worker::DoStart, this)); |
} |
-void FakeAudioConsumer::Worker::DoStart() { |
+void FakeAudioWorker::Worker::DoStart() { |
DCHECK(worker_task_runner_->BelongsToCurrentThread()); |
next_read_time_ = base::TimeTicks::Now(); |
- read_task_cb_.Reset(base::Bind(&Worker::DoRead, this)); |
- read_task_cb_.callback().Run(); |
+ worker_task_cb_.Reset(base::Bind(&Worker::DoRead, this)); |
+ worker_task_cb_.callback().Run(); |
} |
-void FakeAudioConsumer::Worker::Stop() { |
+void FakeAudioWorker::Worker::Stop() { |
DCHECK(thread_checker_.CalledOnValidThread()); |
{ |
- base::AutoLock scoped_lock(read_cb_lock_); |
- if (read_cb_.is_null()) |
+ base::AutoLock scoped_lock(worker_cb_lock_); |
+ if (worker_cb_.is_null()) |
return; |
- read_cb_.Reset(); |
+ worker_cb_.Reset(); |
} |
worker_task_runner_->PostTask(FROM_HERE, base::Bind(&Worker::DoCancel, this)); |
} |
-void FakeAudioConsumer::Worker::DoCancel() { |
+void FakeAudioWorker::Worker::DoCancel() { |
DCHECK(worker_task_runner_->BelongsToCurrentThread()); |
- read_task_cb_.Cancel(); |
+ worker_task_cb_.Cancel(); |
} |
-void FakeAudioConsumer::Worker::DoRead() { |
+void FakeAudioWorker::Worker::DoRead() { |
DCHECK(worker_task_runner_->BelongsToCurrentThread()); |
{ |
- base::AutoLock scoped_lock(read_cb_lock_); |
- if (!read_cb_.is_null()) |
- read_cb_.Run(audio_bus_.get()); |
+ base::AutoLock scoped_lock(worker_cb_lock_); |
+ if (!worker_cb_.is_null()) |
+ worker_cb_.Run(); |
} |
- // Need to account for time spent here due to the cost of |read_cb_| as well |
+ // Need to account for time spent here due to the cost of |worker_cb| as well |
// as the imprecision of PostDelayedTask(). |
const base::TimeTicks now = base::TimeTicks::Now(); |
base::TimeDelta delay = next_read_time_ + buffer_duration_ - now; |
@@ -157,7 +157,7 @@ void FakeAudioConsumer::Worker::DoRead() { |
next_read_time_ = now + delay; |
worker_task_runner_->PostDelayedTask( |
- FROM_HERE, read_task_cb_.callback(), delay); |
+ FROM_HERE, worker_task_cb_.callback(), delay); |
} |
} // namespace media |