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

Unified Diff: media/audio/audio_device_thread.cc

Issue 2640003002: Implement MojoAudioRendererSink and use it in UtilityMojoMediaClient (Closed)
Patch Set: Rebase Created 3 years, 10 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
« no previous file with comments | « media/audio/audio_device_thread.h ('k') | media/base/audio_bus.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_device_thread.cc
diff --git a/media/audio/audio_device_thread.cc b/media/audio/audio_device_thread.cc
index 0a0d274a00d48d72f38eefbd9e8032e3ca3873d8..c1f266baecd933fdec8019ff61c34c6a2fcba9c6 100644
--- a/media/audio/audio_device_thread.cc
+++ b/media/audio/audio_device_thread.cc
@@ -6,7 +6,9 @@
#include <limits>
+#include "base/bind.h"
#include "base/logging.h"
+#include "base/threading/thread.h"
namespace media {
@@ -46,21 +48,27 @@ void AudioDeviceThread::Callback::InitializeOnAudioThread() {
AudioDeviceThread::AudioDeviceThread(Callback* callback,
base::SyncSocket::Handle socket,
const char* thread_name)
- : callback_(callback), thread_name_(thread_name), socket_(socket) {
- CHECK(base::PlatformThread::CreateWithPriority(
- 0, this, &thread_handle_, base::ThreadPriority::REALTIME_AUDIO));
- DCHECK(!thread_handle_.is_null());
+ : callback_(callback),
+ socket_(socket),
+ thread_(new base::Thread("AudioDevice")) {
+ base::Thread::Options options;
+ options.joinable = true;
+ options.priority = base::ThreadPriority::REALTIME_AUDIO;
+ thread_->StartWithOptions(options);
+ bool started = thread_->WaitUntilThreadStarted();
+ CHECK(started);
+
+ thread_->task_runner()->PostTask(
+ FROM_HERE,
+ base::Bind(&AudioDeviceThread::ThreadMain, base::Unretained(this)));
}
AudioDeviceThread::~AudioDeviceThread() {
socket_.Shutdown();
- if (thread_handle_.is_null())
- return;
- base::PlatformThread::Join(thread_handle_);
+ thread_->Stop();
}
void AudioDeviceThread::ThreadMain() {
- base::PlatformThread::SetName(thread_name_);
callback_->InitializeOnAudioThread();
uint32_t buffer_index = 0;
« no previous file with comments | « media/audio/audio_device_thread.h ('k') | media/base/audio_bus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698