OLD | NEW |
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 "media/audio/audio_device_thread.h" | 5 #include "media/audio/audio_device_thread.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 AudioDeviceThread::AudioDeviceThread() { | 65 AudioDeviceThread::AudioDeviceThread() { |
66 } | 66 } |
67 | 67 |
68 AudioDeviceThread::~AudioDeviceThread() { DCHECK(!thread_.get()); } | 68 AudioDeviceThread::~AudioDeviceThread() { DCHECK(!thread_.get()); } |
69 | 69 |
70 void AudioDeviceThread::Start(AudioDeviceThread::Callback* callback, | 70 void AudioDeviceThread::Start(AudioDeviceThread::Callback* callback, |
71 base::SyncSocket::Handle socket, | 71 base::SyncSocket::Handle socket, |
72 const char* thread_name, | 72 const char* thread_name, |
73 bool synchronized_buffers) { | 73 bool synchronized_buffers) { |
74 base::AutoLock auto_lock(thread_lock_); | 74 base::AutoLock auto_lock(thread_lock_); |
75 CHECK(!thread_); | 75 CHECK(!thread_.get()); |
76 thread_ = new AudioDeviceThread::Thread( | 76 thread_ = new AudioDeviceThread::Thread( |
77 callback, socket, thread_name, synchronized_buffers); | 77 callback, socket, thread_name, synchronized_buffers); |
78 thread_->Start(); | 78 thread_->Start(); |
79 } | 79 } |
80 | 80 |
81 void AudioDeviceThread::Stop(base::MessageLoop* loop_for_join) { | 81 void AudioDeviceThread::Stop(base::MessageLoop* loop_for_join) { |
82 base::AutoLock auto_lock(thread_lock_); | 82 base::AutoLock auto_lock(thread_lock_); |
83 if (thread_.get()) { | 83 if (thread_.get()) { |
84 thread_->Stop(loop_for_join); | 84 thread_->Stop(loop_for_join); |
85 thread_ = NULL; | 85 thread_ = NULL; |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 bool AudioDeviceThread::IsStopped() { | 89 bool AudioDeviceThread::IsStopped() { |
90 base::AutoLock auto_lock(thread_lock_); | 90 base::AutoLock auto_lock(thread_lock_); |
91 return !thread_; | 91 return !thread_.get(); |
92 } | 92 } |
93 | 93 |
94 // AudioDeviceThread::Thread implementation | 94 // AudioDeviceThread::Thread implementation |
95 AudioDeviceThread::Thread::Thread(AudioDeviceThread::Callback* callback, | 95 AudioDeviceThread::Thread::Thread(AudioDeviceThread::Callback* callback, |
96 base::SyncSocket::Handle socket, | 96 base::SyncSocket::Handle socket, |
97 const char* thread_name, | 97 const char* thread_name, |
98 bool synchronized_buffers) | 98 bool synchronized_buffers) |
99 : thread_(), | 99 : thread_(), |
100 callback_(callback), | 100 callback_(callback), |
101 socket_(socket), | 101 socket_(socket), |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 } | 212 } |
213 | 213 |
214 AudioDeviceThread::Callback::~Callback() {} | 214 AudioDeviceThread::Callback::~Callback() {} |
215 | 215 |
216 void AudioDeviceThread::Callback::InitializeOnAudioThread() { | 216 void AudioDeviceThread::Callback::InitializeOnAudioThread() { |
217 MapSharedMemory(); | 217 MapSharedMemory(); |
218 CHECK(shared_memory_.memory()); | 218 CHECK(shared_memory_.memory()); |
219 } | 219 } |
220 | 220 |
221 } // namespace media. | 221 } // namespace media. |
OLD | NEW |