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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 DISALLOW_COPY_AND_ASSIGN(Thread); | 59 DISALLOW_COPY_AND_ASSIGN(Thread); |
60 }; | 60 }; |
61 | 61 |
62 // AudioDeviceThread implementation | 62 // AudioDeviceThread implementation |
63 | 63 |
64 AudioDeviceThread::AudioDeviceThread() { | 64 AudioDeviceThread::AudioDeviceThread() { |
65 } | 65 } |
66 | 66 |
67 AudioDeviceThread::~AudioDeviceThread() { | 67 AudioDeviceThread::~AudioDeviceThread() { |
68 DCHECK(!thread_); | 68 DCHECK(!thread_.get()); |
69 } | 69 } |
70 | 70 |
71 void AudioDeviceThread::Start(AudioDeviceThread::Callback* callback, | 71 void AudioDeviceThread::Start(AudioDeviceThread::Callback* callback, |
72 base::SyncSocket::Handle socket, | 72 base::SyncSocket::Handle socket, |
73 const char* thread_name) { | 73 const char* thread_name) { |
74 base::AutoLock auto_lock(thread_lock_); | 74 base::AutoLock auto_lock(thread_lock_); |
75 CHECK(thread_ == NULL); | 75 CHECK(thread_.get() == NULL); |
76 thread_ = new AudioDeviceThread::Thread(callback, socket, thread_name); | 76 thread_ = new AudioDeviceThread::Thread(callback, socket, thread_name); |
77 thread_->Start(); | 77 thread_->Start(); |
78 } | 78 } |
79 | 79 |
80 void AudioDeviceThread::Stop(MessageLoop* loop_for_join) { | 80 void AudioDeviceThread::Stop(MessageLoop* loop_for_join) { |
81 base::AutoLock auto_lock(thread_lock_); | 81 base::AutoLock auto_lock(thread_lock_); |
82 if (thread_) { | 82 if (thread_.get()) { |
83 thread_->Stop(loop_for_join); | 83 thread_->Stop(loop_for_join); |
84 thread_ = NULL; | 84 thread_ = NULL; |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 bool AudioDeviceThread::IsStopped() { | 88 bool AudioDeviceThread::IsStopped() { |
89 base::AutoLock auto_lock(thread_lock_); | 89 base::AutoLock auto_lock(thread_lock_); |
90 return thread_ == NULL; | 90 return thread_.get() == NULL; |
91 } | 91 } |
92 | 92 |
93 // AudioDeviceThread::Thread implementation | 93 // AudioDeviceThread::Thread implementation |
94 AudioDeviceThread::Thread::Thread(AudioDeviceThread::Callback* callback, | 94 AudioDeviceThread::Thread::Thread(AudioDeviceThread::Callback* callback, |
95 base::SyncSocket::Handle socket, | 95 base::SyncSocket::Handle socket, |
96 const char* thread_name) | 96 const char* thread_name) |
97 : thread_(base::kNullThreadHandle), | 97 : thread_(base::kNullThreadHandle), |
98 callback_(callback), | 98 callback_(callback), |
99 socket_(socket), | 99 socket_(socket), |
100 thread_name_(thread_name) { | 100 thread_name_(thread_name) { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 } | 192 } |
193 | 193 |
194 AudioDeviceThread::Callback::~Callback() {} | 194 AudioDeviceThread::Callback::~Callback() {} |
195 | 195 |
196 void AudioDeviceThread::Callback::InitializeOnAudioThread() { | 196 void AudioDeviceThread::Callback::InitializeOnAudioThread() { |
197 MapSharedMemory(); | 197 MapSharedMemory(); |
198 DCHECK(shared_memory_.memory() != NULL); | 198 DCHECK(shared_memory_.memory() != NULL); |
199 } | 199 } |
200 | 200 |
201 } // namespace media. | 201 } // namespace media. |
OLD | NEW |