Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/midi/midi_manager_alsa.h" | 5 #include "media/midi/midi_manager_alsa.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <poll.h> | 8 #include <poll.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <stdlib.h> | 10 #include <stdlib.h> |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 } // namespace | 151 } // namespace |
| 152 | 152 |
| 153 MidiManagerAlsa::MidiManagerAlsa() | 153 MidiManagerAlsa::MidiManagerAlsa() |
| 154 : event_thread_("MidiEventThread"), send_thread_("MidiSendThread") {} | 154 : event_thread_("MidiEventThread"), send_thread_("MidiSendThread") {} |
| 155 | 155 |
| 156 MidiManagerAlsa::~MidiManagerAlsa() { | 156 MidiManagerAlsa::~MidiManagerAlsa() { |
| 157 // Take lock to ensure that the members initialized on the IO thread | 157 // Take lock to ensure that the members initialized on the IO thread |
| 158 // are not destructed here. | 158 // are not destructed here. |
| 159 base::AutoLock lock(lazy_init_member_lock_); | 159 base::AutoLock lock(lazy_init_member_lock_); |
| 160 | 160 |
| 161 // Extra DCHECK to verify all members are already reset. | 161 // Extra DCHECK to verify all members are already reset. |
|
Adam Goode
2016/07/21 15:40:30
You could change all the DCHECK to CHECK here.
Takashi Toyoshima
2016/07/25 05:38:00
Done.
| |
| 162 DCHECK(!initialization_thread_checker_); | 162 DCHECK(!initialization_thread_checker_); |
| 163 DCHECK(!in_client_); | 163 DCHECK(!in_client_); |
| 164 DCHECK(!out_client_); | 164 DCHECK(!out_client_); |
| 165 DCHECK(!decoder_); | 165 DCHECK(!decoder_); |
| 166 DCHECK(!udev_); | 166 DCHECK(!udev_); |
| 167 DCHECK(!udev_monitor_); | 167 DCHECK(!udev_monitor_); |
| 168 | |
| 169 CHECK(!send_thread_.IsRunning()); | |
|
Adam Goode
2016/07/21 15:40:30
I don't think you can be sure of the result of IsR
Takashi Toyoshima
2016/07/21 18:25:24
IsRunning() is safe to be called from any thread.
| |
| 170 CHECK(!event_thread_.IsRunning()); | |
| 168 } | 171 } |
| 169 | 172 |
| 170 void MidiManagerAlsa::StartInitialization() { | 173 void MidiManagerAlsa::StartInitialization() { |
| 171 base::AutoLock lock(lazy_init_member_lock_); | 174 base::AutoLock lock(lazy_init_member_lock_); |
| 172 | 175 |
| 173 initialization_thread_checker_.reset(new base::ThreadChecker()); | 176 initialization_thread_checker_.reset(new base::ThreadChecker()); |
| 174 | 177 |
| 175 // Create client handles. | 178 // Create client handles. |
| 176 snd_seq_t* tmp_seq = nullptr; | 179 snd_seq_t* tmp_seq = nullptr; |
| 177 int err = | 180 int err = |
| (...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1394 source_map_[AddrToInt(client_id, port_id)] = port_index; | 1397 source_map_[AddrToInt(client_id, port_id)] = port_index; |
| 1395 return true; | 1398 return true; |
| 1396 } | 1399 } |
| 1397 | 1400 |
| 1398 MidiManager* MidiManager::Create() { | 1401 MidiManager* MidiManager::Create() { |
| 1399 return new MidiManagerAlsa(); | 1402 return new MidiManagerAlsa(); |
| 1400 } | 1403 } |
| 1401 | 1404 |
| 1402 } // namespace midi | 1405 } // namespace midi |
| 1403 } // namespace media | 1406 } // namespace media |
| OLD | NEW |